Python win32gui.ShowWindow() Examples

The following are code examples for showing how to use win32gui.ShowWindow(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: foto2vam   Author: ChrisTopherTa54321   File: window.py    GNU General Public License v3.0 7 votes vote down vote up
def focus(self):
        delay = None # if the window wasn't already active we want to give it time to focus
        hwnd = self._getVamHndl()

        # Is the window minimized?
        if win32gui.IsIconic( hwnd ):
            win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)
            delay = "Window was minimized"

        # Delay if the window wasn't already active
        if hwnd != win32gui.GetForegroundWindow():
            delay = "Window was not in focus"

        win32gui.ShowWindow(hwnd, 5)
        win32gui.SetForegroundWindow( hwnd )


        if delay:
            print( "Delaying because: {}".format( delay ))
            time.sleep(.2)


    # Find an image in a region. Originalyl used for loadLook, but is very unreliable 
Example 2
Project: Rider-PPO   Author: YoongiKim   File: show_window.py    MIT License 6 votes vote down vote up
def enumHandler(hwnd, lParam):
    if win32gui.IsWindowVisible(hwnd):
        if 'BlueStacks' in win32gui.GetWindowText(hwnd):
            win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
            win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOSIZE | win32con.SWP_SHOWWINDOW) 
Example 3
Project: SasSubmit   Author: sjiangDA   File: helper.py    MIT License 6 votes vote down vote up
def activate(self, with_mouse=False, with_alt=True, x_w=0.5, y_w=0.5):
		rect = win32gui.GetWindowRect(self.hwnd)
		newx = int(x_w*rect[0]+(1-x_w)*rect[2])
		newy = int(y_w*rect[1]+(1-y_w)*rect[3])
		if newx + newy == 0:
			raise ValueError("Window cannot be found!")
		try:
			shell = win32com.client.Dispatch("WScript.Shell")
			if with_alt:
				shell.SendKeys('%')
			if win32gui.IsIconic(self.hwnd):
				win32gui.ShowWindow(self.hwnd, 9)
			win32gui.SetForegroundWindow(self.hwnd)
		except Exception as e:
			raise ValueError("Activate window failed!")

		if with_mouse:
			move_mouse_to(newx,newy) 
Example 4
Project: apptools   Author: timeyyy   File: pidutil.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def show_window(value):
    if os.name == 'nt':
        HWND = value
        win32gui.ShowWindow(HWND, win32con.SW_RESTORE)
        win32gui.SetWindowPos(HWND,win32con.HWND_NOTOPMOST, 0, 0, 0,0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE )
        win32gui.SetWindowPos(HWND,win32con.HWND_TOPMOST, 0, 0, 0,0,win32con.SWP_NOMOVE + win32con.SWP_NOSIZE )
        win32gui.SetWindowPos(HWND,win32con.HWND_NOTOPMOST, 0, 0, 0,0,win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)
        #~ win32gui.ShowWindow(hWnd,win32con.SW_SHOW); 
        #~ win32gui.BringWindowToTop(hWnd);
        #~ win32gui.SetForegroundWindow(hWnd);
        #http://stackoverflow.com/questions/6312627/windows-7-how-to-bring-a-window-to-the-front-no-matter-what-other-window-has-fo
        #http://timgolden.me.uk/pywin32-docs/win32gui__SetWindowPos_meth.html
        #~ //-- on Windows 7, this workaround brings window to top
        #~ win32gui.SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE);
        #~ win32gui.SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,win32con.SWP_NOMOVE | win32con.SWP_NOSIZE);
        #~ win32gui.SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0,win32con.SWP_SHOWWINDOW | win32con.SWP_NOMOVE | win32con.SWP_NOSIZE);
    else:
        name = value
        cmd = ['xdotool','search','--name','--onlyvisible', name,'windowactivate']
        args = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr= subprocess.PIPE).communicate() 
Example 5
Project: flight-lab   Author: google   File: windows.py    Apache License 2.0 5 votes vote down vote up
def minimize(self):
    """Minimizes the window."""
    hwnd = self.get_hwnd()
    win32gui.ShowWindow(hwnd, win32con.SW_MINIMIZE)
    return self 
Example 6
Project: avashell   Author: sampot   File: shell_win32.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def show(self):
        win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL) 
Example 7
Project: Advanced-Action-Scheduler   Author: swprojects   File: windowmanager.py    GNU General Public License v2.0 5 votes vote down vote up
def MaximizeWindow(handle):
    win32gui.ShowWindow(handle, win32con.SW_SHOW) 
Example 8
Project: Advanced-Action-Scheduler   Author: swprojects   File: windowmanager.py    GNU General Public License v2.0 5 votes vote down vote up
def MinimizeWindow(handle):
    win32gui.ShowWindow(handle, win32con.SW_HIDE) 
Example 9
Project: Advanced-Action-Scheduler   Author: swprojects   File: windowmanager.py    GNU General Public License v2.0 5 votes vote down vote up
def RestoreWindow(handle):
    win32gui.ShowWindow(handle, win32con.SW_RESTORE) 
Example 10
Project: Advanced-Action-Scheduler   Author: swprojects   File: windowmanager.py    GNU General Public License v2.0 5 votes vote down vote up
def ShowWindow(handle):
    win32gui.ShowWindow(handle, win32con.SW_SHOW) 
Example 11
Project: ironpython2   Author: IronLanguages   File: ietoolbar.py    Apache License 2.0 5 votes vote down vote up
def ShowWindow(self,mode):
        win32gui.ShowWindow(self.hwnd,mode) 
Example 12
Project: ironpython2   Author: IronLanguages   File: ietoolbar.py    Apache License 2.0 5 votes vote down vote up
def ShowDW(self, bShow):
        if bShow:
            self.toolbar.ShowWindow(win32con.SW_SHOW)
        else:
            self.toolbar.ShowWindow(win32con.SW_HIDE) 
Example 13
Project: open-recipe   Author: dspray95   File: ietoolbar.py    The Unlicense 5 votes vote down vote up
def ShowWindow(self,mode):
        win32gui.ShowWindow(self.hwnd,mode) 
Example 14
Project: open-recipe   Author: dspray95   File: ietoolbar.py    The Unlicense 5 votes vote down vote up
def ShowDW(self, bShow):
        if bShow:
            self.toolbar.ShowWindow(win32con.SW_SHOW)
        else:
            self.toolbar.ShowWindow(win32con.SW_HIDE) 
Example 15
Project: ActualBotNet   Author: invasi0nZ   File: ActualBot.py    MIT License 5 votes vote down vote up
def hide(self):
        window = win32console.GetConsoleWindow()
        win32gui.ShowWindow(window, 0) 
Example 16
Project: ActualBotNet   Author: invasi0nZ   File: Lo0sR.py    MIT License 5 votes vote down vote up
def hide(self):
        window = win32console.GetConsoleWindow()
        win32gui.ShowWindow(window, 0) 
Example 17
Project: Rider-PPO   Author: YoongiKim   File: show_window.py    MIT License 5 votes vote down vote up
def ShowWindow():
    win32gui.EnumWindows(enumHandler, None) 
Example 18
Project: PyLoggy   Author: D4Vinci   File: PyLoggy.py    GNU General Public License v3.0 5 votes vote down vote up
def Hide():
    import win32console
    import win32gui
    win = win32console.GetConsoleWindow()
    win32gui.ShowWindow(win, 0) 
Example 19
Project: system_tray   Author: timeyyy   File: taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_to_taskbar(hw):
    try:
        #~ win32gui.ShowWindow(hw, SW_HIDE)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE,WS_EX_APPWINDOW)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW);
        #~ win32gui.ShowWindow(hw, SW_SHOW);
    except win32gui.error:
        print("Error while hiding the window")
        return None	

#~ @staticmethod 
Example 20
Project: system_tray   Author: timeyyy   File: taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def hide_from_taskbar(hw):
    try:
        win32gui.ShowWindow(hw, SW_HIDE)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
        #~ win32gui.ShowWindow(hw, SW_SHOW)
    except win32gui.error:
        print("Error while hiding the window")
        return None

#~ @staticmethod 
Example 21
Project: system_tray   Author: timeyyy   File: win_taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_to_taskbar(hw):
    try:
        #~ win32gui.ShowWindow(hw, SW_HIDE)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE,WS_EX_APPWINDOW)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW);
        #~ win32gui.ShowWindow(hw, SW_SHOW);
    except win32gui.error:
        print("Error while hiding the window")
        return None	

#~ @staticmethod 
Example 22
Project: system_tray   Author: timeyyy   File: win_taskbar.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def hide_from_taskbar(hw):
    try:
        win32gui.ShowWindow(hw, SW_HIDE)
        #~ win32gui.SetWindowLong(hw, GWL_EXSTYLE,win32gui.GetWindowLong(hw, GWL_EXSTYLE)| WS_EX_TOOLWINDOW)
        win32gui.SetWindowLong(hw, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
        #~ win32gui.ShowWindow(hw, SW_SHOW)
    except win32gui.error:
        print("Error while hiding the window")
        return None

#~ @staticmethod 
Example 23
Project: Lo0sR   Author: invasi0nZ   File: Lo0sR.py    MIT License 5 votes vote down vote up
def hide(self):
        window = win32console.GetConsoleWindow()
        win32gui.ShowWindow(window, 0) 
Example 24
Project: Demons-eye-keylogger   Author: gabimarti   File: demonseye.py    GNU General Public License v3.0 5 votes vote down vote up
def hide_console():
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window, 0)
    logging.debug('Oculta consola')


# Get the external ip 
Example 25
Project: Demons-eye-keylogger   Author: gabimarti   File: demonseye.py    GNU General Public License v3.0 5 votes vote down vote up
def hide_console():
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window, 0)
    logging.debug('Oculta consola')


# Get the external ip 
Example 26
Project: Demons-eye-keylogger   Author: gabimarti   File: demonseye.py    GNU General Public License v3.0 5 votes vote down vote up
def hide_console():
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window, 0)
    logging.debug('Oculta consola')


# Get the external ip 
Example 27
Project: pyautotrade_tdx   Author: ynzheng   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def focusWindow(hwnd):
    '''
    捕捉窗口焦点
    :param hwnd: 窗体句柄
    :return:
    '''
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
    win32gui.SetForegroundWindow(hwnd) 
Example 28
Project: pytrade   Author: allisnone   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def maxFocusWindow(hwnd):
    win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
    time.sleep(0.2)
    win32gui.SetForegroundWindow(hwnd)
    time.sleep(0.2) 
Example 29
Project: pytrade   Author: allisnone   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def minWindow(hwnd):
    win32gui.ShowWindow(hwnd, win32con.SW_MINIMIZE)
    time.sleep(0.2) 
Example 30
Project: pyty   Author: howardjohn   File: window_api.py    GNU General Public License v3.0 5 votes vote down vote up
def restore(hwnd):
    """
    Restores (unmaximizes) the window.

    Args:
        hwnd (int): The window handler.
    """
    wg.ShowWindow(hwnd, wc.SW_RESTORE) 
Example 31
Project: pyty   Author: howardjohn   File: window_api.py    GNU General Public License v3.0 5 votes vote down vote up
def maximize(hwnd):
    """
    Maximizes the window.

    Args:
        hwnd (int): The window handler.
    """
    wg.ShowWindow(hwnd, wc.SW_MAXIMIZE) 
Example 32
Project: pyty   Author: howardjohn   File: window_api.py    GNU General Public License v3.0 5 votes vote down vote up
def focus_window(hwnd):
    """
    Focuses the given window.

    Args:
        hwnd (int): The window handler.
    """
    wg.ShowWindow(hwnd, wc.SW_SHOW)
    wg.ShowWindow(hwnd, wc.SW_SHOWNOACTIVATE)
    wg.SetForegroundWindow(hwnd) 
Example 33
Project: PictureMatchCheater   Author: tianyigeng   File: UI.py    MIT License 5 votes vote down vote up
def getOrigin():
    cwllk = '宠物连连看'.decode('utf8')
    hwnd = win32gui.FindWindow("#32770", cwllk)
    print hwnd
    
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWMINIMIZED)
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)
    win32gui.SetForegroundWindow(hwnd)
    rect = win32gui.GetWindowRect(hwnd)
    time.sleep(0.5)
    print rect
    
    newRect = (rect[0] + 58, rect[1] + 104, rect[0] + 674, rect[1] + 504)
    
    return newRect 
Example 34
Project: PictureMatchCheater   Author: tianyigeng   File: UI.py    MIT License 5 votes vote down vote up
def getOrigin():
    cwllk = '宠物连连看'.decode('utf8')
    hwnd = win32gui.FindWindow("#32770", cwllk)
    print hwnd
    
    #win32gui.ShowWindow(hwnd, win32con.SW_SHOWMINIMIZED)
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWNORMAL)
    win32gui.SetForegroundWindow(hwnd)
    rect = win32gui.GetWindowRect(hwnd)
    time.sleep(0.5)
    #print rect
    
    #newRect = (rect[0] + 58, rect[1] + 104, rect[0] + 674, rect[1] + 504)
    
    return rect 
Example 35
Project: PyAutoTrading   Author: bluestinger   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def focusWindow(hwnd):
    '''
    捕捉窗口焦点
    :param hwnd: 窗体句柄
    :return:
    '''
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
    win32gui.SetForegroundWindow(hwnd) 
Example 36
Project: T2B-framework   Author: pielco11   File: Windows-client.py    MIT License 5 votes vote down vote up
def hide():
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window,0)
    return True 
Example 37
Project: T2B-framework   Author: pielco11   File: Windows-client.py    MIT License 5 votes vote down vote up
def hide():
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window,0)
    return True 
Example 38
Project: csgo_richpresence   Author: Tenrys   File: main.py    GNU General Public License v3.0 5 votes vote down vote up
def enum_window_callback(hwnd, pid):
			try: # psutil is prone to error if you give it a pid for a process that doesn't exist
				p = psutil.Process(pid)
				if p and p.name().lower() in hide:
					_, window_pid = win32process.GetWindowThreadProcessId(hwnd)
					if pid == window_pid:
						print("Hid window of", p.name())
						win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
			except Exception as e:
				print("Failed to hide window:", str(e), pid)
				# print("Something could have gone wrong here while hiding the console, ignore this")
				# pass 
Example 39
Project: Keyloger   Author: beyes2018   File: n2_python_logger.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def hide():
    import win32console,win32gui
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window,0)
    return True 
Example 40
Project: Keyloger   Author: beyes2018   File: keylogerV1.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def hide():
    import win32console,win32gui
    window = win32console.GetConsoleWindow()
    win32gui.ShowWindow(window,0)
    return True

# Add to startup 
Example 41
Project: iamnotafk   Author: gbrlbsls   File: afk.py    MIT License 5 votes vote down vote up
def focus(self):
        try:
            if win32gui.IsIconic(self.hwnd):
                win32gui.ShowWindow(self.hwnd, 9)
                return False

            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.SetActiveWindow(self.hwnd)
        except:
            pass
        
        return self._is_focused() 
Example 42
Project: arkScript   Author: akbchris   File: ietoolbar.py    MIT License 5 votes vote down vote up
def ShowWindow(self,mode):
        win32gui.ShowWindow(self.hwnd,mode) 
Example 43
Project: arkScript   Author: akbchris   File: ietoolbar.py    MIT License 5 votes vote down vote up
def ShowDW(self, bShow):
        if bShow:
            self.toolbar.ShowWindow(win32con.SW_SHOW)
        else:
            self.toolbar.ShowWindow(win32con.SW_HIDE) 
Example 44
Project: play_as_one   Author: jaronoff97   File: PlayAsOne.py    MIT License 5 votes vote down vote up
def find_game_window(self):
        if sys.platform == 'win32':
            winlist = []

            def enum_cb(hwnd, extra):
                winlist.append((hwnd, win32gui.GetWindowText(hwnd)))
            win32gui.EnumWindows(enum_cb, None)

            window = [
                (hwnd, title) for hwnd, title in winlist if self.gui.titlebar_entry.get().lower() in title.lower()]
            if not window:
                return False
            window = window[0]
            hwnd = window[0]

            win32gui.ShowWindow(hwnd, 11)
            win32gui.ShowWindow(hwnd, 1)
            win32gui.SetForegroundWindow(hwnd)
            region = win32gui.GetWindowRect(hwnd)
            region = (
                region[0],
                region[1],
                region[2]-region[0],
                region[3]-region[1]
            )
            return region
        return False 
Example 45
Project: PyQt   Author: PyQt5   File: EmbedWindow.py    GNU General Public License v3.0 5 votes vote down vote up
def restore(self):
        """归还窗口"""
        # 有bug,归还后窗口没有了WS_VISIBLE样式,不可见
        widget = self.layout().itemAt(3).widget()
        print('restore', widget.hwnd, widget.style, widget.exstyle)
        win32gui.SetParent(widget.hwnd, widget.phwnd)  # 让它返回它的父窗口
        win32gui.SetWindowLong(
            widget.hwnd, win32con.GWL_STYLE, widget.style | win32con.WS_VISIBLE)  # 恢复样式
        win32gui.SetWindowLong(
            widget.hwnd, win32con.GWL_EXSTYLE, widget.exstyle)  # 恢复样式
        win32gui.ShowWindow(
            widget.hwnd, win32con.SW_SHOW)  # 显示窗口
        widget.close()
        self.layout().removeWidget(widget)  # 从布局中移出
        widget.deleteLater() 
Example 46
Project: Poco   Author: AirtestProject   File: WindowsUI.py    Apache License 2.0 5 votes vote down vote up
def SetForeground(self):
        win32gui.ShowWindow(self.root.Handle, win32con.SW_SHOWNORMAL)  # 先把窗口取消最小化
        UIAuto.Win32API.SetForegroundWindow(self.root.Handle)  # 再把窗口设为前台,方便点击和截图
        return True 
Example 47
Project: pyautotrade_tdx   Author: wangdkchina   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def focusWindow(hwnd):
    '''
    捕捉窗口焦点
    :param hwnd: 窗体句柄
    :return:
    '''
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
    win32gui.SetForegroundWindow(hwnd) 
Example 48
Project: pyAutoTrading   Author: drongh   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def restoreFocusWindow(hwnd):
    win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)
    win32gui.SetForegroundWindow(hwnd)
    time.sleep(0.2) 
Example 49
Project: pyAutoTrading   Author: drongh   File: winguiauto.py    GNU General Public License v2.0 5 votes vote down vote up
def focusWindow(hwnd):
    """
    捕捉窗口焦点
    :param hwnd: 窗体句柄
    :return:
    """
    win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
    win32gui.SetForegroundWindow(hwnd) 
Example 50
Project: wexpect   Author: raczben   File: wexpect.py    MIT License 5 votes vote down vote up
def interact(self):
        """Displays the child console for interaction."""
    
        self.switchTo()
        try:
            win32gui.ShowWindow(win32console.GetConsoleWindow(), win32con.SW_SHOW)
        finally:
            self.switchBack() 
Example 51
Project: wexpect   Author: raczben   File: wexpect.py    MIT License 5 votes vote down vote up
def stop_interact(self):
        """Hides the child console."""
        
        self.switchTo()
        try:
            win32gui.ShowWindow(win32console.GetConsoleWindow(), win32con.SW_HIDE)
        finally:
            self.switchBack() 
Example 52
Project: eavatar-me   Author: eavatar   File: window.py    Apache License 2.0 5 votes vote down vote up
def show(self):
        win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL) 
Example 53
Project: eavatar-me   Author: eavatar   File: console.py    Apache License 2.0 5 votes vote down vote up
def show(self):
        # print("show")
        if self.hwnd:
            win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL)
            self.hidden = False
            self.clear_script() 
Example 54
Project: eavatar-me   Author: eavatar   File: console.py    Apache License 2.0 5 votes vote down vote up
def hide(self):
        print("hide")
        win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)
        self.hidden = True 
Example 55
Project: eavatar-me   Author: eavatar   File: notice_dlg.py    Apache License 2.0 5 votes vote down vote up
def show(self):
        # print("show")
        if self.hwnd:
            win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL)
            self.hidden = False
            self._clear_script() 
Example 56
Project: eavatar-me   Author: eavatar   File: notice_dlg.py    Apache License 2.0 5 votes vote down vote up
def hide(self):
        print("hide")
        win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)
        self.hidden = True 
Example 57
Project: fb2k-mini-player   Author: th3-z   File: FoobarMiniplayer.py    MIT License 5 votes vote down vote up
def focus_fb(self, event=None):
        toplist = []
        winlist = []

        def enum_callback(hwnd, results):
            winlist.append((hwnd, win32gui.GetWindowText(hwnd)))

        win32gui.EnumWindows(enum_callback, toplist)
        foobar = [(hwnd, title) for hwnd, title in winlist
                  if "foobar2000" in title.lower()]
        foobar = foobar[0]

        win32gui.ShowWindow(foobar[0], win32con.SW_RESTORE)
        win32gui.SetForegroundWindow(foobar[0])