Because to batch use a software to deal with a batch of EPS files, so to simulate the mouse and keyboard action, so that it can automate the operation.
#-*-coding:utf-8-*-
Import OS
Import time
Import Win32gui
Import Win32API
Import Win32con
From PIL import Imagegrab
#os. Startfile ("D:\\artcut6\\prog\\artcut6.exe")
#time. Sleep (1)
Wdname1=u "Ventece painting 2009[]-[no title-1]"
W1hd=win32gui. FindWindow (0,WDNAME1)
Print W1HD
W2hd=win32gui. FindWindowEx (W1hd,none,none,none)
Print W2HD
def aotohelper_wt (i):
#获取窗口焦点
Win32gui. SetForegroundWindow (W2HD)
#快捷键Alt +f
Win32api.keybd_event (18,0,0,0) # ALT
Win32api.keybd_event (70,0,0,0) # F
Win32api.keybd_event (70,0,win32con. keyeventf_keyup,0) #释放按键
Win32api.keybd_event (18,0,win32con. keyeventf_keyup,0)
#快捷键I
Win32api.keybd_event (73,0,0,0) # I
Win32api.keybd_event (73,0,win32con. keyeventf_keyup,0)
Time.sleep (0.2)
Wdname3=u "Open"
W3hd=win32gui. FindWindow (none,wdname3) # Open Window handle
#print W3HD
#win32gui. MoveWindow (W3HD, A, M, True)
If i<=9:
Msg= "YC-00" +str (i)
Elif 10<=i<=99:
Msg= "YC-0" +str (i)
Else
Msg= "yc-" +str (i)
Edithd=win32gui. FindWindowEx (W3hd,none, "Edit", None)
Win32API. SendMessage (Edithd,win32con. WM_SETTEXT,NONE,MSG)
Time.sleep (0.1)
#btnhd =win32gui. FindWindowEx (W3hd,none, "button", None)
#print BTNHD
#模拟快捷键Alt +o
Win32api.keybd_event (18,0,0,0) # ALT
Win32api.keybd_event (79,0,0,0) # O
Win32api.keybd_event (79,0,win32con. keyeventf_keyup,0) #释放按键
Win32api.keybd_event (18,0,win32con. keyeventf_keyup,0)
Time.sleep (0.1)
#模拟鼠标操作
Win32API. Setcursorpos ([30,150]) #为鼠标焦点设定一个位置
Win32api.mouse_event (Win32con. mouseeventf_leftdown,0,0,0,0)
Win32API. Setcursorpos ([500,500])
Win32api.mouse_event (Win32con. mouseeventf_leftup,0,0,0,0)
Time.sleep (0.1)
#模拟快捷键F7 (Limit observation)
Win32api.keybd_event (118,0,0,0) # F7
Win32api.keybd_event (118,0,win32con. keyeventf_keyup,0) #释放按键
Time.sleep (0.2)
#利用PIL截屏
Path= "C:\\users\\ly\\desktop\\pic\\"
Filename= "yc-" +str (i) + ". jpg"
Im=imagegrab.grab ()
Im.save (Path+filename)
#模拟快捷键F8 (Back to the original page size)
Win32api.keybd_event (119,0,0,0) # F8
Win32api.keybd_event (119,0,win32con. keyeventf_keyup,0) #释放按键
#模拟键盘事件delete
Win32api.keybd_event (46,0,0,0) # Delete
Win32api.keybd_event (46,0,win32con. keyeventf_keyup,0) #释放按键
Time.sleep (1)
For I in Range (2,85):
AOTOHELPER_WT (i)
Print I
Print "Work done!"