touch - Windows 8 触摸切换

标签 touch windows-8

在使用数字化笔时,通常需要禁用触摸输入,以避免来自例如屏幕的“噪音”。手放在屏幕上。在 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
               );
            }
        } 
    }
}

最佳答案

在别处找不到答案后,另一种方法是使用 PowerShell 脚本切换适当的设备(如果它与笔不同)。请注意,我尚未测试此解决方案,因为我不想再使用 Windows 8。

您可能需要通过组策略(管理模板 < Windows 组件 < Windows PowerShell)在本地计算机上启用 PowerShell 脚本执行。

首先,为您的机器下载一份“devcon.exe”(来自 Microsoft)。假设“devcon.exe”位于同一目录中,以下脚本然后使用此命令实现预期效果。

$devid = "HID\WACOMVTHID&Col03"

$status = .\devcon status $devid | Select-String "running"

if($status -eq $null) {
  write-host "Enabling touch"
  .\devcon enable $devid
} else {
  write-host "Disabling touch"
  .\devcon disable $devid
}

“devid”参数可以作为设备属性中的“硬件 ID”之一找到。

关于touch - Windows 8 触摸切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12255203/

相关文章:

ios - 上面的 UIView 呈现 SKScene - 为什么触摸总是通过场景?

ios - 除了按钮内部之外的所有地方都禁用触摸? - swift

c# - 如何访问 XAML DataTemplate 中的控件?

windows-8 - 如何在 Windows 8 Metro 应用程序 C# 中将保存缩略图图像存储在设备中

c# - 使用 RichTextBlock 或其他组件在 WinRT 中显示 Html

javascript - 使用 JavaScript 检测硬压 iOS

javascript - 暂时允许使用 TouchSwipe 插件垂直滚动

javascript - Windows 8 应用程序在手指滑动时触发事件

javascript - 解析 html 字符串 Windows 8 javascript 应用程序

c++ - C++ Metro App 教程的编译错误 - 任务继续