Last active
February 24, 2024 08:30
-
-
Save sampollard/9548908ac084c40f56458676f1ac5b2f to your computer and use it in GitHub Desktop.
Add some convenience keybindings
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
; How to view scancodes in AHK v1 (I can't figure this out for v2) | |
; Right-click, "run this script" on this file (not the .exe) | |
; Right click and select "Open" | |
; View -> Key History and Script Info | |
; Now you can type things, press F5 to refresh; they appear bottom-up | |
SendMode("Input") ; Tutorials say this is good | |
Capslock::LCtrl ; Map Capslock to Control | |
RCtrl & Capslock::Capslock ; Map Right control + Capslock to Capslock | |
; Hibernate on ctrl+alt+win+h | |
; On Razer blades, the power button default is sleep | |
; Docs: https://learn.microsoft.com/en-us/windows/win32/api/powrprof/nf-powrprof-setsuspendstate | |
^#!h::{ | |
DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0) | |
} | |
ns := 0 | |
^#!n::{ | |
global ns := !ns | |
if (ns) { | |
MsgBox "Preventing sleep.", "Ctrl-Alt-Win-N to cancel" | |
SetTimer UselessKey, 60*1000 | |
} else { | |
MsgBox "Sleep back to default", "Sleep", "T1" | |
SetTimer UselessKey, 0 ; 0 instead of "Off" for v1 | |
} | |
} | |
; Can query refreshrate with | |
; wmic PATH Win32_videocontroller get currentrefreshrate | |
; Another potentially useful link | |
; https://www.reddit.com/r/ultrawidemasterrace/comments/ogkiho/autohotkey_script_for_quickly_changing/ | |
; Set Refresh rate to 165Hz (f = fast) | |
psfast := "C:\Path\to\165hz.ps1" | |
psslow := "C:\Path\to\60hz.ps1" | |
^#!f::{ | |
RunWait("powershell -ExecutionPolicy Bypass -Windowstyle Hidden -File " . psfast) | |
MsgBox "Refresh rate set to 165Hz", "165Hz", "T1" | |
} | |
; Set Refresh rate to 60Hz (r = really slow) | |
^#!r::{ | |
RunWait("powershell -ExecutionPolicy Bypass -Windowstyle Hidden -File " . psslow) | |
MsgBox "Refresh rate set to 60Hz", "60Hz", "T1" | |
} | |
; Any key that is unbound | |
UselessKey() | |
{ | |
Send("{F15}") | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to get this working, you need two files: 165hz.ps1 and 60hz.ps1 (adjust accordingly for other refresh rates).
The steps are as follows:
xxxHz.ps1
are locatedNOTES:
Here is 60hz.ps1, to get other hz rename the file and change the last line. It would be much more convenient to just call the Set-ScreenRefreshRate 60 inside autohotkey or wherever, but to do that you first have to source the file, i.e.
. 60Hz.ps1
(the one thing that seem to be shared between POSIX shells and powershell). But I don't know how to do that in advance of autohotkey running, and you're not going to be switching between many refresh rates in any case.