def get_new_desktop_name(parent_hwnd): """ Create a dialog box to ask the user for name of desktop to be created """ msgs = { win32con.WM_COMMAND: desktop_name_dlgproc, win32con.WM_CLOSE: desktop_name_dlgproc, win32con.WM_DESTROY: desktop_name_dlgproc } # dlg item [type, caption, id, (x,y,cx,cy), style, ex style style = win32con.WS_BORDER | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU ## |win32con.DS_SYSMODAL h = win32gui.CreateDialogIndirect(win32api.GetModuleHandle(None), [ ['One ugly dialog box !', (100, 100, 200, 100), style, 0], [ 'Button', 'Create', win32con.IDOK, (10, 10, 30, 20), win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_HOLLOW | win32con.BS_DEFPUSHBUTTON ], [ 'Button', 'Never mind', win32con.IDCANCEL, (45, 10, 50, 20), win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_HOLLOW ], ['Static', 'Desktop name:', 71, (10, 40, 70, 10), win32con.WS_VISIBLE], ['Edit', '', 72, (75, 40, 90, 10), win32con.WS_VISIBLE] ], parent_hwnd, msgs) ## parent_hwnd, msgs) win32gui.EnableWindow(h, True) hcontrol = win32gui.GetDlgItem(h, 72) win32gui.EnableWindow(hcontrol, True) win32gui.SetFocus(hcontrol)
def disablewins(self, arg=False): # disable the endprocess button listview = self.getlistview()[0] endprocessbutton = self.getendbutton() if listview: win32gui.EnableWindow(listview, bool(arg)) if endprocessbutton: win32gui.EnableWindow(endprocessbutton, bool(arg))
def OnClicked(self, id): if id == self.control_id: if self.atFinish(): if not self.currentPage.SaveAllControls(): return #finish win32gui.EnableWindow(self.forward_btn_hwnd, False) win32gui.EnableWindow(self.back_btn_hwnd, False) try: #optional h = GetControl( self.window.manager.dialog_parser.ids["IDCANCEL"]) win32gui.EnableWindow(h, False) except: pass self.finish_fn(self.window.manager, self.window) win32gui.EndDialog(self.window.hwnd, win32con.IDOK) else: #forward if self.canGoNext() and self.currentPage.SaveAllControls(): self.page_stack.append(self.currentPageIndex) nextPage = self.getNextPageIndex() self.switchToPage(nextPage) elif id == self.back_btn_id: #backward assert self.page_stack, "Back should be disabled when no back stack" pageNo = self.page_stack.pop() print "Back button switching to page", pageNo self.switchToPage(pageNo)
def changeControls(self): win32gui.EnableWindow(self.back_btn_hwnd, self.currentPageIndex != 0) if self.canGoNext(): enabled = 1 else: enabled = 0 win32gui.EnableWindow(self.forward_btn_hwnd, enabled) index = 0 if self.atFinish(): index = 1 win32gui.SetWindowText(self.forward_btn_hwnd, self.forward_captions[index])
def tk_como_modal(tk, fw_janela=FW_COLIBRI): """ Emula um diálogo modal. Desabilita a janela 'parent' e programa a sua reabilitação para antes do fechamento do diálogo. Altera a função tk.destroy para reabilitar a tela principal :param tk: janela do Tk :param fw_janela: Dados para FindWindow da janela 'parent' """ # janela fica sobre as outras tk.attributes('-topmost', 1) # Procuro a janela do Colibri h = win32gui.FindWindow(*fw_janela) if h: #desabilita a janela do Colibri win32gui.EnableWindow(h, False) # Ao finalizar, habilita a janela do Colibri e depois destrói destroy_org = tk.destroy #substituo a tk.destroy por essa aqui, que reabilita a janela def finaliza(self): win32gui.EnableWindow(h, True) destroy_org() tk.destroy = types.MethodType(finaliza, tk.__class__) # A destruição da janela pelo clique no [X] # invoca a função de finalização tk.wm_protocol('WM_DELETE_WINDOW', finaliza) # ESC sai do diálogo tk.bind('<Escape>', lambda e: tk.destroy())
def _run_application_modal(self, func): """ Run the specified function application modal if possible. """ ret = None if sys.platform == "win32": # when we show a modal dialog, the application should be disabled. # However, because the QApplication doesn't have control over the # main Softimage window we have to do this ourselves... import win32api, win32gui tk_softimage = self.import_module("tk_softimage") foreground_window = None saved_state = [] try: # find all windows and save enabled state: foreground_window = win32gui.GetForegroundWindow() #self.log_debug("Disabling main application windows before showing modal dialog") found_hwnds = tk_softimage.find_windows(thread_id = win32api.GetCurrentThreadId(), stop_if_found=False) for hwnd in found_hwnds: enabled = win32gui.IsWindowEnabled(hwnd) saved_state.append((hwnd, enabled)) if enabled: # disable the window: win32gui.EnableWindow(hwnd, False) # run function ret = func() except Exception, e: self.log_error("Error showing modal dialog: %s" % e) finally:
def OnCheckForwardTimer(self, event, time): #print "Timer fired" if self.canGoNext(): enabled = 1 else: enabled = 0 win32gui.EnableWindow(self.forward_btn_hwnd, enabled)
def main0(): # 获取窗口信息 i = 1 while i == 1: h = 1 while h <= hh: hwnd = hd[h] h += 1 # 根据titlename信息查找窗口 # hwnd = win32gui.FindWindow(0,titlename) win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL) # 窗口激活置顶 win32gui.EnableWindow(hwnd, True) win32gui.SetForegroundWindow(hwnd) # 等比例缩放找到按钮 x = [0] ratios = ('button_h10', 'button_xsfy') buttons = button.get_bottom(hwnd, ratios, button.ratio_types) x.extend(['button_h10', 'button_xsfy', 'button_h10']) # 设置随机延时和抖动 tr = random.uniform(0.5, 1) pr = random.uniform(3, 10) # 打印随机抖动 print('抖动 x轴=' + str(pr) + ' ,' + 'y轴=' + str(tr)) # 移动到对应位置,点击鼠标 for X in x: if X != 0: pyautogui.moveTo(buttons[X][0] + pr, buttons[X][1] + tr) pyautogui.click() # 打印和设置延时 print('延时' + str(tr)) time.sleep(tr)
def UpdateControl_FromValue(self): combo = self.GetControl() conn = self.func() if str(conn.getitem('_iscrm')) == 'False': win32gui.EnableWindow(combo, False) return try: list = [ 'CRM Lead' ] #, 'CRM Helpdesk', 'CRM Lead', 'CRM Meeting', 'CRM Opportunity', 'CRM Phonecall'] objlist = conn.GetAllObjects() if 'crm.claim' in objlist: list.append('CRM Claim') if 'crm.helpdesk' in objlist: list.append('CRM Helpdesk') if 'crm.fundraising' in objlist: list.append('CRM Fundraising') if 'hr.applicant' in objlist: list.append('HR Applicant') if 'project.issue' in objlist: list.append('Project Issue') win32gui.SendMessage(combo, win32con.CB_RESETCONTENT, 0, 0) for item in list: win32gui.SendMessage(combo, win32con.CB_ADDSTRING, 0, str(item)) win32gui.SendMessage(combo, win32con.CB_SETCURSEL, 0, 0) return except xmlrpclib.Fault, e: win32ui.MessageBox(str(e.faultCode), "CRM Case", win32con.MB_ICONEXCLAMATION)
def EnableKeyboardMouse(self, enable=True): """ Enables mouse and keyboard input for the window. :param enable: True to enable False to disable :type enable: bool :return: None :rtype: None """ self.AssertAlive() win32gui.EnableWindow(self.hwnd, enable)
def show_modal_dialog(self, dlg): """ Method to display a modal dialog that also disables the 3dsmax window. """ mb_disabled = self._runningModal # Save enabled state, so we can restore it when this modal dialog is done if (not mb_disabled): self._runningModal = True top = MB_Sub_Frame._top_mb_window_handle # get MB window handle win32gui.EnableWindow(top, False) # disable it ret_val = dlg.ShowModal( ) # show our dialog - won't continue until dialog is closed if ( not mb_disabled ): # enables 3dsmax window again, if it was enabled when this dialog started win32gui.EnableWindow(top, True) self._runningModal = False return ret_val
def close_file(handle, name): handle = win32gui.FindWindow(handle, name) win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.EnableWindow(handle, True) win32gui.SetForegroundWindow(handle) # 注意这里不可以用Atl+F4 pyautogui.keyDown('Ctrl') pyautogui.keyDown('F4') pyautogui.keyUp('Ctrl') pyautogui.keyUp("F4") sleep(2) pyautogui.press('Enter') sleep(2)
def UpdateControl_FromValue(self): combo = self.GetControl() conn = self.func() if str(conn.getitem('_iscrm')) == 'False': win32gui.EnableWindow(combo, False) return try: list = conn.GetCSList() win32gui.SendMessage(combo, win32con.CB_RESETCONTENT, 0, 0) for item in list: win32gui.SendMessage(combo, win32con.CB_ADDSTRING, 0, str(item)) win32gui.SendMessage(combo, win32con.CB_SETCURSEL, 0, 0) return except xmlrpclib.Fault, e: win32ui.MessageBox(str(e.faultCode), "CRM Case", win32con.MB_ICONEXCLAMATION)
def save_evidence1(self, screen_shot_name): save_screenshot(self, screen_shot_name) # 如果是第一次保留留痕,需要创建excel文件 evidence_file = file_path + "\\test_evidence.xls" if not os.path.exists(evidence_file): workbook = xlwt.Workbook(encoding='utf-8') # 新建工作簿 sheet1 = workbook.add_sheet("evidence") # 这里应该是用例名称 workbook.save(evidence_file) # 保存 # 打开截图留痕excel win32api.ShellExecute(0, 'open', evidence_file, '', '', 1) # 等待excel打开,等待时间是不是有点长 sleep(10) # 获得excel临时文件的句柄 # handle = win32gui.FindWindow("XLMAIN", "Microsoft Excel - test_evidence.xls [互換モード]") handle = win32gui.FindWindow("XLMAIN", "Microsoft Excel - test_evidence.xls") # 激活并显示窗口。 win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.EnableWindow(handle, True) win32gui.SetForegroundWindow(handle) # 获取最下方缩小excel的图标,并缩小至70% sleep(1) # 设置输入法为英文 set_EN() pyautogui.moveTo(1311, 848) sleep(1) pyautogui.click() pyautogui.click() pyautogui.click() sleep(1) first_save_evidence = 1 # 如果是第二次留痕 else: sleep(1) # 获得excel临时文件的句柄 handle = win32gui.FindWindow("XLMAIN", "Microsoft Excel - test_evidence.xls") # 激活并显示窗口。 win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.EnableWindow(handle, True) win32gui.SetForegroundWindow(handle) sleep(2) # 点击插入图片,并插入截图好的evidence图片 pyautogui.keyDown('Alt') pyautogui.keyDown("I") pyautogui.keyUp('Alt') pyautogui.keyUp("I") pyautogui.press('P') pyautogui.press('F') # 鼠标移动到文件路径位置 time.sleep(2) for i in range(0, 6): pyautogui.press("Tab") sleep(1) pyautogui.press("space") insert_file_path = file_path pyautogui.typewrite(insert_file_path) time.sleep(1) pyautogui.press('enter') for i in range(0, 5): pyautogui.press("Tab") sleep(1) insert_file_name = filename + ".png" pyautogui.typewrite(insert_file_name) time.sleep(1) pyautogui.press('enter') sleep(1) # 鼠标移动到excel下移图标位置,并移动至空白行,为下一次插入图片的位置做准备 pyautogui.moveTo(1427, 814) for i in range(0, 47): pyautogui.click() sleep(5) # 鼠标移动到excel的初始插入位置 x, y = 35, 186 pyautogui.moveTo(x, y) pyautogui.click() time.sleep(1) # 使excel成为disableWindow win32gui.ShowWindow(handle, win32con.SW_MINIMIZE) win32gui.EnableWindow(handle, False)
def GuiInit(): #初始化pygame pygame.init() #获取屏幕逻辑宽度与高度 DesktopHwnd=win32gui.GetDesktopWindow() MonitorHwnd=win32api.MonitorFromWindow(DesktopHwnd,win32con.MONITOR_DEFAULTTONEAREST) ScreenWidth=win32api.GetMonitorInfo(MonitorHwnd)["Monitor"][2] ScreenHeight=win32api.GetMonitorInfo(MonitorHwnd)["Monitor"][3] #初始化窗口 WindowWidth=1080 WindowHeight=661 Window = pygame.display.set_mode((WindowWidth,WindowHeight),pygame.NOFRAME) pygame.display.set_caption("基于Python的电脑使用情况统计系统") pygame.display.set_icon(pygame.image.load("Images/Icon.ico")) #获得窗口句柄 MeHwnd=pygame.display.get_wm_info()["window"] #隐藏窗口 win32gui.ShowWindow(MeHwnd,win32con.SW_HIDE) #绘制窗口背景 BackgroundImage=pygame.image.load("Images/Back.jpg") Window.blit(BackgroundImage,[0,0]) pygame.display.flip() #窗口居中 win32gui.SetWindowPos(MeHwnd,0,int((ScreenWidth-WindowWidth)/2),int((ScreenHeight-WindowHeight)/2),WindowWidth,WindowHeight,win32con.SWP_NOZORDER | win32con.SWP_NOSIZE) #窗口圆角 RoundRegion=win32gui.CreateRoundRectRgn(0, 0, WindowWidth, WindowHeight, 60, 60) win32gui.SetWindowRgn(MeHwnd, RoundRegion, True) #设置透明度1 win32gui.SetWindowLong(MeHwnd,win32con.GWL_EXSTYLE,win32con.WS_EX_LAYERED) win32gui.SetLayeredWindowAttributes(MeHwnd,0,1,win32con.LWA_ALPHA) #显示窗口 win32gui.ShowWindow(MeHwnd,win32con.SW_SHOW) #淡入 for i in range(1,241): win32gui.SetLayeredWindowAttributes(MeHwnd,0,i,win32con.LWA_ALPHA) pygame.display.flip() pygame.time.delay(4) #初始化信息 GetForegroundInfo(MeHwnd,1) #开启检测今日是否结束线程 tDayEnd=threading._start_new_thread(IsDayEnd,()) #开启窗口消息钩子 StartHook(MeHwnd) while True: #鼠标光标 try: CurX,CurY=win32api.GetCursorPos() except: CurX,CurY=(0,0) WindowX,WindowY,WindowW,WindowH=win32gui.GetWindowRect(MeHwnd) if WindowX<CurX<WindowX+WindowW and WindowY<CurY<WindowY+WindowH: IsInWindow=True while win32api.ShowCursor(False)>=0: win32api.ShowCursor(False) else: IsInWindow=False while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) #遍历所有事件 for event in pygame.event.get(): #退出事件 if event.type == pygame.QUIT: while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) if win32api.MessageBox(0,"确定要退出系统吗?","提示",win32con.MB_OKCANCEL | win32con.MB_ICONQUESTION | win32con.MB_TOPMOST)==1: GetForegroundInfo(MeHwnd,2) EndHook(MeHwnd) FadeOut(MeHwnd) return 1 #鼠标按下事件 elif event.type == pygame.MOUSEBUTTONDOWN: if event.button==1: if True in BtnStatus: #数据汇总 if BtnStatus.index(True)==0: win32gui.EnableWindow(MeHwnd,False) while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) SheetDataGUI() win32gui.EnableWindow(MeHwnd,True) #今日数据 elif BtnStatus.index(True)==1: win32gui.EnableWindow(MeHwnd,False) while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) ShowSheetLogGUI() win32gui.EnableWindow(MeHwnd,True) #统计视图 elif BtnStatus.index(True)==2: win32gui.EnableWindow(MeHwnd,False) while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) ShowChartOptionGUI() win32gui.EnableWindow(MeHwnd,True) #隐藏窗口 elif BtnStatus.index(True)==3: while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) win32api.MessageBox(0,"提示:按下Ctrl+F10可以重新显示窗口","隐藏窗口",win32con.MB_OK | win32con.MB_ICONINFORMATION | win32con.MB_TOPMOST,0) tShowWindow=threading._start_new_thread(HotKeyShowWindow,(MeHwnd,)) #超时提醒 elif BtnStatus.index(True)==4: win32gui.EnableWindow(MeHwnd,False) while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) ShowRemindGUI() win32gui.EnableWindow(MeHwnd,True) #最小化 elif BtnStatus.index(True)==6: win32gui.ShowWindow(MeHwnd,win32con.SW_MINIMIZE) #退出系统 elif BtnStatus.index(True)==5 or BtnStatus.index(True)==7: while win32api.ShowCursor(True)<0: win32api.ShowCursor(True) if win32api.MessageBox(0,"确定要退出系统吗?","提示",win32con.MB_OKCANCEL | win32con.MB_ICONQUESTION | win32con.MB_TOPMOST)==1: GetForegroundInfo(MeHwnd,2) EndHook(MeHwnd) FadeOut(MeHwnd) return 1 #窗口拖动 else: win32gui.ReleaseCapture() win32gui.SendMessage(MeHwnd, win32con.WM_NCLBUTTONDOWN, win32con.HTCAPTION, 0) #鼠标移动事件 elif event.type==pygame.MOUSEMOTION: MouseMoveCheckButton(event.pos[0],event.pos[1]) CurrentX=event.pos[0] CurrentY=event.pos[1] #其他事件 else: pass #绘制窗口 Window.blit(BackgroundImage,[0,0]) for i in range(8): if BtnStatus[i]:Window.blit(BtnPng[i],BtnPos[i]) if IsInWindow: if True in BtnStatus: Window.blit(CurHand,[CurrentX,CurrentY]) else: Window.blit(CurArrow,[CurrentX,CurrentY]) pygame.display.flip()
def unlock_window(hwnd, hwnd2): win32gui.EnableWindow(hwnd, True) win32gui.EnableWindow(hwnd2, True)
def UpdateEnabledStates(self, enabled): for other in self.disable_ids: win32gui.EnableWindow(self.GetControl(other), enabled)
return elem[0] cycle_fake.sort(key=first) return cycle_fake if __name__ == '__main__': None_k = 0 while True: # 随机延时,抖动 tr = random.uniform(0.5, 1) # 窗口置顶 titlename = "阴阳师-网易游戏" # titlename = "阴阳师 - MuMu模拟器" hwnd = win32gui.FindWindow(0, titlename) win32gui.EnableWindow(hwnd, True) win32gui.SetForegroundWindow(hwnd) # 获取窗口信息 left, top, right, bottom = win32gui.GetWindowRect(hwnd) start_bottom = [(left + (right - left) * 0.864290509), (top + (bottom - top) * 0.8)] explore_bottom = [(left + (right - left) * 0.734), (top + (bottom - top) * 0.759)] left_bottom = [(left + (right - left) * 0.3), (top + (bottom - top) * 0.759)] # 截图 for i in range(10): window_capture('ji.jpg') # 查找圆 cycles = cycle_capture('ji.jpg') os.remove('ji.jpg')
#self.log_debug("Disabling main application windows before showing modal dialog") found_hwnds = tk_softimage.find_windows( thread_id=win32api.GetCurrentThreadId(), stop_if_found=False) for hwnd in found_hwnds: enabled = win32gui.IsWindowEnabled(hwnd) saved_state.append((hwnd, enabled)) if enabled: # disable the window: win32gui.EnableWindow(hwnd, False) # run function ret = func() except Exception, e: self.log_error("Error showing modal dialog: %s" % e) finally: #self.log_debug("Restoring state of main application windows") # kinda important to ensure we restore other window state: for hwnd, state in saved_state: if win32gui.IsWindowEnabled(hwnd) != state: # restore the state: win32gui.EnableWindow(hwnd, state) if foreground_window: win32gui.SetForegroundWindow(foreground_window) else: # show dialog: ret = func() return ret
def save_evidence(self, screen_shot_name): save_screenshot(self, screen_shot_name) # 如果是第一次保留留痕,需要创建excel文件 evidence_file = suite_path + "\\" + suite_name + "\\test_evidence.xlsx" if not os.path.exists(evidence_file): global wb wb = Workbook() sheet_name = get_func_name() ws = wb.create_sheet(sheet_name, 0) # wb.remove("sheet") # ws = wb[sheet_name] wb.save(evidence_file) wb.close() # global workboo # workbook = xlwt.Workbook(encoding='utf-8') # 新建工作簿 # sheet_name = get_func_name() # sheet1 = workbook.add_sheet(sheet_name) # 这里应该是用例名称 # # sheet = workbook.add_sheet("evidence") # 这里应该是用例名称 # workbook.save(evidence_file) # 保存 # 打开截图留痕excel win32api.ShellExecute(0, 'open', evidence_file, '', '', 1) # 等待excel打开,等待时间是不是有点长 sleep(10) # 获得excel临时文件的句柄 # handle = win32gui.FindWindow("XLMAIN", "Microsoft Excel - test_evidence.xlsx [互換モード]") handle = win32gui.FindWindow("XLMAIN", "Microsoft Excel - test_evidence.xlsx") # 激活并显示窗口。 win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.EnableWindow(handle, True) win32gui.SetForegroundWindow(handle) # 获取最下方缩小excel的图标,并缩小至70% sleep(1) # 设置输入法为英文 set_EN() pyautogui.moveTo(1311, 848) sleep(1) pyautogui.click() pyautogui.click() pyautogui.click() sleep(1) first_save_evidence = 1 # 如果是第二次留痕 else: sleep(1) # 获得excel临时文件的句柄 # wb = load_workbook(evidence_file) # print("evidence_file",evidence_file) # wb = win32api.ShellExecute(0, 'open', evidence_file, '', '', 1) # sleep(5) # sheet_name = get_func_name() # # ws = wb.create_sheet(sheet_name)sleep(10) # # sheet_name = get_func_name() # # wb.save(evidence_file) # # print("666") # with pd.ExcelWriter(evidence_file) as writer: # data = "1" # data.to_excel(writer, sheet_name=sheet_name) handle = win32gui.FindWindow("XLMAIN", "Microsoft Excel - test_evidence.xlsx") # 激活并显示窗口。 win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.EnableWindow(handle, True) win32gui.SetForegroundWindow(handle) # sheet_name = get_func_name() # print("2workbook", workbook) # print("2sheet_name", sheet_name) # sleep(2) # sheet2 = workbook.add_sheet(sheet_name) # 这里应该是用例名称 # # ws1 = workbook.create_sheet("Mysheet") # #sheet2 = workbook.add_sheet(sheet_name) # 这里应该是用例名称 # #workbook.save(evidence_file) # 保存 sleep(2) sleep(2) # 点击插入图片,并插入截图好的evidence图片 pyautogui.keyDown('Alt') pyautogui.keyDown("I") pyautogui.keyUp('Alt') pyautogui.keyUp("I") pyautogui.press('P') pyautogui.press('F') # 通过tab选中文件 time.sleep(2) for i in range(0, 6): pyautogui.press("Tab") sleep(0.5) sleep(1) pyautogui.press("space") insert_file_path = suite_path + "\\" + suite_name pyautogui.typewrite(insert_file_path) sleep(1) pyautogui.press('enter') sleep(2) for i in range(0, 5): pyautogui.press("Tab") sleep(0.5) sleep(1) insert_file_name = screenshot_name + ".png" pyautogui.typewrite(insert_file_name) time.sleep(1) pyautogui.press('enter') sleep(1) # 鼠标移动到excel下移图标位置,并移动至空白行,为下一次插入图片的位置做准备 pyautogui.moveTo(1427, 814) for i in range(0, 47): pyautogui.click() sleep(5) # 鼠标移动到excel的初始插入位置 x, y = 35, 186 pyautogui.moveTo(x, y) pyautogui.click() time.sleep(1) # 使excel成为disableWindow win32gui.ShowWindow(handle, win32con.SW_MINIMIZE) win32gui.EnableWindow(handle, False)
def EnableWindow(self, state): win32gui.EnableWindow(self._hwnd, state)
def SetEnabledStates(self, enabled): for id in self.disable_while_running_ids: win32gui.EnableWindow(self.GetControl(id), enabled)
def setEnabled(self, enabled): if not self.widget: return if enabled: win32gui.EnableWindow(self.widget, 1) else: win32gui.EnableWindow(self.widget, 0)
def finaliza(self): win32gui.EnableWindow(h, True) destroy_org()
# win32api.SendMessage(hWnd, win32con.WM_MOUSEMOVE, 0, lParam) # win32api.SendMessage(hWnd, win32con.WM_LBUTTONDOWN, 0, lParam) # wParam = win32con.MK_LBUTTON # win32api.SendMessage(hWnd, win32con.WM_LBUTTONUP, 0, lParam) print('SUUUCK') # hc.move((600,300), 1) # find('Steam', 960, 540, 200, 200) steam = FindWindow_bySearch('Steam') paint = FindWindow_bySearch('test.jpg - Paint') win32gui.ShowWindow(paint, win32con.SW_RESTORE) win32gui.SetForegroundWindow(paint) win32gui.EnableWindow(paint, True) # win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, 400, 400, 0, 0) # win32con.MOUSEEVENTF_LEFTDOWN # win32gui.MoveWindow(paint, 100, 100, 400, 400, 1) ppos = getCentre(paint) print(ppos) time.sleep(1) Mouse.move_mouse(ppos) doEvent(win32con.MOUSEEVENTF_LEFTDOWN, ppos) doEvent(win32con.MOUSEEVENTF_LEFTUP, ppos) # doEvent(paint, win32con.WM_MOUSEMOVE, getCentre(paint)) # doEvent(paint, win32con.WM_LBUTTONDOWN, getCentre(paint)) # doEvent(paint, win32con.WM_LBUTTONUP, getCentre(paint)) print('Done!')