def getProcess(self): ''' :description 获取指定窗口关联的进程ID(PID). :return PID:成功, -1:失败. ''' return autoit.win_get_process(self.title, text=self.text)
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/6/27 9:29 # @Author : qiubin # @File : test_xlsx.py # @Software: PyCharm import openpyxl import unittest from ddt import ddt, data, unpack import os import autoit # name_path = r"C:\Users\admin\Documents\WeChat Files\qiubin1984\FileStorage\File\2019-07\72a6e5c84419711b048d0e9930b57fe2_t.gif" # print(os.path.splitext(os.path.basename(name_path))) for file in os.listdir('D:/'): if os.path.splitext(file)[1][1:] in ['png', 'zip']: print(file) autoit.run("notepad.exe") autoit.win_wait_active("[CLASS:Notepad]", 3) print(autoit.win_get_process("[CLASS:Notepad]")) autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}") autoit.win_close("[CLASS:Notepad]") autoit.control_click("记事本", "[CLASS:Button;Instance:3]") autoit.win_close("[CLASS:Notepad]") autoit.control_click("记事本", "[CLASS:Button;Instance:2]")
def getProcess(self): """获取指定窗口关联的进程ID""" return autoit.win_get_process(self.title, text=self.text)
import autoit import time #NIU-RSA-PC1 - RSA SecurID Token / RSA SecurID Token - the two titles my app has # I believe the second one is what i need rsa_path = "C:\\Program Files\\RSA SecurID Software Token\\SecurID.exe" nc_path = "C:\\Program Files (x86)\\Juniper Networks\\Network Connect 7.4.0\\dsNetworkConnect.exe" autoit.run(rsa_path) active = autoit.win_wait_active( "NIU-RSA-PC1 - RSA SecurID Token", 10) # perfect, waits until second, real window opens and acts immediately! title = autoit.win_get_title("[CLASS:QWidget]") prccessid = autoit.win_get_process("NIU-RSA-PC1 - RSA SecurID Token") time.sleep(0.5) RSA_Text = autoit.win_get_text("[CLASS:QWidget]") #autoit.control_send("NIU-RSA-PC1 - RSA SecurID Token", 'edit', "dodo") # text = autoit.win_get_text("NIU-RSA-PC1 - RSA SecurID Token") print(active, title, prccessid, RSA_Text) autoit.win_close("NIU-RSA-PC1 - RSA SecurID Token") # autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}") # autoit.win_close("[CLASS:Notepad]")