|

楼主 |
发表于 2021-3-24 15:36:38
|
显示全部楼层
- import win32gui,win32con,win32api,os,time,win32com
- from ctypes import *
- from win32com.client import Dispatch, constants
- from pykeyboard import PyKeyboard # 这个绝对不能pip 而是需要pip pyuserinput
- # pyuserinput 之后 千万不要 pip pykeyboard
- #lst=open("yzg.txt","r")
- #for zh in lst:
- zh="69003004"
- #print(x)
- apppath=r'"C:\Program Files (x86)\UleSoft\邮掌柜4\邮掌柜.exe"'
- apppath=r'"E:\360SoftMgrGame\邮掌柜4\邮掌柜.exe"'
- #os.system(apppath) #这个system是拥塞式执行,不适合本程序
- os.popen(apppath)
- time.sleep(1)
- shell = win32com.client.Dispatch("WScript.Shell")
- shell.SendKeys('%')
- win32gui.SetForegroundWindow(win32gui.FindWindow("CefBrowserWindow","邮掌柜"))
- hwnd=win32gui.GetForegroundWindow()
- xypos=win32gui.GetWindowPlacement(hwnd)[4]
- x,y=xypos[0],xypos[1]
- hight=xypos[3]-xypos[1]
- width=xypos[2]-xypos[0]
- pos_x=x+width*0.70
- pos_y=y+hight*0.455
- #print(pos_x,pos_y)
- time.sleep(1)
- windll.user32.SetCursorPos(int(pos_x),int(pos_y))
- win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
- win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
- into=PyKeyboard()
- into.tap_key(into.backspace_key,n=10,interval=0.1)
- into.type_string(zh)
- time.sleep(1)
- win32api.keybd_event(9,0,0,0) #9 代表TAB
- win32api.keybd_event(9,0,win32con.KEYEVENTF_KEYUP,0)
- into.type_string(zh)
- time.sleep(1)
- win32api.keybd_event(13,0,0,0) #13 代表回车
- win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0)
- time.sleep(3)
- win32api.keybd_event(18,0,0,0) #115 代表ALT
- win32api.keybd_event(115,0,0,0) #115 代表F4
- win32api.keybd_event(115,0,win32con.KEYEVENTF_KEYUP,0)
- win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0)
- time.sleep(2)
- win32api.keybd_event(13,0,0,0) #13 代表回车
- win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0)
- #break
复制代码 |
|