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


Python win32gui.SetForegroundWindow方法代码示例

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


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

示例1: OnTaskbarNotify

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

示例2: show_menu

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

示例3: find_window_movetop

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def find_window_movetop(cls):
        hwnd = win32gui.FindWindow(None, cls.processname)
        win32gui.ShowWindow(hwnd,5)
        win32gui.SetForegroundWindow(hwnd)
        rect = win32gui.GetWindowRect(hwnd)
        sleep(0.2)
        return rect 
开发者ID:Sunuba,项目名称:roc,代码行数:9,代码来源:Clicker.py

示例4: enumCallback

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

        if title.find(self.windowName) > -1:
            try:
                win32gui.SetActiveWindow(hwnd)
                win32gui.SetForegroundWindow(hwnd)

                FInputs = Input * 1
                extra = c_ulong(0)
                ii_ = Input_I()
                ii_.ki = KeyBdInput(win32con.VK_F5, 0x3f, 0, 0, pointer(extra))
                x = FInputs(( 1, ii_ ))
                windll.user32.SendInput(1, pointer(x), sizeof(x[0]))

            except:
                pass

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

示例5: bring_to_front

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def bring_to_front(self, new=True):
        """Bring a window into focus.
        Kept the old way just to be on the safe side.
        """
        if new:
            win32gui.ShowWindow(self.hwnd, True)
        else:
            self.restore()
            
        #Sometimes it seems to fail but then work a second time
        try:
            win32gui.SetForegroundWindow(self.hwnd)
        except pywintypes.error:
            time.sleep(0.5)
            win32gui.ShowWindow(self.hwnd, True)
            try:
                win32gui.SetForegroundWindow(self.hwnd)
            except pywintypes.error:
                pass 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:21,代码来源:main.py

示例6: show_menu

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

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

示例8: show_menu

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

示例9: _show_menu

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

示例10: set_window_coordinates

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def set_window_coordinates(hwnd, window_info):
    if win32gui.IsWindowVisible(hwnd):
        if WINDOW_SUBSTRING in win32gui.GetWindowText(hwnd):
            rect = win32gui.GetWindowRect(hwnd)
            x = rect[0]
            y = rect[1]
            w = rect[2] - x
            h = rect[3] - y
            window_info['x'] = x
            window_info['y'] = y
            window_info['width'] = w
            window_info['height'] = h
            window_info['name'] = win32gui.GetWindowText(hwnd)
            win32gui.SetForegroundWindow(hwnd) 
开发者ID:maaaxim,项目名称:bot,代码行数:16,代码来源:functions.py

示例11: snapshot

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def snapshot(self, filename=None ):
        ''' Capture device screen '''
        range_ = self._range()
        win32gui.SetForegroundWindow(self.HWND)
        time.sleep(0.1)
        pic = ImageGrab.grab(range_)
        if filename !=None:
            pic.save(filename)
        return pic 
开发者ID:NetEase,项目名称:airtest,代码行数:11,代码来源:windows.py

示例12: focusWindow

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def focusWindow(hwnd):
    '''
    捕捉窗口焦点
    :param hwnd: 窗体句柄
    :return:
    '''
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
    win32gui.SetForegroundWindow(hwnd) 
开发者ID:ynzheng,项目名称:pyautotrade_tdx,代码行数:10,代码来源:winguiauto.py

示例13: enum_window_callback

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def enum_window_callback(hwnd, pid):
    tid, current_pid = win32process.GetWindowThreadProcessId(hwnd)
    if pid == current_pid and win32gui.IsWindowVisible(hwnd):
        win32gui.SetForegroundWindow(hwnd)
        l("window activated") 
开发者ID:xulusjb,项目名称:PUBG,代码行数:7,代码来源:main.py

示例14: swap_focus

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def swap_focus(func):
    """
    Use this decorator for any method that does an action in premiere. Not needed for queries but for any action
    that will change something in the UI we have to give focus to Premiere
    """
    def wrapper(self, *args, **kwargs):
        win32gui.SetForegroundWindow(self.premiere_window_id)
        result = func(self, *args, **kwargs)
        win32gui.SetForegroundWindow(self.ui_id)
        return result
    return wrapper 
开发者ID:qmasingarbe,项目名称:pymiere,代码行数:13,代码来源:demo_ui.py

示例15: getGameWindowPosition

# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SetForegroundWindow [as 别名]
def getGameWindowPosition():
    # FindWindow(lpClassName=None, lpWindowName=None)  窗口类名 窗口标题名
    window = win32gui.FindWindow(None,WINDOW_TITLE)
    # 没有定位到游戏窗体
    while not window:
        print('定位游戏窗体失败,5秒后重试...')
        time.sleep(5)
        window = win32gui.FindWindow(None,WINDOW_TITLE)
    # 定位到游戏窗体
    win32gui.SetForegroundWindow(window) # 将窗体顶置
    pos = win32gui.GetWindowRect(window)
    print("定位到游戏窗体:" + str(pos))
    return (pos[0],pos[1])

# 获取一张完整的屏幕截图 
开发者ID:TheThreeDog,项目名称:Auto-Lianliankan,代码行数:17,代码来源:run.py


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