Last active
September 3, 2023 06:29
-
-
Save orazdow/8479a5af2a4649edf106471916c127d5 to your computer and use it in GitHub Desktop.
ahk script: winontop, hidebar, nightlight
This file contains hidden or 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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
; #Warn ; Enable warnings to assist with detecting common errors. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
; SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
; #NoTrayIcon | |
#Persistent | |
Menu, Tray, Tip ,alt-l nightlight`nctl-alt-b hidebar`nctl-alt-up winontop | |
;*********** Ctl-Alt-b : hide/show taskbar ****************; | |
^!b:: HideShowTaskbar(hide := !hide) | |
HideShowTaskbar(action) { | |
static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2 | |
VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0) | |
NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize) | |
NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize) | |
DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA) | |
} | |
;*********** Alt-l : open night light *********************; | |
!l:: Run, ms-settings:nightlight | |
;*********** Ctl-Alt-Up : pin window on top ***************; | |
^!Up:: | |
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 file contains hidden or 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
#NoEnv | |
SendMode Input | |
#Persistent | |
; #NoTrayIcon | |
Menu, Tray, Tip ,alt-l: nightlight`nctl-alt-up: winontop | |
;Menu, Tray, Tip ,alt-l nightlight`nctl-alt-b hidebar`nctl-alt-up winontop | |
;*********** Alt-l : open night light *********************; | |
!l:: Run, ms-settings:nightlight | |
;*********** Ctl-Alt-Up : pin window on top ***************; | |
^!Up:: Winset, Alwaysontop, , A | |
;;*********** Ctl-Alt-b : hide/show taskbar ****************; | |
;^!b:: HideShowTaskbar(hide := !hide) | |
;HideShowTaskbar(action) { | |
; static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2 | |
; VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0) | |
; NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize) | |
; NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize) | |
; DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA) | |
;} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment