デジタイザ ペンを使用している場合は、タッチ入力を無効にして、画面に手を置くなどの「ノイズ」を避ける必要があることがよくあります。Windows 7 では、タッチを無効にするがペン入力を維持するためのプログラムによる解決策が存在します。これは、TouchGate レジストリ値を変更し、システム メッセージをブロードキャストします。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
);
}
}
}
}