Python win32con 模块,WM_LBUTTONUP 实例源码

我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用win32con.WM_LBUTTONUP

项目:pytomatic    作者:N0K0    | 项目源码 | 文件源码
def release_button(self, coords, button = "left"):

        if "right" in button.lower():
            _button_up = win32con.WM_RBUTTONUP
        elif "left" in button.lower():
            _button_up = win32con.WM_LBUTTONUP
        elif "middle" in button.lower():
            _button_up = win32con.WM_MBUTTONUP
        else:
            raise SyntaxError('"Button" needs to contain "left", "right" or "middle"')

        if all(isinstance(elem, float) for elem in coords):
            coords = self.to_pixel(coords)
        x = coords[0]
        y = coords[1]

        l_param = win32api.MAKELONG(x, y)


        hwnd = self.win_handler.get_hwnd()
        win32api.SendMessage(hwnd, _button_up, 0, l_param)


        raise NotImplementedError
项目: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
项目: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
项目: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
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def notify(self, hwnd, msg, wparam, lparam):
        if lparam == win32con.WM_LBUTTONDBLCLK:
            self.execute_menu_option(self.default_menu_index + self.FIRST_ID)
        elif lparam == win32con.WM_RBUTTONUP:
            self.show_menu()
        elif lparam == win32con.WM_LBUTTONUP:
            pass
        return True
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def HookMessages(self):
        self.HookMessage(self.OnLButtonUp, win32con.WM_LBUTTONUP)
        self.HookMessage(self.OnLButtonDown, win32con.WM_LBUTTONDOWN)
        self.HookMessage(self.OnLButtonDblClk, win32con.WM_LBUTTONDBLCLK)
        self.HookMessage(self.OnNcLButtonDown, win32con.WM_NCLBUTTONDOWN)
        self.HookMessage(self.OnNcLButtonDblClk, win32con.WM_NCLBUTTONDBLCLK)
        self.HookMessage(self.OnMouseMove, win32con.WM_MOUSEMOVE)
        self.HookMessage(self.OnNcPaint, win32con.WM_NCPAINT)
        self.HookMessage(self.OnCaptureChanged, win32con.WM_CAPTURECHANGED)
        self.HookMessage(self.OnWindowPosChanged, win32con.WM_WINDOWPOSCHANGED)
#       self.HookMessage(self.OnSize, win32con.WM_SIZE)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def HookMessages(self):
        self.HookMessage(self.OnLButtonUp, win32con.WM_LBUTTONUP)
        self.HookMessage(self.OnLButtonDown, win32con.WM_LBUTTONDOWN)
        self.HookMessage(self.OnLButtonDblClk, win32con.WM_LBUTTONDBLCLK)
        self.HookMessage(self.OnNcLButtonDown, win32con.WM_NCLBUTTONDOWN)
        self.HookMessage(self.OnNcLButtonDblClk, win32con.WM_NCLBUTTONDBLCLK)
        self.HookMessage(self.OnMouseMove, win32con.WM_MOUSEMOVE)
        self.HookMessage(self.OnNcPaint, win32con.WM_NCPAINT)
        self.HookMessage(self.OnCaptureChanged, win32con.WM_CAPTURECHANGED)
        self.HookMessage(self.OnWindowPosChanged, win32con.WM_WINDOWPOSCHANGED)
#       self.HookMessage(self.OnSize, win32con.WM_SIZE)
项目: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)
项目:KivySystemTrayApp    作者:twister077    | 项目源码 | 文件源码
def notify(self, hwnd, msg, wparam, lparam):
        if lparam == win32con.WM_LBUTTONDBLCLK:
            self.execute_menu_option(self._default_menu_index + SysTrayIcon.FIRST_ID)
        elif lparam == win32con.WM_RBUTTONUP:
            self._show_menu()
        elif lparam == win32con.WM_LBUTTONUP:
            pass
        return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Mouse_LB_click(self,hwnd):

        win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
        win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)
        time.sleep(1)

    #-----------------------------------------------------------------------------
    # Name:         click_CurrentPlace
    # purpose:      click on the current place.
    # explain:     
    # Author:       yuanwen
    #
    # Created:      2013/07/5
    #-----------------------------------------------------------------------------
项目: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 Find_Gui_button(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)
        #print 'hwnd :',hwnd,str_app
        win32gui.SetForegroundWindow(hwnd)
        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 (len(control_name ) ==0 and n==0)  or ((len(control_name )>0 and  str.find(control_name)>-1 )):
                    #win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONDOWN,0)
                    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)
                    #win32gui.SendMessage(win32con.WM_CLOSE,0,0)
                    #print '111'
                    result = True
                    break
            comboHwnd = win32gui.GetWindow(comboHwnd,win32con.GW_HWNDNEXT)
        time.sleep(1)
        return result
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Mouse_LB_click(self,hwnd):

        win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
        win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)
        self.sleep('1')
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Mouse_LB_click(self,hwnd):

        win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
        win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)
        time.sleep(1)
项目:StuffShare    作者:StuffShare    | 项目源码 | 文件源码
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
项目:touch-pay-client    作者:HackPucBemobi    | 项目源码 | 文件源码
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
项目:true_review_web2py    作者:lucadealfaro    | 项目源码 | 文件源码
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
项目:spc    作者:whbrewer    | 项目源码 | 文件源码
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
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
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
项目:rekall-agent-server    作者:rekall-innovations    | 项目源码 | 文件源码
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
项目:slugiot-client    作者:slugiot    | 项目源码 | 文件源码
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
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Find_Gui_Tree(self,str_app='New Scenario',control_class='Button',filename='test_baidu',control_name='AfxOleControl'):

        print "*********Find_Gui_Tree function**********"
        time.sleep(1)
        #self.Mousepos_print()
        print 'str_app',str_app
        hwnd = win32gui.FindWindow(None, str_app)
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)
        print 'hwnd',hwnd
        win32gui.SetForegroundWindow(hwnd)

        print 'hwnd :',hwnd,str_app
        win32gui.SetForegroundWindow(hwnd)

        #self.Mousepos_print('5')
        comboHwnd = win32gui.FindWindowEx(hwnd,0,control_class,None)
        print '111111111111comboHwnd',comboHwnd
        while comboHwnd:
            print "control_class:",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 str
            '''
            if control_class in cla:
                n = win32gui.SendMessage(comboHwnd,win32con.WM_GETTEXT,bufLen,buf)
                str = buf[:n]
                print str
                if (len(control_name ) ==0 and n==0)  or ((len(control_name )>0 and  str.find(control_name)>-1 )):
                    win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONDOWN,0)
                    time.sleep(0.05)
                    win32gui.SendMessage(comboHwnd,win32con.WM_LBUTTONUP,0)
                    time.sleep(0.05)
                    win32gui.SendMessage(win32con.WM_CLOSE,0,0)
                    break
            '''
            comboHwnd = win32gui.GetWindow(comboHwnd,win32con.GW_HWNDNEXT)
        time.sleep(1)


        return True
项目:pytomatic    作者:N0K0    | 项目源码 | 文件源码
def click(self, coords, button="left",hold=False):
        """
        Args:
            coords (touple): coords takes two arguments, either both float
                or int. If float is supplied, it will try to treat them as
                percentages. X, Y
            button (string): either "left","right" or "middle". Decides what button that
                will be sent to the running program.

        Returns:
            bool: True if successful, False otherwise.

        Raises:
            SyntaxError: The button param does not contain "left","right og "middle"
        """

        hwnd = self.win_handler.get_hwnd()

        if all(isinstance(elem, float) for elem in coords):
            coords = self.to_pixel(coords)


        logging.debug("Trying to click on:" + str(coords) + " with " + button + " button")

        x = coords[0]
        y = coords[1]

        if "right" in button.lower():
            _button_state = win32con.MK_RBUTTON
            _button_down = win32con.WM_RBUTTONDOWN
            _button_up = win32con.WM_RBUTTONUP
        elif "left" in button.lower():
            _button_state = win32con.MK_LBUTTON
            _button_down = win32con.WM_LBUTTONDOWN
            _button_up = win32con.WM_LBUTTONUP
        elif "middle" in button.lower():
            _button_state = win32con.MK_MBUTTON
            _button_down = win32con.WM_MBUTTONDOWN
            _button_up = win32con.WM_MBUTTONUP
        else:
            raise SyntaxError('"Button" needs to contain "left", "right" or "middle"')

        l_param = win32api.MAKELONG(x, y)

        win32api.SendMessage(hwnd, win32con.WM_MOUSEMOVE,0,l_param)

        time.sleep(0.2)
        win32api.SendMessage(hwnd,_button_down, _button_state, l_param)
        time.sleep(0.1)

        if not hold: #Do not release the button if hold is true
            win32api.SendMessage(hwnd, _button_up, 0, l_param)

        self._last_x = x
        self._last_y = y
        return True
项目:pytomatic    作者:N0K0    | 项目源码 | 文件源码
def hold_and_drag(self,start,end,steps,button="left"):
        hwnd = self.win_handler.get_hwnd()

        if all(isinstance(elem, float) for elem in start):
            start = self.to_pixel(start)

        if all(isinstance(elem, float) for elem in end):
            end = self.to_pixel(end)

        step_x = (float(end[0] - start[0])) / steps
        step_y = (float(end[1] - start[1])) / steps

        if "right" in button.lower():
            _button_state = win32con.MK_RBUTTON
            _button_down = win32con.WM_RBUTTONDOWN
            _button_up = win32con.WM_RBUTTONUP
        elif "left" in button.lower():
            _button_state = win32con.MK_LBUTTON
            _button_down = win32con.WM_LBUTTONDOWN
            _button_up = win32con.WM_LBUTTONUP
        elif "middle" in button.lower():
            _button_state = win32con.MK_MBUTTON
            _button_down = win32con.WM_MBUTTONDOWN
            _button_up = win32con.WM_MBUTTONUP
        else:
            raise SyntaxError('"Button" needs to contain "left", "right" or "middle"')

        self.move(start)
        l_param = win32api.MAKELONG(start[0], start[1])

        time.sleep(0.1)
        win32api.SendMessage(hwnd,_button_down,_button_state,l_param)
        time.sleep(0.1)

        x, y = start
        for step in range(0,steps):
            x += step_x
            y += step_y
            self.move((int(x),int(y)), button=button)
            time.sleep(0.01)

        l_param = win32api.MAKELONG(int(x), int(y))
        win32api.SendMessage(hwnd,_button_up,0,l_param)
        self._last_x = x
        self._last_y = y