Two AHK scripts to easily change your Monitor's DPI Scaling

3 min read 4 hours ago
Published on Jan 20, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial provides a step-by-step guide on how to use AutoHotkey (AHK) scripts to change your monitor's DPI scaling easily. By assigning hotkeys for different scaling settings, you can enhance your screen experience, especially useful during screen sharing or video production. This method eliminates the need for manual adjustments, allowing for a more streamlined workflow.

Step 1: Set Up AutoHotkey

  1. Download AutoHotkey: If you haven't already, download and install AutoHotkey from autohotkey.com.
  2. Create a New Script:
    • Right-click on your desktop or in a folder.
    • Select "New" > "AutoHotkey Script."
    • Name your script file (e.g., MonitorDPIScaling.ahk).

Step 2: Write the AHK Scripts

You will need two scripts to manage DPI scaling effectively.

Script 1: Active Monitor Scaling

This script allows you to change the DPI scaling on the monitor where your mouse is currently located.

; Script to change DPI scaling on the active monitor
; Assign hotkeys for different DPI settings

^!1:: ; Ctrl + Alt + 1 for 100% DPI
   SetDPI(100)
return

^!2:: ; Ctrl + Alt + 2 for 125% DPI
   SetDPI(125)
return

^!3:: ; Ctrl + Alt + 3 for 150% DPI
   SetDPI(150)
return

SetDPI(dpi) {
   ; Function to set the DPI scaling
   Run, DisplaySwitch.exe /setdpi %dpi%
}

Script 2: Specific Monitor Scaling

This script allows you to specify which monitor to adjust.

; Script to change DPI scaling for a specific monitor
; Assign hotkeys for different monitors

^!4:: ; Ctrl + Alt + 4 for Monitor 1 at 100% DPI
   SetMonitorDPI(1, 100)
return

^!5:: ; Ctrl + Alt + 5 for Monitor 2 at 125% DPI
   SetMonitorDPI(2, 125)
return

SetMonitorDPI(monitor, dpi) {
   ; Function to set the DPI scaling for a specified monitor
   Run, DisplaySwitch.exe /monitor %monitor% /setdpi %dpi%
}

Step 3: Test Your Scripts

  1. Run Your AHK Script: Double-click your script file to run it.
  2. Use Hotkeys: Press the assigned hotkeys (e.g., Ctrl + Alt + 1, Ctrl + Alt + 2, etc.) to test the DPI changes on your monitors.
  3. Check Results: Observe the changes in DPI scaling to ensure they work as intended.

Practical Tips

  • Adjust Hotkeys: Feel free to change the hotkey combinations to ones that suit your preferences better.
  • Monitor Configuration: Make sure you know the monitor numbers if you are using the specific monitor scaling script.
  • Common Pitfalls: Ensure that the AHK script is running in the background while you attempt to use the hotkeys. If it doesn't seem to work, check for any conflicting applications that may also use hotkeys.

Conclusion

Using AutoHotkey scripts to manage your monitor's DPI scaling can significantly enhance your productivity and ease of use. With just a few hotkeys, you can switch between settings seamlessly. Try experimenting with different DPI settings based on your needs—especially useful for screen sharing or presentations. For further customization, explore additional AHK commands and scripts to optimize your workflow.