以编程方式关闭 Windows 虚拟触摸板/触控板

Programmatically toggling off the Windows Virtual Touchpad / Trackpad

我试图弄清楚如何通过 C++/# 或 Windows 脚本以编程方式启动 Windows 10 附带的新虚拟触摸板,这应该是通用的 Windows平台应用

经过一些注册表黑客攻击后,我发现我可以利用 launch behavior with registered protocols 启动触摸板,如下所示:

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

我在这个键找到了这个信息:

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}"

(Default)值为REG_EXPAND_SZ:"%SystemRoot%\system32\LaunchWinApp.exe" "%1"

DelegateExecute 与此密钥相关:

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"

(Default)值为REG_EXPAND_SZ:%SystemRoot%\system32\twinui.pcshell.dll

因此,对于我的非 UWP 应用程序或脚本,我已将其启用。然后问题就变成了关闭它。因此,如果它是一个 UWP 应用程序,我假设我需要让它处于挂起状态,或者以某种方式发送它终止。

我能看到的关于 LaunchWinApp 的文档不多,我也没有注意到任何与 Close/Suspend/Terminate.

我可以通过其他方式启动虚拟触摸板,但据我所知,目前还没有关于以编程方式启动虚拟触摸板的问答。

我应该如何进行?

这里有一个 C++ 工作代码示例,用于打开触摸板,关闭任何感兴趣的人。我相信您需要一个支持触摸的显示器才能让触摸板真正出现。我一直无法在我的非接触式桌面上运行它。

#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,抱歉回复晚了。

我终于可以启动 ms-virtualtouchpad 了。原因是我的设备在 x64 OS 上是 运行,我的 x86 程序应该访问 C:\Windows\Sysnative 下的 LaunchWinApp.exe,而不是 here 所说的 C:\Windows\System32。这样就可以了!感谢您事先的研究!