Autohotkey script for toggling between resolutions / changing screen resolution in Windows
When recording videos I need to record at one resolution, and when I edit I do so at a different resolution. I’ve been using a very simple autohotkey script for this that I thought might be worth sharing :) Ctrl 8 and Ctrl 9 lets you toggle between two set screen resolutions - you can of course change the script however you want.
If you are new to Autohotkey read: Stupid Question 188-193: What is AutoHotKey, macros, automation software, hotkeys and scripts?
Download autohotkey
Create new text file with script below and save with .ahk extension
Right click on file and run the script
[sourcecode language=“javascript”]
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
^8::
ChangeResolution(1920,1080)
return
^9::
ChangeResolution(1024,768)
return
ChangeResolution(w,h) {
VarSetCapacity(dM,156,0)
NumPut(156,dM,36)
NumPut(0x5c0000,dM,40)
NumPut(w,dM,108)
NumPut(h,dM,112)
DllCall( “ChangeDisplaySettingsA”, UInt,&dM, UInt,0 )
}
[/sourcecode]
Comments
3200x1800* but seriously this is the best script ever. I feel like a 5 year old, it's so easy and fun switching back and forth.
Thanks, that works and I use it to toggle my HTPC (win 7 x64) between HDTV resolution and a sensible VNC desktop size.
Isn't it fun? I have so many tiny little macros left and right now, AHK is awesome!
this was great, thanks
This is an awesome script, so concise! Never again will I have to put up with stupid video game image cropping on my portrait monitor.
Hello, I just stumbled on your page after days of trying to figure out an efficient way of setting screen resolutions using ahk, what a great little script you have there :) . I do have questions if I may. I need to change the scaling so that when selecting 1024x768 it doesn't stretch to 16x9 or when I select 1366x768 it doesn't center rather than scaling to fullscreen. My guess is specifying the scaling will help if possible. I also need to do the same to the external monitor and choose if it's outputing in miror mode or extended desktop. Is it possible using your method? Do you have any idea how? Thanks btw, you are so bookmarked :D
Last modified on 2013-08-15