1.编写autoit脚本:upload.au3
ControlFocus("打开", "", "Edit1") ;用于识别windwos窗口 WinWait("[CLASS:#32770]", "", 3) ;等待窗口显示 ControlSetText("打开", "", "Edit1", $CmdLine[1]) ;用于向“文件名”输入框内输入本地文件路径 Sleep(2000) ;等待2秒 ControlClick("打开","","Button1") ;点击窗口的打开按钮
2.将上述autoit.au3脚本编译成exe文件:upload.exe
3.python调用
import os class Upload: # 上传文件方法 def upload_file(self, exe_path, file_path): ''' :param exe_path: 生成的upload.exe的路径 :param file_path: 要上传的文件的路径 ''' try: if os.path.exists(exe_path): os.system('%s %s' %(exe_path, file_path)) except Exception as e: raise e if __name__ == '__main__': up = Upload() exe_path = r'' file_path = r'' up.upload_file(exe_path,file_path)
标签:__,exe,upload,参数,file,autoIt,path,上传 From: https://www.cnblogs.com/Small-lucky/p/17029721.html