-
-
Save gustavomdsantos/46f4b4615eeabb2089478cbcc83cda76 to your computer and use it in GitHub Desktop.
; Press Ctrl+Shift+Space to set any currently active window to be always on top. | |
; Press Ctrl+Shift+Space again set the window to no longer be always on top. | |
; Source: https://www.howtogeek.com/196958/the-3-best-ways-to-make-a-window-always-on-top-on-windows | |
^+SPACE:: | |
WinGetTitle, activeWindow, A | |
if IsWindowAlwaysOnTop(activeWindow) { | |
notificationMessage := "The window """ . activeWindow . """ is now always on top." | |
notificationIcon := 16 + 1 ; No notification sound (16) + Info icon (1) | |
} | |
else { | |
notificationMessage := "The window """ . activeWindow . """ is no longer always on top." | |
notificationIcon := 16 + 2 ; No notification sound (16) + Warning icon (2) | |
} | |
Winset, Alwaysontop, , A | |
TrayTip, Always-on-top, %notificationMessage%, , %notificationIcon% | |
Sleep 3000 ; Let it display for 3 seconds. | |
HideTrayTip() | |
IsWindowAlwaysOnTop(windowTitle) { | |
WinGet, windowStyle, ExStyle, %windowTitle% | |
isWindowAlwaysOnTop := if (windowStyle & 0x8) ? false : true ; 0x8 is WS_EX_TOPMOST. | |
return isWindowAlwaysOnTop | |
} | |
HideTrayTip() { | |
TrayTip ; Attempt to hide it the normal way. | |
if SubStr(A_OSVersion,1,3) = "10." { | |
Menu Tray, NoIcon | |
Sleep 200 ; It may be necessary to adjust this sleep. | |
Menu Tray, Icon | |
} | |
} | |
Return |
This is very helpful, thank you! Works very well in Windows in general, but when using Citrix Workspace, it still runs on top of 'window of interest'. For example, I put Zoom as "always on top", but Citrix still hides it (while all other apps do not). Do you have any idea how to overcome it?
Thanks for this, the TrayTip is a very nice addition from the simple way I had been using.
Does not work for all windows, anybody know why?
e.g. with Dadroit JSON Viewer, this command does not work:
Winset, Alwaysontop, , A
TY
Works just fine (Win 10), thanks, pal!
For users who encounter software that the script does not work, try running AutoHotKey as a Windows administrator.
This script is now deprecated, I'm working in a AHKv2 version of this script:
https://gist.github.com/gustavomdsantos/c0d9d01c241e6ab72196a5d9664698a9
Is it possible to have a variant in which mouse hover on the "Always on" window makes it move to somewhere else?