Iris Classon
Iris Classon - In Love with Code

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.

screen

If you are new to Autohotkey read: Stupid Question 188-193: What is AutoHotKey, macros, automation software, hotkeys and scripts?

  1. Download autohotkey

  2. Create new text file with script below and save with .ahk extension

  3. 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

Leave a comment below, or by email.
damo
8/7/2014 7:28:18 PM
#1, You've solved a problem that's been really pissing me off with my yoga2pro. It's got a 3000x1920 display that makes illustrator look like it's a million miles away. But on the resolution setting below that, everything else is HUGE. 
#2 You're stunning :) 
damo
8/7/2014 7:34:52 PM
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. 
Pedro
8/12/2014 12:10:53 AM
Thanks, that works and I use it to toggle my HTPC (win 7 x64) between HDTV resolution and a sensible VNC desktop size. 
Iris Classon
8/24/2014 3:19:57 PM
Reply to: damo
Isn't it fun? I have so many tiny little macros left and right now, AHK is awesome! 
Iris Classon
8/24/2014 3:20:28 PM
Reply to: damo
#1 Thank you
#2 Thank you 
foobarff
9/10/2014 9:21:20 PM
this was great, thanks 
Robert
11/25/2014 11:42:06 AM
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. 
Claude Rivet
8/7/2015 6:54:15 AM
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

comments powered by Disqus