def set_always_on_top(val):
global windowsWindow
global isOnTop
if isWindows:
if windowsWindow:
rect = win32gui.GetWindowRect(windowsWindow)
x = rect[0]
y = rect[1]
w = rect[2] - x
h = rect[3] - y
placement = win32gui.GetWindowPlacement(windowsWindow)
if val is True:
win32gui.SetWindowPos(windowsWindow, win32con.HWND_TOPMOST, x, y, w, h, placement[1])
isOnTop = True
# win32gui.SetFocus(windowsWindow)
else:
win32gui.SetWindowPos(windowsWindow, win32con.HWND_NOTOPMOST, x, y, w, h, placement[1])
isOnTop = False
return True
else:
print("Window with title 'Google It Up!' doesnt exist")
return False
elif isMac:
# Not working, dont try
command = "/usr/bin/osascript -e 'tell app \"System Events\"' "
command += "-e 'set theApps to every process whose name contains \"Google It Up!\"' "
command += "-e 'set theApp to item 1 of theApps' -e 'set frontmost of theApp to true' "
command += "-e 'end tell'"
if val == False:
command = command.replace('true', 'false')
os.system(command)
评论列表
文章目录