Last active
September 30, 2024 03:32
-
-
Save gustavomdsantos/46f4b4615eeabb2089478cbcc83cda76 to your computer and use it in GitHub Desktop.
AutoHotKey script that make any window Always-on-Top on Windows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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 |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not work for all windows, anybody know why?
e.g. with Dadroit JSON Viewer, this command does not work: