AHK

From Sinden Lightgun
Revision as of 04:35, 10 January 2021 by sindenlightgun>Overboardkiller
Jump to navigation Jump to search

Auto Hot Key (AHK) is small but powerful automation scripting language for windows.

In this Quick video I demonstrate how to install AHK and create your first script. All AHK commands can be found here if you are creating your own scripts: https://www.autohotkey.com/docs/AutoHotkey.htm

Change DPI AHK

Script to change Res and DPI settings.(Windows 10, Windows 7 Not tested.)

 1#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
 2SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
 3
 4#SingleInstance force 
 5
 6!#PgDn::
 7RegWrite, REG_DWORD, HKEY_CURRENT_USER\Control Panel\Desktop\PerMonitorSettings\ACR0408#ASNmpEVZnard_00_07DD_A1^1977EFB0FCDDA00B4A190B2C0A4C2256, DpiValue, 1
 8ChangeResolution(2560, 1440)
 9Return
10
11!#PgUp::
12RegWrite, REG_DWORD, HKEY_CURRENT_USER\Control Panel\Desktop\PerMonitorSettings\ACR0408#ASNmpEVZnard_00_07DD_A1^1977EFB0FCDDA00B4A190B2C0A4C2256, DpiValue, 0
13ChangeResolution(2560, 1440)
14Return
15
16ChangeResolution(Screen_Width := 2560, Screen_Height := 1440, Color_Depth := 32)
17{
18	VarSetCapacity(Device_Mode,156,0)
19	NumPut(156,Device_Mode,36) 
20	DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&Device_Mode )
21	NumPut(0x5c0000,Device_Mode,40) 
22	NumPut(Color_Depth,Device_Mode,104)
23	NumPut(Screen_Width,Device_Mode,108)
24	NumPut(Screen_Height,Device_Mode,112)
25	Return DllCall( "ChangeDisplaySettingsA", UInt,&Device_Mode, UInt,0 )
26}
27Return

This scripts helps change DPI and Resolution of your monitor in windows 10. Some games need the DPI to be 100% or the gun will not work

lets talk through this script

Line 6: this is the hotkey to change enable the change (currently set to ! (ALT) + # (WinKey) + PageDown

Line 7: "ACR0408#ASNmpEVZnard_00_07DD_A1^1977EFB0FCDDA00B4A190B2C0A4C2256" is the name of my monitor this will need to be changed to your monitor name This can be found here

ChangeDPIMonitorName.png

The DPIValue are the following 0 = 100%, 1 = 125%, 2= 150%, 3= 175% and 4= 200%

Line 8: this is for your Resalution settings

Line 11 to 14 are the same as above You need to change these settings also

Line 18 to 25: you don't need to change anything here. This just changes the settings and applies them. If this isn't here the regedit would not change anything


NOTE if you have 2 or more monitors you will need to choose one under HKEY_CURRENT_USER\Control Panel\Desktop\PerMonitorSettings\ and do a trail and error. I don't know how windows makes this reg folder for the display name.

Do don't have to use a key bind to call the script you can put in before your load your rom. You need to change the Reg file before calling the change res.