本文整理汇总了Python中win32gui.ShowWindow方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.ShowWindow方法的具体用法?Python win32gui.ShowWindow怎么用?Python win32gui.ShowWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32gui
的用法示例。
在下文中一共展示了win32gui.ShowWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bring_to_front
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [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
示例2: find_window_movetop
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [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
示例3: raise_mpv
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def raise_mpv():
# This workaround is madness. Apparently SetForegroundWindow
# won't work randomly, so I have to call ShowWindow twice.
# Once to hide the window, and again to successfully raise the window.
try:
top_windows = []
fg_win = win32gui.GetForegroundWindow()
win32gui.EnumWindows(windowEnumerationHandler, top_windows)
for i in top_windows:
if " - mpv" in i[1].lower():
if i[0] != fg_win:
win32gui.ShowWindow(i[0], 6) # Minimize
win32gui.ShowWindow(i[0], 9) # Un-minimize
break
except Exception:
print("Could not raise MPV.")
traceback.print_exc()
示例4: tap
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def tap(self, x, y):
if self.run_time.stop:
return
x, y = int(x), int(y)
self.root.debug("Tapping at location ({},{})".format(x, y))
if self._debug:
# Helper to debug taps
input("waiting for confirmation press enter")
ox, oy = win32api.GetCursorPos()
curr_window = win32gui.GetForegroundWindow()
win32gui.ShowWindow(self.win_handle, win32con.SW_RESTORE)
x, y = int(x), int(y)
cx, cy = win32gui.ClientToScreen(self.win_handle, (x, y))
x, y = self.__calculate_absolute_coordinates__(cx, cy)
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE | win32con.MOUSEEVENTF_ABSOLUTE,
x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
time.sleep(20 / 1000)
win32api.SetCursorPos((ox, oy))
win32gui.SetActiveWindow(curr_window)
示例5: minimise
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def minimise(self):
"""Minimise a window."""
win32gui.ShowWindow(self.hwnd, win32con.SW_MINIMIZE)
示例6: focusWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def focusWindow(hwnd):
"""
捕捉窗口焦点
:param hwnd: 窗体句柄
:return:
"""
win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
win32gui.SetForegroundWindow(hwnd)
示例7: ShowWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def ShowWindow(self,mode):
win32gui.ShowWindow(self.hwnd,mode)
示例8: ShowDW
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def ShowDW(self, bShow):
if bShow:
self.toolbar.ShowWindow(win32con.SW_SHOW)
else:
self.toolbar.ShowWindow(win32con.SW_HIDE)
示例9: _win32gui_show_window
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def _win32gui_show_window(state):
return lambda self: win32gui.ShowWindow(self._handle, state)
示例10: Hide
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def Hide():
import win32console
import win32gui
win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)
示例11: hide
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def hide(self):
window = win32console.GetConsoleWindow()
win32gui.ShowWindow(window, 0)
示例12: focusWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def focusWindow(hwnd):
'''
捕捉窗口焦点
:param hwnd: 窗体句柄
:return:
'''
win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED)
win32gui.SetForegroundWindow(hwnd)
示例13: restore
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def restore(self):
"""Restore a window from being minimised."""
win32gui.ShowWindow(self.hwnd, win32con.SW_RESTORE)
示例14: hide
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
def hide(self, new=True):
"""Hide a window from the task bar.
Kept the old way just to be on the safe side.
"""
if new:
win32gui.ShowWindow(self.hwnd, False)
else:
self.minimise()
win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)
win32gui.SetWindowLong(self.hwnd, win32con.GWL_EXSTYLE,
win32gui.GetWindowLong(self.hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_TOOLWINDOW)
win32gui.ShowWindow(self.hwnd, win32con.SW_SHOW)
示例15: restore
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import ShowWindow [as 别名]
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()