def changeCallback(type, args): global messWindow # not active without special version of natlinkmain, # call the cancelMode, to switch off exclusive mode when mic toggles: # try to find the messages window at each mic on and minimize if found: if type == 'mic' and args == 'on': if testMode: return # only in production mode... #print 'mic on, messWindow: %s'% messWindow if messWindow: try: title = win32gui.GetWindowText(messWindow) if title != messTitle: print('title does not match: actual: |%s|, wanted: |%s|' % (title, messTitle)) messWindow = None except: messWindow = None if not messWindow: messWindows = mess.findTopWindows( wantedText="Messages from Python Macros") if messWindows: messWindow = messWindows[0] if not messWindow: print('didnt find messages window') return #toMin = win32con.SW_MINIMIZE toMin = win32con.SW_SHOWMINIMIZED info = list(win32gui.GetWindowPlacement(messWindow)) #print 'info1: %s, SW_SHOWMINIMIZED: %s'% (info[1], toMin) info[1] = toMin win32gui.SetWindowPlacement(messWindow, tuple(info))
def onPlacewindow(self, name): # """ toplist, winlist = [], [ ] # пустые списки куда будут запихиваться хандлы окон #европейская рулетка премиум - william hill casino nameWindow = name def enum_cb(hwnd, results): winlist.append((hwnd, win32gui.GetWindowText(hwnd))) win32gui.EnumWindows(enum_cb, toplist) print(winlist) windowToInterest = [(hwnd, title) for hwnd, title in winlist if nameWindow in title.lower() ] # получение хендла по title # just grab the hwnd for first window matching firefox print(len(windowToInterest)) # if len(firefox1)==1: hwnd1 = windowToInterest print(repr(hwnd1)) firefox = windowToInterest[0] # мы тут отсекли название окна hwnd = firefox[0] print(repr(hwnd)) # y = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN) # получаем координату Y(начало в данном случае Y=0) win32gui.SetForegroundWindow(hwnd) # выводит на передний план окно # win32gui.SetWindowPlacement(hwnd,(0, 1, (-1, -1), (-1, -1), (1922, 0, 2720, 474))) with open('WindowPlace.txt', 'r') as f: # извлекаем из файла place = json.load(f) win32gui.SetWindowPlacement(hwnd, place)
def __init__(self, parent): self._init_ctrls(parent) self.engine = TortillaEngine() if not self.engine.version_tag.startswith("NoIcon"): try: import win32api exeName = win32api.GetModuleFileName( win32api.GetModuleHandle(None)) icon = wx.Icon(exeName, wx.BITMAP_TYPE_ICO) self.SetIcon(icon) except: pass self.SetTitle('AstroTortilla %s' % self.engine.version) self.progress.Hide() self.configGrid.CreateGrid(1, 2) self.engine.subscribeStatus(self.__statusUpdater) self.engine.subscribeProgress(self.__progressUpdater) self.prev_rowcol = [None, None] # helper for solver config matrix tooltip # set default null values everywhere self.txtDec.SetLabel(deg2dms(0)) self.txtScopeTargetDec.SetLabel(deg2dms(0)) self.txtCamDec.SetLabel(deg2dms(0)) # Bind self.OnClose to window closing event self.Bind(wx.EVT_CLOSE, self.OnClose) self.numCtrlExposure.SetValue(self.engine.getExposure() or 5.0) # set default exposure value self.numCtrlAccuracy.SetValue(self.engine.getAccuracy() or 1.0) # set default accuracy value disable(self.btnScopeSetup) self.updateCamera() # Old compatibility mode x = y = w = h = -32000 try: x = self.engine.config.getint("Session", "GuiX") y = self.engine.config.getint("Session", "GuiY") w = self.engine.config.getint("Session", "GuiW") h = self.engine.config.getint("Session", "GuiH") except: pass # -32000 for minimized state? check SetWindowPlacement/Get... if x > -32000: self.SetPosition((x, y)) if h > 0: self.SetSize((w, h)) # New window placement method try: placement = self.engine.config.get("Session", "MainPlacement") import ast win32gui.SetWindowPlacement(self.GetHandle(), ast.literal_eval(placement)) except: pass
def set_placement(self, hndl, placement): """ Set the window placement in the desktop. @type placement: L{win32.WindowPlacement} @param placement: Window placement in the desktop. @raise WindowsError: An error occurred while processing this request. """ try: win32gui.SetWindowPlacement(hndl, placement) except: print "Unexpected error:", sys.exc_info()[0] raise else: pass
def deactivate(): restore_data = vim.vars.get('fullscreen_restoredata') win32gui.DestroyWindow(restore_data.get('bkgnd_wnd')) win32gui.UnregisterClass(restore_data.get('class_atom'), None) top_wnd = win32gui.FindWindow('Vim', None) win32api.SetWindowLong(top_wnd, win32con.GWL_STYLE, restore_data.get('style')) win32api.SetWindowLong(top_wnd, win32con.GWL_EXSTYLE, restore_data.get('exstyle')) win32gui.SetWindowPlacement(top_wnd, restore_data.get('window_placement')) if restore_data.get('window_placement')[1] == win32con.SW_SHOWMAXIMIZED: win32api.SendMessage(top_wnd, win32con.WM_SYSCOMMAND, win32con.SC_RESTORE, 0) win32api.SendMessage(top_wnd, win32con.WM_SYSCOMMAND, win32con.SC_MAXIMIZE, 0) vim.vars.update({'fullscreen_restoredata': {}}) vim.vars.update({'fullscreen_active': 0})
def onPlacewindow(self, event): # """ start1 = clock() btn = event.GetEventObject().GetLabel() toplist, winlist = [], [ ] # пустые списки куда будут запихиваться хандлы окон #европейская рулетка премиум - william hill casino nameWindow = (self.posCtrl.GetValue()).lower() def enum_cb(hwnd, results): winlist.append((hwnd, win32gui.GetWindowText(hwnd))) win32gui.EnumWindows(enum_cb, toplist) print(winlist) windowToInterest = [(hwnd, title) for hwnd, title in winlist if nameWindow in title.lower() ] # получение хендла по title # just grab the hwnd for first window matching firefox print(len(windowToInterest)) # if len(firefox1)==1: hwnd1 = windowToInterest print(repr(hwnd1)) firefox = windowToInterest[0] # мы тут отсекли название окна hwnd = firefox[0] print(repr(hwnd)) # y = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN) # получаем координату Y(начало в данном случае Y=0) win32gui.SetForegroundWindow(hwnd) # выводит на передний план окно if btn == 'Get Place Window': place = win32gui.GetWindowPlacement(hwnd) print('place', place) with open('WindowPlace.txt', 'w') as jsonfile: json.dump(place, jsonfile) # win32gui.SetWindowPlacement(hwnd,(0, 1, (-1, -1), (-1, -1), (1922, 0, 2720, 474))) if btn == 'Place window': with open('WindowPlace.txt', 'r') as f: # извлекаем из файла place = json.load(f) win32gui.SetWindowPlacement(hwnd, place) end1 = clock() print("Result (iterativ): выполняется за " + "\nФункция %1.10f секунд" % (end1 - start1))
def unmaximize(hwnd, x, y, width, height): SW_NORMAL = 1 win32gui.SetWindowPlacement(hwnd, (0, SW_NORMAL, (-1, -1), (-1, -1), (x, y, x + width, y + height)))
def maximize(hwnd): SW_MAXIMIZE = 3 x, y, x2, y2 = win32gui.GetWindowRect(hwnd) win32gui.SetWindowPlacement(hwnd, (2, SW_MAXIMIZE, (-1, -1), (-1, -1), (x, y, x2, y2)))
def restore(self): for window in self.frozen_windows: if window.is_real(): win32gui.BringWindowToTop(window.hwnd) win32gui.SetWindowPlacement(window.hwnd, window.placement)