Python win32con 模块,WM_RBUTTONUP 实例源码

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

项目: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_RBUTTONUP:
            print "You right clicked me."
            # display the menu at the cursor pos.
            pos = GetCursorPos()
            SetForegroundWindow(self.hwnd)
            TrackPopupMenu(self.hmenu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print "You double-clicked me"
            # find the default menu item and fire it.
            cmd = GetMenuDefaultItem(self.hmenu, False, 0)
            if cmd == -1:
                print "Can't find a default!"
            # and just pretend it came from the menu
            self.OnCommand(hwnd, win32con.WM_COMMAND, cmd, 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_RBUTTONUP:
            print("You right clicked me.")
            # display the menu at the cursor pos.
            pos = GetCursorPos()
            SetForegroundWindow(self.hwnd)
            TrackPopupMenu(self.hmenu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print("You double-clicked me")
            # find the default menu item and fire it.
            cmd = GetMenuDefaultItem(self.hmenu, False, 0)
            if cmd == -1:
                print("Can't find a default!")
            # and just pretend it came from the menu
            self.OnCommand(hwnd, win32con.WM_COMMAND, cmd, 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 OnInitialUpdate(self):
        rc = self._obj_.OnInitialUpdate()
        self.frame = self.GetParent().GetParent()
        self.hierList = hierlist.HierListWithItems( self.GetHLIRoot(), win32ui.IDB_HIERFOLDERS, win32ui.AFX_IDW_PANE_FIRST)
        self.hierList.HierInit(self.frame, self.GetTreeCtrl())
        self.hierList.SetStyle(commctrl.TVS_HASLINES | commctrl.TVS_LINESATROOT | commctrl.TVS_HASBUTTONS)
        self.hierList.PerformItemSelected = self.PerformItemSelected

        self.frame.HookNotify(self.frame.OnItemDoubleClick, commctrl.NM_DBLCLK)
        self.frame.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK)
#       self.HookMessage(self.OnItemRightClick, win32con.WM_RBUTTONUP)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnInitialUpdate(self):
        rc = self._obj_.OnInitialUpdate()
        self.frame = self.GetParent().GetParent()
        self.hierList = hierlist.HierListWithItems( self.GetHLIRoot(), win32ui.IDB_HIERFOLDERS, win32ui.AFX_IDW_PANE_FIRST)
        self.hierList.HierInit(self.frame, self.GetTreeCtrl())
        self.hierList.SetStyle(commctrl.TVS_HASLINES | commctrl.TVS_LINESATROOT | commctrl.TVS_HASBUTTONS)
        self.hierList.PerformItemSelected = self.PerformItemSelected

        self.frame.HookNotify(self.frame.OnItemDoubleClick, commctrl.NM_DBLCLK)
        self.frame.HookNotify(self.OnItemRightClick, commctrl.NM_RCLICK)
#       self.HookMessage(self.OnItemRightClick, win32con.WM_RBUTTONUP)
项目: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
项目: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
项目: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