當前位置: 首頁>>代碼示例>>Python>>正文


Python win32gui.GetCursorPos方法代碼示例

本文整理匯總了Python中win32gui.GetCursorPos方法的典型用法代碼示例。如果您正苦於以下問題:Python win32gui.GetCursorPos方法的具體用法?Python win32gui.GetCursorPos怎麽用?Python win32gui.GetCursorPos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32gui的用法示例。


在下文中一共展示了win32gui.GetCursorPos方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: show_menu

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
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) 
開發者ID:samclane,項目名稱:LIFX-Control-Panel,代碼行數:18,代碼來源:SysTrayIcon.py

示例2: OnTaskbarNotify

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:20,代碼來源:win32gui_taskbar.py

示例3: set_size

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def set_size(self, size, update=True):
        """Set the window size.
        :size: list or tuple: the new size.
        :mode: bool: (re)set the pygame.display mode; self.mode must be a pygame display mode object.
        Raises a TypeError if something else than a list or a tuple is sent."""
        if type(size) in (list, tuple):
            w, h = size
            cx, cy = win32gui.GetCursorPos()
            if DEBUG_WM:
                print "Settin size to", size
                print "actual size", self.get_size()
                print "actual position", self.get_position()
                
                print 'cursor pos', cx, cy
            flags, showCmd, ptMin, ptMax, rect = win32gui.GetWindowPlacement(self.base_handler_id)
            if DEBUG_WM:
                print "set_size rect", rect, "ptMin", ptMin, "ptMax", ptMax, "flags", flags
            x = rect[0]
            y = rect[1]
            rect = (x, y, x + w, y + h)
            win32gui.SetWindowPlacement(self.base_handler_id, (0, showCmd, ptMin, ptMax, rect))
        else:
            # Raise a Type error.
            raise TypeError, "%s is not a list or a tuple." % repr(size) 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:26,代碼來源:mcplatform.py

示例4: set_position

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def set_position(self, pos, update=True):
        """Set the window position.
        :pos: list or tuple: the new position (x, y)."""
        if DEBUG_WM:
            print "Setting position to", pos
        if type(pos) in (list, tuple):
            self.first_pos = False
            x, y = pos
            if update:
                flags, showCmd, ptMin, ptMax, rect = win32gui.GetWindowPlacement(self.base_handler_id)
                if DEBUG_WM:
                    print "set_position rect", rect, "ptMin", ptMin, "ptMax", ptMax
                realW = rect[2] - rect[0]
                realH = rect[3] - rect[1]
                if DEBUG_WM:
                    print 'rect[0]', rect[0], 'rect[1]', rect[1]
                    print 'realW', realW, 'realH', realH
                    print 'cursor pos', win32gui.GetCursorPos()

                rect = (x, y, x + realW, y + realH)

                win32gui.SetWindowPlacement(self.base_handler_id, (0, showCmd, ptMin, ptMax, rect))
        else:
            # Raise a Type error.
            raise TypeError, "%s is not a list or a tuple." % repr(pos) 
開發者ID:mcgreentn,項目名稱:GDMC,代碼行數:27,代碼來源:mcplatform.py

示例5: show_menu

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def show_menu(self):
        """Draw the popup menu."""
        menu = win32gui.CreatePopupMenu()
        self._create_menu(menu, self.menu_options)
        
        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)
        self.logger.debug('Menu displayed.') 
開發者ID:Peter92,項目名稱:MouseTracks,代碼行數:19,代碼來源:tray.py

示例6: _notify

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def _notify(klass, hwnd, msg, wparam, lparam):
        self = klass._instance[hwnd]
        if lparam == win32con.WM_LBUTTONDBLCLK:
            menu = self.get_popup()
            wid = win32gui.GetMenuDefaultItem(menu, 0, 0)
            if 0 < wid:
                win32gui.PostMessage(hwnd, win32con.WM_COMMAND, wid, 0)
        elif lparam == win32con.WM_RBUTTONUP:
            menu = self.get_popup()
            pos = win32gui.GetCursorPos()
            win32gui.SetForegroundWindow(hwnd)
            win32gui.TrackPopupMenu(
                menu, win32con.TPM_LEFTALIGN,
                pos[0], pos[1], 0, hwnd, None)
            win32gui.PostMessage(hwnd, win32con.WM_NULL, 0, 0)
        elif lparam == win32con.WM_LBUTTONUP:
            pass
        return True 
開發者ID:euske,項目名稱:pyrexecd,代碼行數:20,代碼來源:__init__.py

示例7: show_menu

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
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) 
開發者ID:beville,項目名稱:ComicStreamer,代碼行數:18,代碼來源:gui_win.py

示例8: _show_menu

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def _show_menu( self ):
        menu = win32gui.CreatePopupMenu()
        for action in self.menu_actions:
            if action:
                flags = win32con.MF_STRING
                if not action.sensitive:
                    flags |= win32con.MF_GRAYED
                win32gui.AppendMenu( menu, flags, action.get_id(), action.label )
            else:
                win32gui.AppendMenu( menu, win32con.MF_SEPARATOR, 0, '' )
        
        pos = win32gui.GetCursorPos()
        
        win32gui.SetForegroundWindow( self.window_handle )
        win32gui.TrackPopupMenu( menu,
                                 win32con.TPM_LEFTALIGN | win32con.TPM_BOTTOMALIGN,
                                 pos[ 0 ],
                                 pos[ 1 ],
                                 0,
                                 self.window_handle,
                                 None )
        win32gui.PostMessage( self.window_handle, win32con.WM_NULL, 0, 0 ) 
開發者ID:mailpile,項目名稱:gui-o-matic,代碼行數:24,代碼來源:winapi.py

示例9: set_size

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def set_size(self, size, update=True):
        """Set the window size.
        :size: list or tuple: the new size.
        :mode: bool: (re)set the pygame.display mode; self.mode must be a pygame display mode object.
        Raises a TypeError if something else than a list or a tuple is sent."""
        if isinstance(size, (list, tuple)):
            w, h = size
            cx, cy = win32gui.GetCursorPos()
            if DEBUG_WM:
                print "Settin size to", size
                print "actual size", self.get_size()
                print "actual position", self.get_position()
                
                print 'cursor pos', cx, cy
            flags, showCmd, ptMin, ptMax, rect = win32gui.GetWindowPlacement(self.base_handler_id)
            if DEBUG_WM:
                print "set_size rect", rect, "ptMin", ptMin, "ptMax", ptMax, "flags", flags
            x = rect[0]
            y = rect[1]
            rect = x, y, x + w, y + h
            win32gui.SetWindowPlacement(self.base_handler_id, (0, showCmd, ptMin, ptMax, rect))
        else:
            # Raise a Type error.
            raise TypeError("%s is not a list or a tuple." % repr(size)) 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:26,代碼來源:mcplatform.py

示例10: set_position

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def set_position(self, pos, update=True):
        """Set the window position.
        :pos: list or tuple: the new position (x, y)."""
        if DEBUG_WM:
            print "Setting position to", pos
        if isinstance(pos, (list, tuple)):
            self.first_pos = False
            x, y = pos
            if update:
                flags, showCmd, ptMin, ptMax, rect = win32gui.GetWindowPlacement(self.base_handler_id)
                if DEBUG_WM:
                    print "set_position rect", rect, "ptMin", ptMin, "ptMax", ptMax
                realW = rect[2] - rect[0]
                realH = rect[3] - rect[1]
                if DEBUG_WM:
                    print 'rect[0]', rect[0], 'rect[1]', rect[1]
                    print 'realW', realW, 'realH', realH
                    print 'cursor pos', win32gui.GetCursorPos()

                rect = (x, y, x + realW, y + realH)

                win32gui.SetWindowPlacement(self.base_handler_id, (0, showCmd, ptMin, ptMax, rect))
        else:
            # Raise a Type error.
            raise TypeError("%s is not a list or a tuple." % repr(pos)) 
開發者ID:Podshot,項目名稱:MCEdit-Unified,代碼行數:27,代碼來源:mcplatform.py

示例11: _input_left_mouse

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def _input_left_mouse(self, x, y):
        left, top, right, bottom = self.rect
        width, height = right - left, bottom - top
        if x < 0 or x > width or y < 0 or y > height:
            return

        win32gui.SetForegroundWindow(self.hwnd)
        pos = win32gui.GetCursorPos()
        win32api.SetCursorPos((left+x, top+y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
        win32api.Sleep(100) #ms
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
        win32api.Sleep(100) #ms
        # win32api.SetCursorPos(pos) 
開發者ID:NetEaseGame,項目名稱:ATX,代碼行數:16,代碼來源:windows.py

示例12: show_menu

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def show_menu(self):
        menu = win32gui.CreatePopupMenu()
        self.create_menu(menu)

        pos = win32gui.GetCursorPos()
        win32gui.SetForegroundWindow(self.shell.main_frame.hwnd)
        win32gui.TrackPopupMenu(menu,
                                win32con.TPM_LEFTALIGN,
                                pos[0],
                                pos[1],
                                0,
                                self.shell.main_frame.hwnd,
                                None) 
開發者ID:eavatar,項目名稱:eavatar-me,代碼行數:15,代碼來源:shell.py

示例13: icon_wndproc

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
def icon_wndproc(hwnd, msg, wp, lp):
    """ Window proc for the tray icons """
    if lp==win32con.WM_LBUTTONDOWN:
        ## popup menu won't disappear if you don't do this
        win32gui.SetForegroundWindow(hwnd)

        curr_desktop=win32service.OpenInputDesktop(0,True,win32con.MAXIMUM_ALLOWED)
        curr_desktop_name=win32service.GetUserObjectInformation(curr_desktop,win32con.UOI_NAME)
        winsta=win32service.GetProcessWindowStation()
        desktops=winsta.EnumDesktops()
        m=win32gui.CreatePopupMenu()
        desktop_cnt=len(desktops)
        ## *don't* create an item 0
        for d in range(1, desktop_cnt+1):
            mf_flags=win32con.MF_STRING
             ## if you switch to winlogon yourself, there's nothing there and you're stuck
            if desktops[d-1].lower() in ('winlogon','disconnect'):
                mf_flags=mf_flags|win32con.MF_GRAYED|win32con.MF_DISABLED
            if desktops[d-1]==curr_desktop_name:
                mf_flags=mf_flags|win32con.MF_CHECKED
            win32gui.AppendMenu(m, mf_flags, d, desktops[d-1])
        win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt+1, 'Create new ...')
        win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt+2, 'Exit')
            
        x,y=win32gui.GetCursorPos()
        d=win32gui.TrackPopupMenu(m,win32con.TPM_LEFTBUTTON|win32con.TPM_RETURNCMD|win32con.TPM_NONOTIFY,
            x,y, 0, hwnd, None)
        win32gui.PumpWaitingMessages()
        win32gui.DestroyMenu(m)
        if d==desktop_cnt+1:      ## Create new
            get_new_desktop_name(hwnd)
        elif d==desktop_cnt+2:    ## Exit
            win32gui.PostQuitMessage(0)
            win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, window_info[hwnd])
            del window_info[hwnd]
            origin_desktop.SwitchDesktop()
        elif d>0:
            hdesk=win32service.OpenDesktop(desktops[d-1],0,0,win32con.MAXIMUM_ALLOWED)
            hdesk.SwitchDesktop()
        return 0
    else:
        return win32gui.DefWindowProc(hwnd, msg, wp, lp) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:44,代碼來源:desktopmanager.py

示例14: OnTaskbarNotify

# 需要導入模塊: import win32gui [as 別名]
# 或者: from win32gui import GetCursorPos [as 別名]
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 
開發者ID:uwdata,項目名稱:termite-visualizations,代碼行數:54,代碼來源:taskbar_widget.py


注:本文中的win32gui.GetCursorPos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。