Python win32gui 模块,PostMessage() 实例源码

我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用win32gui.PostMessage()

项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def show_menu(self):
        menu = win32gui.CreatePopupMenu()
        self.create_menu(menu, self.menu_options)
        # win32gui.SetMenuDefaultItem(menu, 1000, 0)

        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)
        win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Free_quotation():
    time.sleep(3)
    try:
        Tab_handle = win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????V7.35'),None,'SysTabControl32','Tab1')
        #print(hex(Tab_handle))
        #time.sleep(1)
        p=win32gui.GetWindowRect(Tab_handle)
        #print(p)
        #print(p[2])
        #print(p[3])
        win32api.SetCursorPos([p[0]+170,p[1]+7])
        time.sleep(1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
        time.sleep(1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
        time.sleep(1)
        win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????V7.35'),None,'Button','??'),win32con.BM_CLICK,0,0)
        time.sleep(3)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))

#?????
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam == win32con.WM_LBUTTONUP:
            print "You clicked me."
        elif lparam == win32con.WM_LBUTTONDBLCLK:
            print "You double-clicked me - goodbye"
            win32gui.DestroyWindow(self.hwnd)
        elif lparam == win32con.WM_RBUTTONUP:
            print "You right clicked me."
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1023, gbk("????"))
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1024, gbk("????"))
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1025, gbk("????"))
            win32gui.AppendMenu(menu, win32con.MF_STRING, 1026, gbk("????"))
            pos = win32gui.GetCursorPos()
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Save():
    try:
        win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???'),None,'Button','??(&S)'),win32con.BM_CLICK,0,0)
        time.sleep(1)
        global handle
        handle = None
        win32gui.EnumChildWindows(win32gui.FindWindow('#32770','?????'),handle_window,'?(&Y)')
        if handle!= None:
            win32gui.PostMessage(handle,win32con.BM_CLICK,0,0)
        time.sleep(3)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
项目:QiniuSync    作者:beyondskyway    | 项目源码 | 文件源码
def show_menu(self):
        menu = win32gui.CreatePopupMenu()
        self.create_menu(menu, self.menu_options)
        #win32gui.SetMenuDefaultItem(menu, 1000, 0)

        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)
        win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam==win32con.WM_LBUTTONUP:
            print "You clicked me."
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print "You double-clicked me - goodbye"
            win32gui.DestroyWindow(self.hwnd)
        elif lparam==win32con.WM_RBUTTONUP:
            print "You right clicked me."
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
            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)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == IDC_BUTTON_SEARCH:
            self.ClearListItems()
            def fill_slowly(q, hwnd):
                import time
                for i in range(20):
                    q.put(("whatever", str(i+1), "Search result " + str(i) ))
                    win32gui.PostMessage(hwnd, WM_SEARCH_RESULT, 0, 0)
                    time.sleep(.25)
                win32gui.PostMessage(hwnd, WM_SEARCH_FINISHED, 0, 0)

            import threading
            self.result_queue = Queue.Queue()
            thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
            thread.start()
        elif id == IDC_BUTTON_DISPLAY:
            print "Display button selected"
            sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
            print "The selected item is", sel+1

    # These function differ based on how the window is used, so may be overridden
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam==win32con.WM_LBUTTONUP:
            print("You clicked me.")
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print("You double-clicked me - goodbye")
            win32gui.DestroyWindow(self.hwnd)
        elif lparam==win32con.WM_RBUTTONUP:
            print("You right clicked me.")
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
            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)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnCommand(self, hwnd, msg, wparam, lparam):
        id = win32api.LOWORD(wparam)
        if id == IDC_BUTTON_SEARCH:
            self.ClearListItems()
            def fill_slowly(q, hwnd):
                import time
                for i in range(20):
                    q.put(("whatever", str(i+1), "Search result " + str(i) ))
                    win32gui.PostMessage(hwnd, WM_SEARCH_RESULT, 0, 0)
                    time.sleep(.25)
                win32gui.PostMessage(hwnd, WM_SEARCH_FINISHED, 0, 0)

            import threading
            self.result_queue = queue.Queue()
            thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
            thread.start()
        elif id == IDC_BUTTON_DISPLAY:
            print("Display button selected")
            sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
            print("The selected item is", sel+1)

    # These function differ based on how the window is used, so may be overridden
项目:KivySystemTrayApp    作者:twister077    | 项目源码 | 文件源码
def _show_menu(self):
        self.FIRST_ID = 1023
        self.menu_options = (('Show', None, self.onShow),('Run', None, self.onRun),('Quit', None, self.onQuit))
        self._next_action_id = self.FIRST_ID
        self.menu_actions_by_id = set()
        self.menu_options = self._add_ids_to_menu_options(list(self.menu_options))
        self.menu_actions_by_id = dict(self.menu_actions_by_id)
        del self._next_action_id
        menu = win32gui.CreatePopupMenu()
        self.create_menu(menu, self.menu_options)

        pos = win32gui.GetCursorPos()
        win32gui.SetForegroundWindow(self.hwnd)
        win32gui.TrackPopupMenu(menu,
                                win32con.TPM_LEFTALIGN,
                                pos[0],
                                pos[1],
                                0,
                                self.hwnd,
                                None)
        win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Export_plate():
    try:
        win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????'),None,'#32770','???????'),None,'Button','????'),win32con.BM_CLICK,0,0)
        time.sleep(1)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))

#???
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def IsOK():
    try:
        #??
        win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','TdxW'),None,'Button','??'),win32con.BM_CLICK,0,0)
        time.sleep(1)
        #?????????
        win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????'),None,'Button','??'),win32con.BM_CLICK,0,0)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))

#???????
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Info():
    try:
        win32gui.PostMessage(win32gui.FindWindow('#32770','?????'),win32con.WM_CLOSE,0,0)
        time.sleep(5)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#???? Ctrl+T
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def EXE():
    try:
        while win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'Static','????. ') == 0:
            zs = win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'Button','????')
            print(zs)
            print(type(zs))
            win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'Button','????'),win32con.BM_CLICK,0,0)
            time.sleep(7)
            print("????")
            break
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#???
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Complement_data():
    try:
        time.sleep(3)
        if win32gui.FindWindowEx(win32gui.FindWindow('#32770','TdxW'),None,'Button','?(&Y)') != 0:
            win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','TdxW'),None,'Button','?(&Y)'),win32con.BM_CLICK,0,0)
            time.sleep(5)
            print("???")
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#?????
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Close_Stockpickingmachine():
    time.sleep(5)
    try:
        #while win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'Static','????. ') == 0:
            print("????")
            time.sleep(1)
            #if win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'Static','????. ') != 0:
            win32gui.PostMessage(win32gui.FindWindow('#32770','????'),win32con.WM_CLOSE,0,0)
            time.sleep(3)
            print("????")
                #break
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
项目:tdx    作者:sqltxt    | 项目源码 | 文件源码
def Close_TDX():
    try:
        time.sleep(3)
        lstj=win32gui.FindWindow('TdxW_MainFrame_Class','???????V7.35 - [???-?????]')
        print(hex(lstj))
        win32gui.PostMessage(lstj,win32con.WM_CLOSE,0,0)
        time.sleep(3)
        win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'Button','??'),win32con.BM_CLICK,0,0)
        time.sleep(3)
    except Exception as e:
        ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __close__(self, hwnd, dummy):
        """
        EnumWindows callback - sends WM_CLOSE to any window
        owned by this process.
        """
        TId, PId = win32process.GetWindowThreadProcessId(hwnd)
        if PId == self.PId:
            win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_SendTextWithAt(str):
    os.system(qq_shortcut)

    try_time = 0
    while True:
        time.sleep(0.5)
        hwnd = win32gui.FindWindow(None, '??&??')
        # hwnd = win32gui.FindWindow(None, 'OSVT?O?')
        print('try_time = %d, hwnd = %d' % (try_time, hwnd))
        if hwnd != 0:
            break
        elif try_time >= 60:
            print ('SendTextToQQ Error.')
            return
        else:
            try_time = try_time + 1

    win32gui.SetForegroundWindow(hwnd)

    QQ_PrintTextWithAt(str)
    QQ_Enter()

    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('v'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('v'), 0)


    #win32gui.SendMessage(hwnd, win32con.WM_SETTEXT, None, 'aaa')
    #win32gui.SetWindowText(hwnd, 'aaa')
    #win32gui.ReplaceSel()
    #win32gui.PostMessage(hwnd, win32con.WM_CHAR, '', 3)

    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('V'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('V'), 0)
    # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __close__(self, hwnd, dummy):
        """
        EnumWindows callback - sends WM_CLOSE to any window
        owned by this process.
        """
        TId, PId = win32process.GetWindowThreadProcessId(hwnd)
        if PId == self.PId:
            win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
项目:pyty    作者:howardjohn    | 项目源码 | 文件源码
def close_window(hwnd):
    """
    Sends a message to close the given window.

    Args:
        hwnd (int): The window handler.
    """
    wg.PostMessage(hwnd, wc.WM_CLOSE, 0, 0)
项目:fame_modules    作者:certsocietegenerale    | 项目源码 | 文件源码
def foreach_window(self):
        def callback(hwnd, lparam):
            title = win32gui.GetWindowText(hwnd).lower()

            for window in self.to_close:
                if window in title:
                    win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    print "Closed window ({})".format(title)

            for window in self.clicks:
                if window in title:
                    self._windows[hwnd] = {
                        "matches": self.clicks[window],
                        "to_click": [],
                        "buttons": []
                    }
                    try:
                        win32gui.EnumChildWindows(hwnd, self.foreach_child(), hwnd)
                    except:
                        print "EnumChildWindows failed, moving on."

                    for button_toclick in self._windows[hwnd]['to_click']:
                        for button in self._windows[hwnd]['buttons']:
                            if button_toclick in button['text']:
                                win32gui.SetForegroundWindow(button['handle'])
                                win32gui.SendMessage(button['handle'], win32con.BM_CLICK, 0, 0)
                                print "Clicked on button ({} / {})".format(title, button['text'])

                    del self._windows[hwnd]

            return True

        return callback
项目:pyAutoTrading    作者:drongh    | 项目源码 | 文件源码
def click(hwnd):
    """
    ????????
    :param hwnd: ???????????
    :return:
    """
    win32gui.PostMessage(hwnd, win32con.WM_LBUTTONDOWN, None, None)
    time.sleep(0.2)
    win32gui.PostMessage(hwnd, win32con.WM_LBUTTONUP, None, None)
    time.sleep(0.2)
项目:pyAutoTrading    作者:drongh    | 项目源码 | 文件源码
def sendKeyMsg(hwnd, key_code):
    """
    ????
    :param hwnd: ????
    :param key_code: ?????win32con????win32con.VK_F1
    :return:
    """
    win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, key_code, 0)  # ????
    time.sleep(0.2)
    win32gui.PostMessage(hwnd, win32con.WM_KEYUP, key_code, 0)
    time.sleep(0.2)
项目:InstaGoogling    作者:Ivanca    | 项目源码 | 文件源码
def run(self, edit):
        setSettingIsOpen(False)
        try:
            global windowsWindow
            if windowsWindow:
                win32gui.PostMessage(windowsWindow, win32con.WM_CLOSE, 0, 0)
                windowsWindow = None
        except Exception as e:
            pass
项目:KeyCounter    作者:Microcore    | 项目源码 | 文件源码
def show_menu(self):
        if self.MENU is None:
            self.create_menu()
        position = win32gui.GetCursorPos()
        win32gui.SetForegroundWindow(self.HWND)
        win32gui.TrackPopupMenu(
            self.MENU,
            win32con.TPM_LEFTALIGN,
            position[0],
            position[1],
            0,
            self.HWND,
            None
        )
        win32gui.PostMessage(self.HWND, win32con.WM_NULL, None, None)
项目:KeyCounter    作者:Microcore    | 项目源码 | 文件源码
def stop(self):
        if getattr(self, 'hook', None) is not None:
            del self.hook
        if self.HWND is not None:
            win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, (self.HWND, 0))
            # win32gui.PostMessage(self.HWND, win32con.WM_CLOSE, 0, 0)
            win32gui.DestroyWindow(self.HWND)
            self.HWND = None
        self.clear_instance_check_event()

        super(KeyCounter, self).stop()
        raise SystemExit(0)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def init_PDF(self):
        try:
            hwnd1 = win32gui.FindWindow(PDF_CLASS,None)
        except:
            log_public(ERR_NO_0003)            
            self.m_ERROR_MSG = ERR_NO_0003
            hwnd1 = 0
            print 'hwnd1:',hwnd1

        while hwnd1 != 0:
            #close PDF window    
            time.sleep(2)
            win32gui.PostMessage(hwnd1, win32con.WM_SYSCOMMAND, win32con.SC_CLOSE, 0);
            print 'close_PDF'
            try:
                hwnd1 = win32gui.FindWindow(PDF_CLASS,None)
                print 'new hwnd1---',hwnd1
            except:
                log_public(ERR_NO_0004)            
                self.m_ERROR_MSG = ERR_NO_0004
                hwnd1 = 0
            print 'new hwnd1:',hwnd1
        else:
            print 'hwnd1=0,init_PDF has been done'
        return True

    #-----------------------------------------------------------------------------
    # Name:         open_waveQoE
    # purpose:      open waveQoE.
    # explain:     
    # Author:       gongke
    #
    # Created:      2013/05/20
    #-----------------------------------------------------------------------------
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def _postNotifyMessage(hwnd, nofifyMessage):
    '''Send a notify message to a control.'''
    win32gui.PostMessage(win32gui.GetParent(hwnd),
                         win32con.WM_COMMAND,
                         _buildWinLong(nofifyMessage,
                                       win32api.GetWindowLong(hwnd,
                                                              win32con.GWL_ID)),
                         hwnd)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Find_Gui_key_run(self,str_app='´ò¿ª'):
        time.sleep(1)
        print "*********Find_Gui_button function**********"
        #self.Mousepos_print()
        print 'control_name:',str_app
        hwnd = win32gui.FindWindow(None, str_app)
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)
        print 'hwnd :',hwnd,str_app
        win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_F5, 0)
        return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Find_Gui_title(self,str_app='Edit Action',find_control_class='0',control_class='WindowsForms10.Window.8.app.0.2e0c681',text='10',control_name=''):
        time.sleep(1)
        print "*********Find_Gui_title function**********"
        #self.Mousepos_print()
        print 'control_name:',str_app,find_control_class
        hwnd = win32gui.FindWindow(None, str_app)
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)
        print 'hwnd :',hwnd,str_app
        win32gui.SetForegroundWindow(hwnd)
        comboHwnd = win32gui.FindWindowEx(hwnd,0,control_class,None)
        print 'comboHwnd',comboHwnd
        while comboHwnd:
            cla =  win32gui.GetClassName(comboHwnd)
            print "control_class_name:",cla
            bufLen=1024
            buf =win32gui.PyMakeBuffer(bufLen)
            n = win32gui.SendMessage(comboHwnd,win32con.WM_GETTEXT,bufLen,buf)
            str = buf[:n]
            print 'buf:',str
            if str.find(find_control_class)>-1:
                win32gui.PostMessage(comboHwnd,win32con.WM_LBUTTONDOWN,0)
                time.sleep(0.05)
                #win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONUP,0)
                win32gui.PostMessage(comboHwnd,win32con.WM_LBUTTONUP,0)
                time.sleep(0.05)
                time.sleep(1)
                break
            comboHwnd = win32gui.GetWindow(comboHwnd,win32con.GW_HWNDNEXT)
        return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Find_Gui_button_hwnd(self,str_app='´ò¿ª',control_class='Button',control_name='´ò¿ª(&O)'):
        time.sleep(1)
        result = False
        print "*********Find_Gui_button function**********"
        #self.Mousepos_print()
        #print 'control_name:',str_app,',',control_name
        hwnd = win32gui.FindWindow(None, str_app)
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)
        comboHwnd = win32gui.FindWindowEx(hwnd,0,control_class,None)
        #print 'comboHwnd',comboHwnd

        while comboHwnd:
            #print "control_class:",comboHwnd,control_name
            cla =  win32gui.GetClassName(comboHwnd)
            #print 'cla:' ,cla
            bufLen=1024
            buf =win32gui.PyMakeBuffer(bufLen)
            if control_class in cla:
                n = win32gui.SendMessage(comboHwnd,win32con.WM_GETTEXT,bufLen,buf)
                str = buf[:n]
                #print 'buttonname ,len,n,find :',str,len(control_name ),n,str.find(control_name)
                if str.find(control_name)>-1:
                    result = True
                    win32gui.PostMessage(comboHwnd,win32con.WM_LBUTTONDOWN,0)
                    time.sleep(0.05)
                    #win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONUP,0)
                    win32gui.PostMessage(comboHwnd,win32con.WM_LBUTTONUP,0)
                    time.sleep(0.05)
                    time.sleep(1)
                    print 'find control_name',result
                    break
            comboHwnd = win32gui.GetWindow(comboHwnd,win32con.GW_HWNDNEXT)
        if result ==False:
            comboHwnd = -1
        return comboHwnd
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def init_PDF(self):
        try:
            hwnd1 = win32gui.FindWindow(PDF_CLASS,None)
        except:
            log_public(ERR_NO_0003)            
            self.m_ERROR_MSG = ERR_NO_0003
            hwnd1 = 0
            print 'hwnd1:',hwnd1

        while hwnd1 != 0:
            #close PDF window    
            time.sleep(2)
            win32gui.PostMessage(hwnd1, win32con.WM_SYSCOMMAND, win32con.SC_CLOSE, 0);
            print 'close_PDF'
            try:
                hwnd1 = win32gui.FindWindow(PDF_CLASS,None)
                print 'new hwnd1---',hwnd1
            except:
                log_public(ERR_NO_0004)            
                self.m_ERROR_MSG = ERR_NO_0004
                hwnd1 = 0
            print 'new hwnd1:',hwnd1
        else:
            print 'hwnd1=0,init_PDF has been done'
        return True

    #-----------------------------------------------------------------------------
    # Name:         open_waveApps
    # purpose:      open waveApps.
    # explain:     
    # Author:       gongke
    #
    # Created:      2013/05/20
    # Amend:        2013/07/05  ---yuanwen
    #-----------------------------------------------------------------------------