對剪切板的失控異常的處理---多半的時間再處理剪切板的失控---冗餘操做api
import timeimport win32gui, win32ui, win32con, win32apifrom PIL import Imageimport pytesseractimport osqqu, qqp = ('25', 'h2020')win_p=(1714,942)# 將app窗口置爲當前窗口,等效點,選3個,點擊time.sleep(6)l = [(15, 81), (23, 120), (22, 126)]for i in l: x, y = i win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)#登錄口qqqqx, qqy = (358, 239)x,y=qqx,qqywin32api.SetCursorPos([x, y])win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)time.sleep(0.05)win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)time.sleep(0.05)win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y)time.sleep(0.05)win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)time.sleep(10)import win32clipboardqqu_p, qqp_p=(93,347),(151,447)#點擊帳號輸入區,調出搜狗輸入法appx,y=qqu_pfor i in range(20): win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) # time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(0.5) print(i)time.sleep(10)for i in range(3): x,y=win_p win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(1)#剪切板內容賦值for i in range(10): win32clipboard.OpenClipboard() # win32clipboard.EmptyClipboard() ms =qqu win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, '') win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, ms) cs = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) print(i,cs) time.sleep(1) try: win32clipboard.CloseClipboard() except Exception as e: print(e)# 將app窗口置爲當前窗口,等效點,選3個,點擊time.sleep(6)l = [(15, 81), (23, 120), (22, 126)]for i in l: x, y = i win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)#剪切板內容賦值for i in range(10): win32clipboard.OpenClipboard() # win32clipboard.EmptyClipboard() ms =qqu win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, '') win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, ms) cs = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) print(i,cs) time.sleep(1) try: win32clipboard.CloseClipboard() except Exception as e: print(e)time.sleep(20)#搜搜輸入法,輸入至目標區#複製-粘貼路徑1input_app_p=[(344,635),(463,793)]#複製-粘貼路徑2input_app_pb=[(49,623),(497,979),(287,710)]for i in input_app_pb: x,y=i win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(30)for i in range(3): x,y=win_p win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(1)time.sleep(10)#剪切板內容賦值for i in range(10): win32clipboard.OpenClipboard() # win32clipboard.EmptyClipboard() ms =qqp win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, '') win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, ms) cs = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) print(i,cs) time.sleep(1) try: win32clipboard.CloseClipboard() except Exception as e: print(e)time.sleep(20)# 將app窗口置爲當前窗口,等效點,選3個,點擊time.sleep(6)l = [(15, 81), (23, 120), (22, 126)]for i in l: x, y = i win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y)#剪切板內容賦值for i in range(10): win32clipboard.OpenClipboard() # win32clipboard.EmptyClipboard() ms =qqp win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, '') win32clipboard.SetClipboardData(win32con.CF_UNICODETEXT, ms) cs = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) print(i,cs) time.sleep(1) try: win32clipboard.CloseClipboard() except Exception as e: print(e)x,y=qqp_pfor i in range(20): win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) # time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(0.5) print(i)#搜搜輸入法,輸入至目標區#複製-粘貼路徑1input_app_p=[(344,635),(463,793)]#複製-粘貼路徑2input_app_pb=[(49,623),(497,979),(287,710)]for i in input_app_pb: x,y=i win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(30)time.sleep(10)login_p=(217,537)for i in range(3): x,y=login_p win32api.SetCursorPos([x, y]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y) time.sleep(10)time.sleep(30)os._exit(5435)