Ive read various way on how to detect if a Windows 10 device is in Tablet Mode, most notably the topic below;
How can I detect when Window 10 enters tablet mode in a Windows Forms application?
I would like to enable/disable Tablet Mode through code (.Net C#) but I cant find any resources to achieve this. Ive tried changing the registry key and sending a HWND_BROADCAST that a change has occurred but this doesn't initiate the change to tablet mode.
Ive also tried using Spy++ style applications but cant see the messages being sent.
Does a method exist to do this?
Tablet mode makes Windows 10 more touch-friendly when using your device as a tablet. Select action center on the taskbar (next to the date and time), and then select Tablet mode to turn it on or off.
Solution. Press the Windows key + A to launch Action Center. Click the Tablet Mode quick action tile. Manually turn the tablet mode on or off.
Step 1: In the Run interface, input cmd and click OK. Step 2: Type shutdown /s /f /t 0 in the Command Prompt window and press Enter. Then, your device will shut down immediately. After a few minutes, restart your PC to check if you easily turn off Tablet Mode.
There is no real way to do this in C#. Of course you can change the registry key, but you will need a log off/on to change from or to tablet mode.
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell\TabletMode
Enable: 1 or disable 0
Since I had a problem that my WPF-App will not appear on startup with tablet mode on, I used a AutoHotKey script. You can create a .exe as well. Source: https://autohotkey.com/boards/viewtopic.php?t=15619
#NoEnv
SetBatchLines -1
ListLines Off
#NoTrayIcon
TABLETMODESTATE_DESKTOPMODE := 0x0
TABLETMODESTATE_TABLETMODE := 0x1
TabletModeController_GetMode(TabletModeController, ByRef mode) {
return DllCall(NumGet(NumGet(TabletModeController+0),3*A_PtrSize), "Ptr", TabletModeController, "UInt*", mode)
}
TabletModeController_SetMode(TabletModeController, _TABLETMODESTATE, _TMCTRIGGER := 4) {
return DllCall(NumGet(NumGet(TabletModeController+0),4*A_PtrSize), "Ptr", TabletModeController, "UInt", _TABLETMODESTATE, "UInt", _TMCTRIGGER)
}
ImmersiveShell := ComObjCreate("{C2F03A33-21F5-47FA-B4BB-156362A2F239}", "{00000000-0000-0000-C000-000000000046}")
TabletModeController := ComObjQuery(ImmersiveShell, "{4fda780a-acd2-41f7-b4f2-ebe674c9bf2a}", "{4fda780a-acd2-41f7-b4f2-ebe674c9bf2a}")
if (TabletModeController_GetMode(TabletModeController, mode) == 0)
TabletModeController_SetMode(TabletModeController, mode == TABLETMODESTATE_DESKTOPMODE ? TABLETMODESTATE_TABLETMODE : TABLETMODESTATE_DESKTOPMODE)
ObjRelease(TabletModeController), TabletModeController := 0
ObjRelease(ImmersiveShell), ImmersiveShell := 0 ; Can be freed after TabletModeController is created, instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With