0

In 2-in-1 laptop/tablets, Windows 10 and 11 can recognize with onboard hardware sensors when a display is folded back which triggers tablet conversion.

I want my display scaling to be 200% for desktop mode and 225% for tablet mode so that the UI elements get easy to click on touch-screen.

I'm looking for a program/script/system tweak which can automatically set the display scaling depending on the current mode.

2 Answers 2

1

I was able to write a C++ program with this functionality which is working perfectly as I expected. I used the open source tool SetDPI mentioned in previous answer to set the DPI for the main display. Usage: SetDPI.exe [monitor no] [DPI scale value]

#include <Windows.h>
#include <cstdlib>

bool isTabletMode() {
    return GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0;
}
void setTabletScaling() {
    WinExec("C:\\Programs\\SetDpi.exe 1 225", SW_HIDE);
}
void setDesktopScaling() {
    WinExec("C:\\Programs\\SetDpi.exe 1 200", SW_HIDE);
}
int main() {
    bool currentMode, lastMode = isTabletMode();
    while (true) {
        currentMode = isTabletMode();
        if (currentMode && !lastMode) {
            setTabletScaling();
        } 
        else if (!currentMode && lastMode) {
            setDesktopScaling();
        }
        lastMode = currentMode;
        Sleep(5000);
    }
    
    return 0;
}
0

Here is a solution that uses the free AutoHotkey.

The following example script will loop, checking the registry key for the mode every second, and will set the DPI accordingly. As I'm not using a tablet, I couldn't fully test the script.

It uses the open-source project of SetDPI. You should download the utility from the Release page. In my test script, this is located in C:\Temp\SetDpi.exe.

I also assume that this refers to your primary monitor, which is the first monitor, so numbered 1.

#Persistent
lastmode = -1
SetTimer, checkmode, 1000
return

checkmode:
RegRead, mode, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell, TabletMode
if mode = lastmode
  return
if mode = 0
  Run, C:\Temp\SetDpi.exe 1 200, , Hide    ; desktop mode
else
  Run, C:\Temp\SetDpi.exe 1 225, , Hide    ; tablet mode
lastmode = mode
return

If instead of a loop, you prefer using hotkeys to change the DPI, use the following simplified script, where F11 sets the DPI to 200 and F12 to 225:

F11::Run, C:\Temp\SetDpi.exe 1 200, , Hide
F12::Run, C:\Temp\SetDpi.exe 1 225, , Hide

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Useful AutoHotkey documentation:

2
  • Yes, I have only one display. Unfortunately, your first code (without hotkey) doesn't work. Maybe the way you tried to detect desktop/tablet mode doesn't work. Commented Jan 5, 2023 at 5:37
  • Strange. I checked, and there are dozens of sources to be found that point to this registry item as the indicator for Tablet Mode. Perhaps this has changed. For future readers, here is an alternative AutoHotKey script.
    – harrymc
    Commented Jan 5, 2023 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .