2

I was trying to figure out how to programmatically via C++/# or Windows scripts launch the new Virtual Touchpad that comes with Windows 10, which is supposed to be a Universal Windows Platform app.

After some registry-hacking, I figured out I could launch the Touchpad leveraging launch behavior with registered protocols, like so:

"%SystemRoot%\system32\LaunchWinApp.exe" "ms-virtualtouchpad:"

I found this information at this key:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ms-virtualtouchpad]
@="URL:Virtual Touchpad"
"EditFlags"=dword:00200000
"URL Protocol"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ms-virtualtouchpad\Shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ms-virtualtouchpad\Shell\Open]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ms-virtualtouchpad\Shell\Open\Command]
@=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4c,00,\
  61,00,75,00,6e,00,63,00,68,00,57,00,69,00,6e,00,41,00,70,00,70,00,2e,00,65,\
  00,78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,00,00
"DelegateExecute"="{54058896-4775-4C34-8B62-789FB2E263A4}"

Its (Default) value is REG_EXPAND_SZ:"%SystemRoot%\system32\LaunchWinApp.exe" "%1"

That DelegateExecute is related to this key:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{54058896-4775-4C34-8B62-789FB2E263A4}]
@="VirtualTouchpadFlow Class"

[HKEY_CLASSES_ROOT\CLSID\{54058896-4775-4C34-8B62-789FB2E263A4}\InProcServer32]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,74,00,77,00,\
  69,00,6e,00,75,00,69,00,2e,00,70,00,63,00,73,00,68,00,65,00,6c,00,6c,00,2e,\
  00,64,00,6c,00,6c,00,00,00
"ThreadingModel"="Both"

Its (Default) value is REG_EXPAND_SZ:%SystemRoot%\system32\twinui.pcshell.dll

So for my non-UWP app or script, I've got enabling it down. The issue then becomes toggling it off. So if it's a UWP app, I'm assuming I need to get it in either the Suspend state, or somehow send it terminate.

There's not much documented for LaunchWinApp that I can see, and I haven't noticed anything similarly named for Close/Suspend/Terminate.

I'm fine launching the Virtual Touchpad another way, but as far as I can tell, there's no currently existing Q&A on even launching that programmatically.

How should I proceed?

kayleeFrye_onDeck
  • 5,531
  • 5
  • 56
  • 62
  • You should just be able to [`ShellExecuteEx`](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762154(v=vs.85).aspx) the custom URI, then terminate the process later. Not that this is necessarily a good idea... – Peter Torr - MSFT Oct 18 '17 at 03:11
  • How is that possible, @PeterTorr-MSFT? I may have misunderstood your intent of instruction. `LaunchWinApp.exe` is the process being used to launch the UWP app, but LaunchWinApp does not persist, and the somewhat-masked generated processes (like COM Surrogates) don't toggle off the Windows Virtual Touchpad after killing them. – kayleeFrye_onDeck Oct 18 '17 at 20:30
  • You should be able to execute any registered scheme handler. On my machine I tried `Start -> Run -> ms-virtualtrackpad:` and nothing happened, but then I don't have a touchscreen on this PC. I don't see this documented, so it's probably not going to be supported anyway. Consider providing feedback at http://wpdev.uservoice.com – Peter Torr - MSFT Nov 04 '17 at 00:57
  • @PeterTorr-MSFT I eventually found the window and class name via Spy++, and close it using `SendMessage` with Win32 APIs. – kayleeFrye_onDeck Nov 04 '17 at 01:07

2 Answers2

2

Here's a C++ working code sample for toggling the touchpad open, the closed for anyone interested. I believe you need a touch-enabled display for the touchpad to actually come up. I've been unable to get it working on my touchless desktop.

#include <Windows.h>
#include <iostream>

int main()
{    
    ShellExecute(0, 0, "ms-virtualtouchpad:", 0, 0, SW_HIDE);
    Sleep(1500);

    HWND uwp_wnd = HWND();
    uwp_wnd = FindWindowEx(0, uwp_wnd, "ApplicationFrameWindow", 0);
    if (uwp_wnd)
    {
        HWND tpad_wnd = HWND();

        tpad_wnd = FindWindowEx(uwp_wnd, tpad_wnd, "Windows.UI.Core.CoreWindow", "Windows Shell Experience Host");
        if (tpad_wnd != 0)
        {
            SendMessage(tpad_wnd, WM_CLOSE, 0, 0);
            return 0;
        }
    }

    return 1;
}
kayleeFrye_onDeck
  • 5,531
  • 5
  • 56
  • 62
  • 1
    I can't run (toggle on) the virtualtouchpad by this code, but hiding/closing it works. – Jeff T. May 08 '18 at 08:26
  • 1
    The `ShellExecute(0, 0, "ms-virtualtouchpad:", 0, 0, SW_HIDE);` doesn't work for me. – Jeff T. May 08 '18 at 08:27
  • @JeffT. can you please tell me what version of Windows you're using? I thought this stopped working when RedStone 3 went live, but I just rebuilt and ran this successfully on RS3, Version 1709 (OS Build 16299.371) ; you can get this info quickly by running `winver` – kayleeFrye_onDeck May 08 '18 at 23:34
  • Hi @kayleeFrye_onDeck, I run it on OS Build 16299.371, but it still doesn't work though. I've tried `WinExec()` and `system()` as well. Both didn't work, even I ran a bat script which includes `start ms-virtualtouchpad:`. – Jeff T. May 09 '18 at 04:02
  • But if I manually click to run a bat script which includes `start ms-virtualtouchpad:`, it can be launched. Don't know how Windows 10 prevents users from launching it programmatically. – Jeff T. May 09 '18 at 04:03
  • is there a real touchpad in your laptop ? If your device is a full-screen pad (like ipad) without a real touchpad, the result might be different, I guess. Because my device is just a pad, there is no `Touchpad` name shown in the `Settings/Devices` unless I've launched the virtual touchpad manually. – Jeff T. May 09 '18 at 04:29
  • @JeffT. it's a proprietary piece of HW that my company uses; it's not really a traditional touchpad, it's more like a soft touch-screen, connected to a PC. I know that my PC at home can't do this, as it can't even launch the Touchpad, as there's no touch-eligible devices. I didn't know about device-specific issues with this usage, but it's good to know about! Just curious, did you try the sample as-written? I'd be interested to know where in the code it stops working as-expected. – kayleeFrye_onDeck May 09 '18 at 05:43
0

@KayleeFrye_onDeck, sorry for late reply.

Finally I can launch the ms-virtualtouchpad. The reason is my device was running on x64 OS, my x86 program should access LaunchWinApp.exe under C:\Windows\Sysnative instead of C:\Windows\System32 as here said. So that works ! Thank you for your research beforehand !

Jeff T.
  • 1,753
  • 23
  • 29