通过在命令行中启动进程
我相信您想按照建议在 Windows 10 中启动以下过程here https://social.msdn.microsoft.com/Forums/en-US/0e3e1eb6-ad12-455c-84e9-b5a78a893ac4/open-on-screen-keyboard-in-windows-10-via-vba?forum=accessdev:
"C:\Program Files\Common Files\microsoft shared\ink\tabtip.exe"
正如@bernard-vander-beken所建议的,最好使用
Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
生产"C:\Program Files\Common Files\"
适合不同安装位置的路径的一部分。
通过 API
前面的命令行似乎以不一致的方式工作,特别是如果tabtip.exe
进程已经在运行。
我在 @torvin 上找到了这个片段这个线程 https://stackoverflow.com/questions/38774139/show-touch-keyboard-tabtip-exe-in-windows-10-anniversary-edition,您可以使用它以编程方式显示屏幕键盘after你已经开始了tabtip.exe
使用命令行解决方案,否则会失败并显示COM
例外。
class Program
{
static void Main(string[] args)
{
var uiHostNoLaunch = new UIHostNoLaunch();
var tipInvocation = (ITipInvocation)uiHostNoLaunch;
tipInvocation.Toggle(GetDesktopWindow());
Marshal.ReleaseComObject(uiHostNoLaunch);
}
[ComImport, Guid("4ce576fa-83dc-4F88-951c-9d0782b4e376")]
class UIHostNoLaunch
{
}
[ComImport, Guid("37c994e7-432b-4834-a2f7-dce1f13b834b")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface ITipInvocation
{
void Toggle(IntPtr hwnd);
}
[DllImport("user32.dll", SetLastError = false)]
static extern IntPtr GetDesktopWindow();
}