コード例 #1
0
	def callback(self, hwnd, param):
		if not win32gui.IsWindowVisible(hwnd):
			return
		if win32gui.GetWindowTextLength(hwnd) == 0:
			return
		if win32gui.GetParent(hwnd):
			return
		self.list.update({win32gui.GetWindowText(hwnd) : hwnd})
コード例 #2
0
ファイル: windows.py プロジェクト: franzmelchiori/alyvix
    def _get_hwnd(self, window_title):
        windows_found = []
        hwnd_list = []
        win32gui.EnumWindows(self.__window_enumeration_handler, windows_found)
        for hwnd_found, title_found in windows_found:
            if re.match(".*" + window_title + ".*", title_found, re.DOTALL | re.IGNORECASE) is not None and \
                    (win32gui.IsWindowVisible(hwnd_found) != 0 or win32gui.GetWindowTextLength(hwnd_found) > 0):
                hwnd_list.append(hwnd_found)

        return hwnd_list
コード例 #3
0
ファイル: closewindow.py プロジェクト: vafaronaghi/Alexa2
def CloseHideAllWindow(close=True):
    if sys.platform == 'win32':
        import win32gui
        import win32con

        toplist, winlist = [], []

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

        win32gui.EnumWindows(enum_callback, toplist)

        #^(?!.*details\.cfm).*selector=size.*$
        #window = [(hwnd, curTitle) for hwnd, curTitle in winlist if re.match("al.*exa.*(tool|nagios utilities|mouse and keyboard).*", curTitle, re.DOTALL | re.IGNORECASE) != None and win32gui.IsWindowVisible(hwnd) != 0]
        windows = [(hwnd, curTitle) for hwnd, curTitle in winlist
                   if win32gui.GetWindowTextLength(hwnd) > 0]

        # just grab the hwnd for first window matching title
        #print "toplist", top
        if len(windows) > 0:
            toplist, winlist = [], []
            #print windows

            for window in windows:
                try:
                    #if openedWindow[0].lower() == 'Al\'exa tools':
                    title = window[1]

                    if 'al\'exa - nagios utilities' == title.lower(
                    ) or 'al\'exa - mouse and keyboard' == title.lower(
                    ) or 'al\'exa - windows and region' == title.lower(
                    ) or 'al\'exa - process utilities' == title.lower(
                    ) or 'al\'exa - e-mail' == title.lower():
                        if close is True:
                            win32gui.PostMessage(window[0], win32con.WM_CLOSE,
                                                 0, 0)
                        else:
                            win32gui.ShowWindow(window[0], 0)
                except:
                    continue
コード例 #4
0
    def _get_hwnd(self, window_title):
        windows_found = []
        hwnd_list = []
        win32gui.EnumWindows(self.__window_enumeration_handler, windows_found)
        self._win_found = None
        for hwnd_found, title_found in windows_found:
            if re.match(window_title, title_found, re.DOTALL) is not None and \
                    (win32gui.IsWindowVisible(hwnd_found) != 0 or win32gui.GetWindowTextLength(hwnd_found) > 0):
                hwnd_list.append(hwnd_found)

                try:
                    rect = win32gui.GetWindowRect(hwnd_found)
                    x = rect[0]
                    y = rect[1]
                    w = rect[2] - x
                    h = rect[3] - y

                    self._win_found = title_found + ", is visible: x=" + str(
                        x) + ", y=" + str(y) + ", width=" + str(
                            w) + ", height=" + str(h)
                except:
                    self._win_found = "nothing to show, window doesn't exist anymore"

        return hwnd_list
コード例 #5
0
 def write(self, data):
     length = win32gui.GetWindowTextLength(self.handle)
     win32gui.SendMessage(self.handle, win32con.EM_SETSEL, length, length)
     win32gui.SendMessage(self.handle, win32con.EM_REPLACESEL, False, data)