def mouse_up(self, button=Key.VK_LBUTTON, l_param=None): params = { Key.VK_LBUTTON: [win32con.WM_LBUTTONUP, None], Key.VK_RBUTTON: [win32con.WM_RBUTTONUP, None], Key.VK_MBUTTON: [win32con.WM_MBUTTONUP, None] } u_int, w_param = params[button] win32api.PostMessage(self.hwnd, u_int, w_param, l_param)
def LaunchVugen(self, ExePath, ScriptPath, FlagFileName, my_TIMEOUTMAX_COVERPAGE="10", my_TIMEOUTMAX="8"): TIMEOUTMAX_COVERPAGE = string.atoi(my_TIMEOUTMAX_COVERPAGE) TIMEOUTMAX = string.atoi(my_TIMEOUTMAX) try: #launch win32process.CreateProcess(ExePath, ScriptPath, None, None, 0, win32process.CREATE_NO_WINDOW, None, None, win32process.STARTUPINFO()) #wait 6 seconds for Vugen opened. time.sleep(10) #run #get windows class clss = 'VugenMainWindowClass' #find handle for the windows hwnd = win32gui.FindWindow(clss, None) print hwnd time.sleep(TIMEOUTMAX_COVERPAGE) #post VK_F5,to do run script print win32api.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_F5, 0) #loop to check Flag timeout = 1 ret = 0 while ret == 0: #check flag every 10 seconds time.sleep(10) ret = self.CheckFlag(FlagFileName) #judge timeout if timeout == TIMEOUTMAX: # ret = -1 timeout = timeout + 1 print timeout time.sleep(1) #ret is 1,means operate success,else failed. if ret == 1: win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0) print "ok" return 1 else: win32api.SendMessage(hwnd, win32con.WM_CLOSE, 0, 0) print "ng" return -1 print "NG" except: print ERROR_MSG_VUGEN_CHECK
def stopThreads(): for t in self.threadToMsgWindow.keys(): # PostMessage blocks for dead threads if t.isAlive() and self.threadToMsgWindowCreated[t]: win32api.PostMessage( self.threadToMsgWindow[t], # thread id WM_CLOSE_THREAD, # message 0, # wParam 0 # lParam )
def mouse_down(self, button=Key.VK_LBUTTON, l_param=None): # May need to call WM_MOUSEMOVE before hand depending on usage if not using through click() params = { Key.VK_LBUTTON: [win32con.WM_LBUTTONDOWN, None], Key.VK_RBUTTON: [win32con.WM_RBUTTONDOWN, None], Key.VK_MBUTTON: [win32con.WM_MBUTTONDOWN, None] } u_int, w_param = params[button] win32api.PostMessage(self.hwnd, u_int, w_param, l_param)
def NotifyAutoxdShow(self, code): return 0 #窗口通知 hwnd = LiveData().getFrameHwnd() code = int(code) #lparam为整型的股票代码, wparam为补充0的个数 try: win32api.PostMessage(hwnd, 0x400 + 101, code, 6 - len(str(code))) except: pass
def send_to_rstudio(cmd): rid = win32gui.FindWindow("Qt5QWindowIcon", "RStudio") if rid: clipboard.set_clipboard(cmd) time.sleep(0.01) win32api.PostMessage(rid, win32con.WM_KEYDOWN, ord("V"), 0) time.sleep(0.01) # set focus win32api.PostMessage(rid, win32con.WM_SETFOCUS, 0, 0) time.sleep(0.01) win32api.PostMessage(rid, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) time.sleep(0.01) clipboard.reset_clipboard()
def RightClick(self, Position): ClientPosition = win32gui.ScreenToClient(self.hwnd, Position) PositionToClick = win32api.MAKELONG(ClientPosition[0], ClientPosition[1] + 23) win32api.PostMessage(self.hwnd, win32con.WM_MOUSEMOVE, 0, PositionToClick) win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONDOWN, win32con.MK_RBUTTON, PositionToClick) win32api.SendMessage(self.hwnd, win32con.WM_RBUTTONUP, win32con.MK_RBUTTON, PositionToClick)
def closeMhxy(): mhName = u"梦幻手游辅助v"+ver # 获得窗体的句柄 # 从顶层窗口向下搜索主窗口,无法搜索子窗口 mhwin = win32gui.FindWindow(None,mhName) if(mhwin > 0): # 该函数将一个消息放入(寄送)到与指定窗口创建的线程相联系消息队列里,不等待线程处理消息就返回。消息队列里的消息通过调用GetMessage和PeekMessage取得。 # 寄送的消息:win32con.WM_QUIT,加的消息特定的信息:0 # 应该是关闭窗体 win32api.PostMessage(mhwin, win32con.WM_QUIT, 0, 0)
def handle_verify(parent_trade_hwnd, hold_panel_hwnd, data_grid_hwnd): # TODO 解决获取不到验证码对话框的 hwnd句柄的问题 def call_back(handle, dialog_l): dialog_l.append(handle) if win_is_verify_code(handle,parent_trade_hwnd) else None # todo """ 下单 时不论成功失败,肯定在最后有一个 提示 弹框 """ while True: dialog_list = [] # 对话框的长度 win32gui.EnumWindows(call_back, dialog_list) # 获得 每个 dialog 句柄的子句柄,判断出是 提示 弹出窗 # 如果提示窗口过多,表示有错误; 如果没有提示信息窗口,等待弹出窗口 if len(dialog_list) > 1: exit(-1) if len(dialog_list) == 0: time.sleep(0.1) continue if len(dialog_list) == 1: dialog_hwnd, pic_hwnd, input_hwnd = dialog_list[0], -1, -1 dialog_sons = [] win32gui.EnumChildWindows(dialog_hwnd, lambda handle, param: param.append(handle), dialog_sons) dialog_rect = win32gui.GetWindowRect(dialog_hwnd) pic = GuiPosition(HwndType.Static, 186, 89, 62, 23) input_box = GuiPosition(HwndType.Edit, 93, 90, 86, 20) button = GuiPosition(HwndType.Button, 96, 149, 60, 24) for dialog in dialog_sons: if pos_in_window_rect(pic, dialog_rect, dialog): pic_hwnd = dialog elif pos_in_window_rect(input_box, dialog_rect, dialog): input_hwnd = dialog elif pos_in_window_rect(button, dialog_rect, dialog): button_hwnd = dialog # todo 验证码弹框, 使用ocr识别 identify_code = "1234" identify_code = ocr_string_from_hwnd(pic_hwnd, expand=10) win32gui.SendMessage(input_hwnd, win32con.WM_SETTEXT, None, identify_code) win32api.PostMessage(button_hwnd, win32con.WM_LBUTTONDOWN, None, None) win32api.PostMessage(button_hwnd, win32con.WM_LBUTTONUP, None, None) return
def send_to_r(cmd): rid = win32gui.FindWindow("Rgui", None) if not rid: rid = win32gui.FindWindow("Rgui Workspace", None) if rid: clipboard.set_clipboard(cmd + "\n") mid = win32gui.GetMenu(rid) buf, extras = win32gui_struct.EmptyMENUITEMINFO() win32gui.GetMenuItemInfo(mid, 1, True, buf) eid = win32gui_struct.UnpackMENUITEMINFO(buf).hSubMenu buf, extras = win32gui_struct.EmptyMENUITEMINFO() win32gui.GetMenuItemInfo(eid, 1, True, buf) pid = win32gui_struct.UnpackMENUITEMINFO(buf).wID win32api.PostMessage(rid, win32con.WM_SETFOCUS, pid, 0) sublime.set_timeout( lambda: win32api.PostMessage(rid, win32con.WM_COMMAND, pid, 0), 50) clipboard.reset_clipboard()
def write(self, msg): """ write sends a message to the rfoil window and then waits for rfoil to be idle (cpu usage = 0) for a certain amount of time. """ msg = str(msg) + '\n' for c in msg: win32api.PostMessage(self.handle['rfoil01Graphic'], win32con.WM_CHAR, ord(c), 0) self.waitready()
def send_to_rstudio(cmd): rid = win32gui.FindWindow("Qt5QWindowIcon", "RStudio") if rid: clipboard.set_clipboard(cmd) time.sleep(0.01) win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0) win32api.PostMessage(rid, win32con.WM_KEYDOWN, ord("V"), 0) time.sleep(0.2) control_was_released = win32api.GetAsyncKeyState(win32con.VK_CONTROL) >= 0 win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0) win32api.PostMessage(rid, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) time.sleep(0.001) if not control_was_released: win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0) clipboard.reset_clipboard()
def SearchImageAndInputPassword(self, _Tname, _Mname, _Gsql): self.CaptureOne(_Mname) if self.SearchImage(_Tname, _Mname) == False: time.sleep(1.0) return False time.sleep(1.0) # 第1次口令 self.send_input_hax(_Gsql._gmail._password) time.sleep(1.0) #time.sleep(0.5) #win32api.PostMessage(self._hwndMain, win32con.WM_KEYDOWN, win32con.VK_NEXT, 0) #time.sleep(0.5) #win32api.PostMessage(self._hwndMain, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) #time.sleep(0.5) win32api.PostMessage(self._hwndMain, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) time.sleep(0.1) win32api.PostMessage(self._hwndMain, win32con.WM_KEYUP, win32con.VK_RETURN, 0) time.sleep(0.5) # 第2次口令 if self.ImgLeftClick('gmail_input_password_12', _Mname) == True: time.sleep(1.0) self.send_input_hax(_Gsql._gmail._password) time.sleep(2.0) # 按下 Next if self.ImgLeftClick('gmail_input_name_next_1', _Mname) == True: time.sleep(1.0) #print('已点击 Next.') print('input pass: ', _Gsql._gmail._password.lower()) return True
def OnTaskbarNotify( self, hwnd, msg, wparam, lparam, ): if lparam == win32con.WM_LBUTTONUP: pass elif lparam == win32con.WM_LBUTTONDBLCLK: pass elif lparam == win32con.WM_RBUTTONUP: menu = win32gui.CreatePopupMenu() win32gui.AppendMenu(menu, win32con.MF_STRING, 1023, 'Toggle Display') win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, '') if self.serverState == self.EnumServerState.STOPPED: win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, 'Start Server') win32gui.AppendMenu(menu, win32con.MF_STRING | win32con.MF_GRAYED, 1025, 'Restart Server') win32gui.AppendMenu(menu, win32con.MF_STRING | win32con.MF_GRAYED, 1026, 'Stop Server') else: win32gui.AppendMenu(menu, win32con.MF_STRING | win32con.MF_GRAYED, 1024, 'Start Server') win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, 'Restart Server') win32gui.AppendMenu(menu, win32con.MF_STRING, 1026, 'Stop Server') win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, '') win32gui.AppendMenu(menu, win32con.MF_STRING, 1027, 'Quit (pid:%i)' % os.getpid()) pos = win32gui.GetCursorPos() # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp win32gui.SetForegroundWindow(self.hwnd) win32gui.TrackPopupMenu( menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None, ) win32api.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0) return 1
def active_window(hwnd): print "--------------- 激活窗口: ", hwnd win32gui.SetForegroundWindow(hwnd) win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL) win32api.PostMessage(hwnd, win32con.WM_MOUSEMOVE, 0, win32api.MAKELONG(39, 61)) time.sleep(1) # win32api.PostMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, win32api.MAKELONG(39, 61)) # win32api.PostMessage(hwnd, win32con.WM_LBUTTONUP, 0, win32api.MAKELONG(39, 61)) # win32gui.SendMessage(hwnd, win32con.WM_SETTEXT, 0, u"我真实日了够了哟".encode("gbk")) for num in range(1, 1000): mySendMessage(hwnd, "this is a test message! " + str(num)) time.sleep(0.1)
def click_position(hwd, x_position, y_position): """ 鼠标左键点击指定坐标 :param hwd: :param x_position: :param y_position: :param sleep: :return: """ # 将两个16位的值连接成一个32位的地址坐标 long_position = win32api.MAKELONG(x_position, y_position) # long_position = 0x000D09D0 # win32api.SendMessage(hwnd, win32con.MOUSEEVENTF_LEFTDOWN, win32con.MOUSEEVENTF_LEFTUP, long_position) # print("点击位置为:" + str(long_position)) # win32gui.PostMessage(hwd, win32con.WM_ACTIVATE, win32con.WA_ACTIVE, 0) # 点击左键 win32api.PostMessage(hwd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, long_position) win32api.PostMessage(hwd, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON, long_position) time.sleep(0.1)
def stop(self, hwnd): """ @param hwnd 終了メッセージの送信先ウィンドウハンドル """ self._can_running = False # PostQuitMessage だと他スレッドからの実行時に終了できない. # そのため, あえて hwnd を明示的に指定できる PostMessage を使用. #win32api.PostQuitMessage(0) win32api.PostMessage( hwnd, win32con.WM_QUIT )
def __send_msg(self, stock_code, price, lot): # 使用 windows 消息机制 登录 win32gui.SendMessage(self.__edit_set["code"], win32con.WM_SETTEXT, None, stock_code) # WM_SETTEXT 不管用,使用 WM_CHAR 消息,先删除原来的内容 text = get_item_text(self.__edit_set["price"]) if text: for i in range(0, len(text)): win32api.PostMessage(self.__edit_set["price"], win32con.WM_CHAR, win32con.VK_BACK, 0) content = str(price) for char in list(content): win32api.PostMessage(self.__edit_set["price"], win32con.WM_CHAR, ord(char), 0) win32api.SendMessage(self.__edit_set["lot"], win32con.WM_SETTEXT, None, str(lot * 100)) win32api.PostMessage(self.__edit_set["buy_btn"], win32con.WM_LBUTTONDOWN, None, None) win32api.PostMessage(self.__edit_set["buy_btn"], win32con.WM_LBUTTONUP, None, None)
def post_message(self, message, wparam, lparam): """Posts Windows message to the window. Args: message: a defined Windows message. wparam: parameter of the message. lparam: parameter of the message. Returns: Self. """ hwnd = self.get_hwnd() win32api.PostMessage(hwnd, message, wparam, lparam) return self
def zbRedo(): hwnd = win32gui.FindWindowEx(0, 0, 0, 'ZBrush') win32api.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0) # win32api.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_SHIFT, 0) # win32api.PostMessage(hwnd, win32con.WM_KEYDOWN, 90, 0) # win32api.PostMessage(hwnd, win32con.WM_KEYUP, 90, 0) win32api.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_SHIFT, 0) win32api.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
def main(): # proc = subprocess.Popen("C:\\Program Files (x86)\\Leap Motion\\Core Services\\VisualizerApp.exe", stdin=subprocess.PIPE, stderr=subprocess.STDOUT) # time.sleep(1) # try: # proc.stdin.write(b'f') # except: # print("Killing") # proc.kill() _, cmd = win32api.FindExecutable('"C:\\Program Files (x86)\\Leap Motion\\Core Services\\VisualizerApp.exe"') time.sleep(1) _, _, pid, tid = win32process.CreateProcess( None, # name cmd, # command line None, # process attributes None, # thread attributes 0, # inheritance flag 0, # creation flag None, # new environment None, # current directory win32process.STARTUPINFO ()) def wcallb(hwnd, handle): handle[win32gui.GetClassName(hwnd)] = hwnd win32gui.EnumChildWindows(hwnd, wcallb, handle) return True handle = {} while not handle: # loop until the window is loaded time.sleep(0.5) win32gui.EnumThreadWindows(tid, wcallb, handle) win32api.PostMessage( handle['FREEGLUT'], win32con.WM_CHAR, ord("f"), 0) # Create a sample listener and controller listener = SampleListener() controller = Leap.Controller() listener.add_handle(handle) # Have the sample listener receive events from the controller controller.add_listener(listener) # Keep this process running until Enter is pressed print("Press Enter to quit...") sys.stdout.flush() try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener)
def SearchImageAndInputName(self, _Tname, _Mname, _Gsql): self.CaptureOne(_Mname) if self.SearchImage(_Tname, _Mname) == False: time.sleep(1.0) return False time.sleep(0.2) # 输入 first name self.send_input_hax(_Gsql._gmail._first_name) time.sleep(1.0) #time.sleep(0.5) #win32api.PostMessage(self._hwndMain, win32con.WM_KEYDOWN, win32con.VK_NEXT, 0) #time.sleep(0.5) win32api.PostMessage(self._hwndMain, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) time.sleep(0.1) win32api.PostMessage(self._hwndMain, win32con.WM_KEYUP, win32con.VK_RETURN, 0) time.sleep(1.0) # 查找 last name pic if self.ImgLeftClick('gmail_input_last_name', _Mname) == True: # self.winRightClick(self._hwndMain, self.imgx, self.imgy) time.sleep(1.0) self.send_input_hax(_Gsql._gmail._last_name) time.sleep(1.5) # 按下 Next if self.ImgLeftClick('gmail_input_name_next_1', _Mname) == True: time.sleep(1.0) #print('已点击 Next.') return True
def send_to_r(cmd): rid = win32gui.FindWindow("Rgui Workspace", None) if rid: # mdi win32gui.EnumChildWindows(rid, child_window_callback, None) else: # sdi rid = win32gui.FindWindow("Rgui", "R Console (64-bit)") if not rid: rid = win32gui.FindWindow("Rgui", "R Console (32-bit)") if rid: win32gui.BringWindowToTop(rid) if rid: clipboard.set_clipboard(cmd + "\n") menuitems = win32gui.GetMenu(rid) buf, extras = win32gui_struct.EmptyMENUITEMINFO() win32gui.GetMenuItemInfo(menuitems, 0, True, buf) if win32gui_struct.UnpackMENUITEMINFO(buf).text == "": editid = 2 else: editid = 1 buf, extras = win32gui_struct.EmptyMENUITEMINFO() win32gui.GetMenuItemInfo(menuitems, editid, True, buf) editmenu = win32gui_struct.UnpackMENUITEMINFO(buf).hSubMenu buf, extras = win32gui_struct.EmptyMENUITEMINFO() win32gui.GetMenuItemInfo(editmenu, 1, True, buf) pasteid = win32gui_struct.UnpackMENUITEMINFO(buf).wID win32api.PostMessage(rid, win32con.WM_SETFOCUS, pasteid, 0) sublime.set_timeout( lambda: win32api.PostMessage(rid, win32con.WM_COMMAND, pasteid, 0), 50) clipboard.reset_clipboard()
def OpenRemote(num): # Control SocksCap64 hWnd = findwindw('SocksCap64_WND_Class_150213', None) c_hWnd = findwindwEx(hWnd, 0, 'Static', 'About SocksCap64') # win32gui.PostMessage(c_hWnd, win32con.BM_CLICK) Rect = win32gui.GetWindowRect(c_hWnd) print(Rect) # set front win32gui.ShowWindow(hWnd, win32con.SW_SHOWNA) KeyBoard(win32con.VK_DOWN) win32gui.SetForegroundWindow(hWnd) # Open remote # win32gui.PostMessage(c_hWnd,win32con.BM_CLICK) # KeyBoard(win32con.VK_LEFT) # KeyBoard(win32con.VK_RETURN) Click(Rect[0] + 20, Rect[1] + 20) KeyBoard(13) time.sleep(5) # select ip open and input password # select hWnd = findwindw('#32770', '远程桌面连接') c_hWnd = findwindwEx(hWnd, None, 'Button', '连接(&N)') com_hWnd = win32gui.FindWindowEx(hWnd, 0, 'ComboBoxEx32', None) com2_hWnd = win32gui.FindWindowEx(com_hWnd, 0, 'ComboBox', None) e_hWnd = win32gui.FindWindowEx(com2_hWnd, 0, 'Edit', None) # 设置文本框内容,等窗口处理完毕后返回true。中文需编码成gbk # 参数:句柄;消息类型;参数WParam,无需使用; 参数IParam,要设置的内容,字符串 win32api.SendMessage(e_hWnd, win32con.WM_SETTEXT, 0, str_ip[num]) print('Selected index is ', str_ip[num]) # open win32api.PostMessage(c_hWnd, win32con.BM_CLICK) hwd = findwindw('TscShellContainerClass', str_na[num]) win32gui.ShowWindow(hwd, win32con.SW_SHOWMAXIMIZED) KeyBoard(win32con.VK_DOWN) win32gui.SetForegroundWindow(hwd) # set Xvnc y_xorg = 575 Click(1075, y_xorg) Click(908, y_xorg + 40) # set password Click(905, 627) time.sleep(0.5) KeyStr('chencheng123123') KeyBoard(13) #Enter
def ConvertLast(c_word): '''Converts last inputted text''' w3a.PostMessage(w3g.GetForegroundWindow(), 0x50, lcs.GetNotCurrentLocale()) global self self = True for x in range(len(c_word)): MakeInput(True, False, VK_BACK) for x in range(len(c_word)): print(str(c_word[x].VKCode) + '/' + str(c_word[x].Upper)) if c_word[x].Upper: MakeInput(False, True, c_word[x].VKCode) else: MakeInput(False, False, c_word[x].VKCode) self = False
def __close_with_key(self, pid): main_hwnd = self.__find_window(pid, ['Site Admin Private Key']) self.__choose_button(main_hwnd, ['Browse']) time.sleep(.42) location_hwnd = self.__find_window(pid, ['Site Admin Signing Key']) combo_hwnd = win32gui.FindWindowEx(location_hwnd, 0, 'ComboBoxEx32', '') win32api.SendMessage(combo_hwnd, win32con.WM_SETTEXT, 0, self.__location) win32api.PostMessage(combo_hwnd, win32con.WM_SETFOCUS, 0, 0) win32api.PostMessage(combo_hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) self.__choose_button(main_hwnd, ['OK']) time.sleep(.42) password_hwnd = self.__find_window(pid, ['Site Admin Private Key Password']) edit_hwnd = win32gui.FindWindowEx(password_hwnd, 0, 'Edit', '') win32api.SendMessage(edit_hwnd, win32con.WM_SETTEXT, 0, self.__password) self.__choose_button(password_hwnd, ['OK'])
def __get_handles(self): Main = win32gui.FindWindow(0, self.Title) # HT交易窗口 Frame = win32gui.GetDlgItem(Main, 59648) # 操作窗口框架 Afxwnd = win32gui.GetDlgItem(Frame, 59648) # 操作窗口框架 Hexin = win32gui.GetDlgItem(Afxwnd, 129) Scrolwnd = win32gui.GetDlgItem(Hexin, 200) # 左部折叠菜单控件 treev = win32gui.GetDlgItem(Scrolwnd, 129) # 左部折叠菜单控件 # 获取委托窗口所有控件句柄 win32api.PostMessage(treev, win32con.WM_KEYDOWN, win32con.VK_F1, 0) time.sleep(0.1) F_Bentrust = win32gui.GetDlgItem(Frame, 59649) # 委托窗口框架 self.E_Bsymbol = win32gui.GetDlgItem(F_Bentrust, 1032) # 买入代码输入框 self.E_Bprice = win32gui.GetDlgItem(F_Bentrust, 1033) # 买入价格输入框 self.E_Bvol = win32gui.GetDlgItem(F_Bentrust, 1034) # 买入数量输入框 self.B_Buy = win32gui.GetDlgItem(F_Bentrust, 1006) # 买入确认按钮 self.B_refresh = win32gui.GetDlgItem(F_Bentrust, 32790) # 刷新持仓按钮 F_Bhexin = win32gui.GetDlgItem(F_Bentrust, 1047) # 持仓显示框架 F_Bhexinsub = win32gui.GetDlgItem(F_Bhexin, 200) # 持仓显示框架 self.G_position = win32gui.GetDlgItem(F_Bhexinsub, 1047) # 持仓列表 win32api.PostMessage(treev, win32con.WM_KEYDOWN, win32con.VK_F2, 0) time.sleep(0.1) F_Sentrust = win32gui.GetDlgItem(Frame, 59649) # 委托窗口框架 self.E_Ssymbol = win32gui.GetDlgItem(F_Sentrust, 1032) # 卖出代码输入框 self.E_Sprice = win32gui.GetDlgItem(F_Sentrust, 1033) #卖出价格输入框 self.E_Svol = win32gui.GetDlgItem(F_Sentrust, 1034) # 卖出数量输入框 self.B_Sell = win32gui.GetDlgItem(F_Sentrust, 1006) # 卖出确认按钮 #撤单窗口 win32api.PostMessage(treev, win32con.WM_KEYDOWN, win32con.VK_F3, 0) time.sleep(0.1) F_Centrust = win32gui.GetDlgItem(Frame, 59649) # 撤单窗口框架 self.E_Csymbol = win32gui.GetDlgItem(F_Centrust, 3348) # 卖出代码输入框 self.B_Csort = win32gui.GetDlgItem(F_Centrust, 3349) # 查询代码按钮 self.B_Cbuy = win32gui.GetDlgItem(F_Centrust, 30002) # 撤买 self.B_Csell = win32gui.GetDlgItem(F_Centrust, 30003) # 撤卖 F_Chexin = win32gui.GetDlgItem(F_Centrust, 1047) F_Chexinsub = win32gui.GetDlgItem(F_Chexin, 200) self.G_entrust = win32gui.GetDlgItem(F_Chexinsub, 1047) # 委托列表
def RClearConsolePy(): global RConsole global Rterm if Rterm: return if RConsole == 0: FindRConsole() if RConsole: win32api.keybd_event(0x11, 0, 0, 0) try: win32api.PostMessage(RConsole, 0x100, 0x4C, 0x002F0001) except: vim.command("call RWarningMsg('R Console window not found [1].')") RConsole = 0 pass if RConsole: time.sleep(0.05) try: win32api.PostMessage(RConsole, 0x101, 0x4C, 0xC02F0001) except: vim.command( "call RWarningMsg('R Console window not found [2].')") pass win32api.keybd_event(0x11, 0, 2, 0)
def OnInitDialog(self, event): if self._scroll_down: # to scroll richedit down correctly we need to use EM_SCROLLCARET, # wxWidgets SetInsertionPoint and ShowPosition fail on win9x if sys.platform.startswith('win'): import win32api, win32con win32api.PostMessage(self.textCtrl.GetHandle(), win32con.EM_SCROLLCARET, 0, 0) else: self.textCtrl.SetInsertionPointEnd() self.textCtrl.ShowPosition(self.textCtrl.GetLastPosition()) else: self.textCtrl.SetInsertionPoint(0) self.textCtrl.ShowPosition(0) event.Skip()
def on_atp_run_clicked(self): """ 运行按钮 :return: """ print('on_atp_run_clicked') # 先更新atp # 更新路径,对比不一致项 self.on_atp_update_clicked() # 修改配置文件 AtpBat.setAtpConf('1') time.sleep(1) # 发送F2键 win32api.PostMessage(self.handle_atpdraw, win32con.WM_KEYDOWN, win32con.VK_F2, 0)