3
当使用数字转换笔以避免例如来自例如笔记本的“噪音”时,通常需要禁用触摸输入。手搁在屏幕上。存在一个程序化解决方案来禁用触摸 - 但在Windows 7中维护笔输入,这会更改TouchGate注册表值并广播系统消息;似乎后者在Windows 8中失败了。Windows 8触摸切换
有谁知道如何更新Windows 8的代码/替代解决方案(请注意,我的系统不允许我通过控制面板GUI禁用触摸输入)。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Touch_Toggle
{
class Program
{
static void Main(string[] args)
{
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser;
regKey = regKey.OpenSubKey(@"Software\Microsoft\Wisp\Touch", true);
string currKey = regKey.GetValue("TouchGate").ToString();
if (currKey == "1")
regKey.SetValue("TouchGate", 0x00000000);
else
regKey.SetValue("TouchGate", 0x00000001);
regKey.Close();
User32Utils.Notify_SettingChange();
}
internal class User32Utils
{
#region USER32 Options
static IntPtr HWND_BROADCAST = new IntPtr(0xffffL);
static IntPtr WM_SETTINGCHANGE = new IntPtr(0x1a);
#endregion
#region STRUCT
enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0000,
SMTO_BLOCK = 0x0001,
SMTO_ABORTIFHUNG = 0x2,
SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
}
#endregion
#region Interop
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr SendMessageTimeout(
IntPtr hWnd,
uint Msg,
UIntPtr wParam,
UIntPtr lParam,
SendMessageTimeoutFlags fuFlags,
uint uTimeout,
out UIntPtr lpdwResult
);
#endregion
internal static void Notify_SettingChange()
{
UIntPtr result;
SendMessageTimeout(
HWND_BROADCAST,
(uint)WM_SETTINGCHANGE,
UIntPtr.Zero,
UIntPtr.Zero,
SendMessageTimeoutFlags.SMTO_NORMAL,
1,
out result
);
}
}
}
}