def experiment(text): '''this function is for tests''' try: '''''' exes = set([x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows()]) titles = set([x.title for x in Window.get_all_windows()]) # print get_similar_process_name(exes) print titles except Exception: utilities.simple_log(False)
def experiment(text): '''this function is for tests''' try: '''''' exes = set([ x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows() ]) titles = set([x.title for x in Window.get_all_windows()]) # print get_similar_process_name(exes) print titles except Exception: utilities.simple_log(False)
def attempt_focus(): for win in Window.get_all_windows(): w=win found_match=True if title!=None: found_match=title in w.title if found_match and executable!=None: found_match=executable in w.executable if found_match: try: # this is still broken win32gui.SetWindowPos(w.handle,win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) win32gui.SetWindowPos(w.handle,win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) win32gui.SetWindowPos(w.handle,win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) Key("alt").execute() time.sleep(0.5) win32gui.SetForegroundWindow(w.handle) w.set_foreground() except Exception: utilities.report("Unable to set focus:\ntitle: "+w.title+"\nexe: "+w.executable) break # do not assume that it worked success = SuperFocusWindow.focus_was_success(title, executable) if not success: if title!=None: print "title failure: ", title, w.title if executable!=None: print "executable failure: ", executable, w.executable, executable in w.executable return success
def focus_was_success(title, executable): w = Window.get_foreground() success = True if title != None: success = title in w.title if success and executable != None: success = executable in w.executable return success
def focus_was_success(title, executable): w=Window.get_foreground() success=True if title!=None: success=title in w.title if success and executable!=None: success=executable in w.executable return success
def attempt_focus(): for win in Window.get_all_windows(): w = win found_match = True if title != None: found_match = title in w.title if found_match and executable != None: found_match = executable in w.executable if found_match: try: # this is still broken win32gui.SetWindowPos( w.handle, win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) win32gui.SetWindowPos( w.handle, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) win32gui.SetWindowPos( w.handle, win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) Key("alt").execute() time.sleep(0.5) win32gui.SetForegroundWindow(w.handle) w.set_foreground() except Exception: utilities.report("Unable to set focus:\ntitle: " + w.title + "\nexe: " + w.executable) break # do not assume that it worked success = SuperFocusWindow.focus_was_success(title, executable) if not success: if title != None: print "title failure: ", title, w.title if executable != None: print "executable failure: ", executable, w.executable, executable in w.executable return success
def get_active_window_path(): #return natlink.getCurrentModule()[0] return Window.get_foreground().executable
def path_from_executable(executable): for win in Window.get_all_windows(): if executable in win.executable: return win.executable
def dredge_tie_list_provider(): return list(set([x.title for x in Window.get_all_windows()]))
def dredge_ex_list_provider(): return list( set([ x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows() ]))
def dredge(id, text): print Window.get_foreground().executable print [x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows()]
for w in wanted_processes: # make copies because _phrase_to_symbol_similarity_score is destructive (of spoken phrase) process_lower = process.lower() w_lower = w.lower() score = selector._phrase_to_symbol_similarity_score(process_lower, w_lower) if score > best[0]: best = (score, w) return best[1] def dredge(id, text): print Window.get_foreground().executable print [x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows()] print get_similar_process_name(text, [x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows()]) LAST_TIME = 0 def print_time(): global LAST_TIME print time.time() - LAST_TIME LAST_TIME = time.time() COUNT = 5 def countdown():
def dredge_ex_list_provider(): return list(set([x.executable.split("\\")[-1][:-4] for x in Window.get_all_windows()]))