Last active
April 8, 2025 01:25
-
-
Save gustavomdsantos/c0d9d01c241e6ab72196a5d9664698a9 to your computer and use it in GitHub Desktop.
Ruindows Workarounds (AHKv2 script) - For a better user experience in Windows. Set "Always on top", laptop monitor brightness, and more.
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
/* | |
Workarounds for a better user experience in Windows. | |
Ruindows = Ruim + Windows | |
*/ | |
#SingleInstance Force | |
;================= VARIABLES =================== | |
ScriptName := "Ruindows Workarounds" | |
ScriptVersion := "v1.8" | |
ScriptHomepage := | |
"https://gist.github.com/gustavomdsantos/c0d9d01c241e6ab72196a5d9664698a9" | |
HelpMsgPt1 := " | |
( | |
HELP AND ABOUT THIS SCRIPT | |
* Ctrl + Shift + " " = Toggle "Always-On-Top" state anywhere. | |
* Ctrl + Win + Numpads 4 or 6 = Switch between workspaces. | |
* Ctrl + Alt + "Arrow" = Block monitor rotation shortcuts. | |
* Win + F2 or F3 = Change laptop monitor brightness. | |
* Win + H = Show this Help window. | |
)" | |
HelpMsgPt2 := " | |
( | |
© 2024-2025 Gustavo Moraes <[email protected]> | |
Do you want to visit the source code webpage and update the script or | |
post a comment on GitHub Gist? | |
)" | |
WrongKeysMsg := " | |
( | |
WARNING! | |
This keyboard shortcut has been blocked on | |
your PC because it rotates your monitor. | |
)" | |
;================= FUNCTIONS =================== | |
HelpFunc() { | |
Result := MsgBox(HelpMsgPt1 . ScriptName . " " . ScriptVersion . HelpMsgPt2, | |
ScriptName, "YesNo") | |
if (result = "Yes") | |
Run ScriptHomepage | |
} | |
HelpFuncCallback(ItemName, ItemPos, MyMenu) { | |
HelpFunc | |
} | |
setSysTray() { | |
TraySetIcon "Shell32.dll", 174 | |
MyMenu := A_TrayMenu | |
MyMenu.Delete("8&") ; Suspend Hotkeys | |
MyMenu.Delete("7&") ; Last Separator | |
MyMenu.Delete("4&") ; Window Spy | |
MyMenu.Delete("2&") ; Help | |
MyMenu.Rename("1&", "Help and About...") | |
MyMenu.Add("1&", HelpFuncCallback) | |
A_IconTip := ScriptName . " " . ScriptVersion . | |
"`nDouble-click to show 'Help and About' window." | |
} | |
AlwaysOnTop() { | |
activeWindow := WinGetTitle("A") | |
try { | |
WinSetAlwaysOnTop -1, activeWindow | |
ToolTip "Switched 'Always-On-Top' state:`n" activeWindow | |
SetTimer () => ToolTip(), -2000 | |
} catch Error as err { | |
ToolTip "Unable to set 'Always-On-Top' state:`n" err.Message | |
SetTimer () => ToolTip(), -2000 | |
} | |
} | |
AdjustScreenBrightness(step) { | |
static service := | |
"winmgmts:{impersonationLevel=impersonate}!\\.\root\WMI" | |
monitors := | |
ComObjGet(service).ExecQuery( | |
"SELECT * FROM WmiMonitorBrightness WHERE Active=TRUE") | |
monMethods := | |
ComObjGet(service).ExecQuery( | |
"SELECT * FROM wmiMonitorBrightNessMethods WHERE Active=TRUE") | |
for i in monitors { | |
curr := i.CurrentBrightness | |
break | |
} | |
toSet := curr + step | |
if (toSet < 10) | |
toSet := 10 | |
if (toSet > 100) | |
toSet := 100 | |
for i in monMethods { | |
i.WmiSetBrightness(1, toSet) | |
ToolTip ("Laptop monitor brightness:`n" . toSet . "%") | |
SetTimer () => ToolTip(), -2000 | |
break | |
} | |
} | |
;==================== MAIN ===================== | |
setSysTray | |
^+SPACE:: AlwaysOnTop | |
^#Numpad4:: Send "^#{Left}" | |
^#Numpad6:: Send "^#{Right}" | |
^!Up:: | |
^!Down:: | |
^!Left:: | |
^!Right:: | |
^!NumpadUp:: | |
^!NumpadDown:: | |
^!NumpadLeft:: | |
^!NumpadRight:: { | |
MsgBox WrongKeysMsg, ScriptName | |
} | |
LWin & F2:: AdjustScreenBrightness(-5) | |
LWin & F3:: AdjustScreenBrightness(5) | |
LWin & h:: HelpFunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment