Python 链接 Pcomm
下载 GitHUb AS400 Interface, 并 install comtypes package
# python -m pip install comtypes
from ibmpcomm import Instance
def main():
wSession = Instance(session='A')
GotoCmdEntry(wSession)
wSession.set_text(text='Dspjob',row=18,column=7)
wSession.send_keys(key='[Enter]')
wSession.wait(1)
wjobname = wSession.get_text(row=3,column=9,length=10).decode('UTF-8')
print('job is ',wjobname)
wSession.send_keys(key='[pf12]')
def GotoCmdEntry(wSession):
wstr = wSession.get_text(row=1,column=34,length=13).decode('UTF-8')
i = 0
while True:
if i > 20 : break
if wstr == 'Command Entry': break
wstr1 = wSession.get_text(row=1,column=1,length=80).decode('UTF-8')
if wstr1.find('Exit Interactive SQL') > 0: wSession.send_keys(key='[Enter]')
wSession.send_keys(key='[pf12]')
i += 1
wstr = wSession.get_text(row=1, column=34, length=13).decode('UTF-8')
wSession.send_keys(key='[reset]')
wSession.send_keys(key='[sys attn]')
wSession.wait(1)
if __name__ == '__main__':
main()