当前位置: 首页>>代码示例>>Python>>正文


Python win32gui.PostMessage方法代码示例

本文整理汇总了Python中win32gui.PostMessage方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.PostMessage方法的具体用法?Python win32gui.PostMessage怎么用?Python win32gui.PostMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32gui的用法示例。


在下文中一共展示了win32gui.PostMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OnCommand

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:win32gui_dialog.py

示例2: click_drag

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def click_drag(x :int, y :int, x2 :int, y2 :int) -> None:
        """Click at pixel xy."""
        x += Window.x
        y += Window.y
        x2 += Window.x
        y2 += Window.y
        lParam = win32api.MAKELONG(x, y)
        lParam2 = win32api.MAKELONG(x2, y2)
        # MOUSEMOVE event is required for game to register clicks correctly
        win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam)
        while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
               win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
               win32api.GetKeyState(wcon.VK_MENU) < 0):
            time.sleep(0.005)
        win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
                             wcon.MK_LBUTTON, lParam)
        time.sleep(userset.LONG_SLEEP * 2)
        win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam2)
        time.sleep(userset.SHORT_SLEEP)
        win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
                             wcon.MK_LBUTTON, lParam2)
        time.sleep(userset.MEDIUM_SLEEP) 
开发者ID:kujan,项目名称:NGU-scripts,代码行数:24,代码来源:inputs.py

示例3: ctrl_click

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def ctrl_click(x :int, y :int) -> None:
        """Clicks at pixel x, y while simulating the CTRL button to be down."""
        x += Window.x
        y += Window.y
        lParam = win32api.MAKELONG(x, y)
        while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
               win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
               win32api.GetKeyState(wcon.VK_MENU) < 0):
            time.sleep(0.005)

        win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, wcon.VK_CONTROL, 0)
        win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
                             wcon.MK_LBUTTON, lParam)
        win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
                             wcon.MK_LBUTTON, lParam)
        win32gui.PostMessage(Window.id, wcon.WM_KEYUP, wcon.VK_CONTROL, 0)
        time.sleep(userset.MEDIUM_SLEEP) 
开发者ID:kujan,项目名称:NGU-scripts,代码行数:19,代码来源:inputs.py

示例4: OnTaskbarNotify

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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

示例5: enumChildCallback

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumChildCallback(hwnd, windowName):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            try:

                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)

            except:
                pass
            #print sys.exc_info() 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:23,代码来源:process.py

示例6: show_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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

示例7: show_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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

示例8: enumCallback

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumCallback(hwnd, self):
            title = win32gui.GetWindowText(hwnd)

            for name in self.WindowNames:
                if title.find(name) > -1:
                    try:
                        self.FoundWindowEvent.set()

                        if self.CloseWindows:
                            win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    except:
                        pass
                else:
                    try:
                        win32gui.EnumChildWindows(hwnd, _WindowWatcher.enumChildCallback, self)
                    except:
                        pass

            return True 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:21,代码来源:gui.py

示例9: enumCallback

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumCallback(hwnd, args):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            proc = args[0]
            windowName = args[1]

            try:
                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    win32gui.EnumChildWindows(hwnd, FileWriterLauncherGui.enumChildCallback, args)
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
            except:
                pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:24,代码来源:file.py

示例10: enumChildCallback

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumChildCallback(hwnd, args):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            proc = args[0]
            windowName = args[1]

            try:

                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)

            except:
                pass
            #print sys.exc_info() 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:26,代码来源:file.py

示例11: enumCallback

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumCallback(hwnd, windowName):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            try:
                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    win32gui.EnumChildWindows(hwnd, FileWriterLauncherGui.enumChildCallback, windowName)
                    return

                # Send WM_CLOSE message
                win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
            except:
                pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:21,代码来源:process.py

示例12: _notify

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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

示例13: show_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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

示例14: _show_menu

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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

示例15: _win32gui_post

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def _win32gui_post(message, w=0, l=0):
        return lambda self: win32gui.PostMessage(self._handle, message, w, l) 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:4,代码来源:win32_window.py


注:本文中的win32gui.PostMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。