DPI

This page uses content or is imported from the abandoned Miraheze counterpart of this page. You can view the original authors of this page here.

== The Sinden Lightgun Wiki Has Moved ==

#### Please visit the new site: https://www.sindenwiki.org/wiki/DPI

For certain emulators/games in Windows having DPI set to anything over 100% and resolution above 1080p can affect bezels and tracking. This AHK can allow you to change resolution and DPI by editing the directory. Add it into your own AHK when launching certain games/emulators.

## WARNING

**WARNING - This AHK edits your registry, use at your own risk!**

## Required User Steps

* First open the Registry (Win + R, enter 'regedit', press return)
* Navigate to HKEY\_CURRENT\_USER\Control Panel\Desktop\PerMonitorSettings\ and take note of the entry. This will relate to your monitor(s), hopefully it will say something like 'ACR' for Acer or SAM for Samsung at the start to match your monitor's brand name).
* Copy the name of the folder and replace both '<monitor entry here>' sections on lines 3 and 23

 File:Regedit.png

## Script Explaination

* The DpiValue section on line 3 sets the DPI to 100% from 150%

*also works for 300% so -2 **should** mean 100% but you may need to experiment*

* Lines 5-17 changes the resolution to 1080p

* Line 23 changes the DPI to the recommended (default) DPI for the monitor. If using the non-recommended DPI you may need to adjust this value.

* Linse 25-37 changes the resolution back to 4K

```
;Set Resolution to 1920x1080 DPI 100%

RegWrite, REG\_DWORD, HKEY\_CURRENT\_USER\Control Panel\Desktop\PerMonitorSettings\<monitor entry here>, DpiValue, -2

ChangeDisplaySettings( (ClrDep:=32) , (Wid:=1920) , (Hei:=1080) , (Hz:=60) )

ChangeDisplaySettings( cD, sW, sH, rR ) {

VarSetCapacity(dM,156,0), NumPut(156,dM,36)

DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)

NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)

Return DllCall( "ChangeDisplaySettingsA", UInt,&dM, UInt,0 )

}

Esc::

;Restore resolution back to 3840x2160 DPI 150%

RegWrite, REG\_DWORD, HKEY\_CURRENT\_USER\Control Panel\Desktop\PerMonitorSettings\<monitor entry here>, DpiValue, 0

ChangeDisplaySettings2( (ClrDep:=32) , (Wid:=3840) , (Hei:=2160) , (Hz:=60) )

ChangeDisplaySettings2( cD, sW, sH, rR ) {

VarSetCapacity(dM,156,0), NumPut(156,dM,36)

DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)

NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)

Return DllCall( "ChangeDisplaySettingsA", UInt,&dM, UInt,0 )

}

```

## Time Crisis 5 Example

You can use these AHK scripts for launching a game/emulator, an example for Time Crisis 5 is below.

* This includes disabling and restoring the second display as well (lines 9 & 85).

Add the code for switching before launching the game/emulator and the switch back after you've closed the game/emulator.

```
#NoEnv

SendMode Input

#SingleInstance Force

;Set screen to Primary Only

RunWait C:\Windows\System32\DisplaySwitch.exe /internal

sleep, 2000

SetWorkingDir D:\Games\Emulation\Time Crisis 5\TC5\Binaries\Win64

;Set Resolution to 1920x1080 DPI 100%

RegWrite, REG\_DWORD, HKEY\_CURRENT\_USER\Control Panel\Desktop\PerMonitorSettings\ACR0460#ASOiujyJugrd\_00\_07DD\_8B^C9976F11F0A22F88CF4AFF8329D38111, DpiValue, -2

ChangeDisplaySettings( (ClrDep:=32) , (Wid:=1920) , (Hei:=1080) , (Hz:=60) )

ChangeDisplaySettings( cD, sW, sH, rR ) {

VarSetCapacity(dM,156,0), NumPut(156,dM,36)

DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)

NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)

Return DllCall( "ChangeDisplaySettingsA", UInt,&dM, UInt,0 )

}

Run, D:\Games\Emulation\DemulShooter\_v10.1.5\demulshooterX64.exe -target=es3 -rom=tc5

sleep, 1000

Run, D:\Games\Emulation\nomousy\nomousy.bat

Run, "D:\Games\Emulation\Time Crisis 5\TC5\Binaries\Win64\start.bat"

RButton::t

1::y

v::<+t

5::<+h

MButton::

WheelUpDown:

Send,{WheelDown 1}

Return

Esc::

Process,Close,TimeCrisisGame-Win64-Shipping.exe

Run,taskkill /im "TimeCrisisGame-Win64-Shipping.exe" /F

run, D:\Games\Emulation\nomousy\nomousy.bat

;Restore resolution back to 3840x2160 DPI 150%

RegWrite, REG\_DWORD, HKEY\_CURRENT\_USER\Control Panel\Desktop\PerMonitorSettings\ACR0460#ASOiujyJugrd\_00\_07DD\_8B^C9976F11F0A22F88CF4AFF8329D38111, DpiValue, 0

ChangeDisplaySettings2( (ClrDep:=32) , (Wid:=3840) , (Hei:=2160) , (Hz:=60) )

ChangeDisplaySettings2( cD, sW, sH, rR ) {

VarSetCapacity(dM,156,0), NumPut(156,dM,36)

DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&dM ), NumPut(0x5c0000,dM,40)

NumPut(cD,dM,104),  NumPut(sW,dM,108),  NumPut(sH,dM,112),  NumPut(rR,dM,120)

Return DllCall( "ChangeDisplaySettingsA", UInt,&dM, UInt,0 )

}

;Restore extended display

RunWait C:\Windows\System32\DisplaySwitch.exe /extend

sleep, 2000

ExitApp

```