zoukankan      html  css  js  c++  java
  • Windows Mobile 中模拟按键

    在Windows Mobile 中模拟按键有时是非常有用的,比如我们可以发送Tab键使输入焦点自动跳转到下一个输入框。在Windows Form程序中,我们可以调用SystemCalls.SendKey()来实现,但不幸的是在.net framework ce中却没有SystemCalls这个类。在网上找到实现这个功能的代码,分享一下。

     class SystemCalls
        {
            
    public const byte VK_NONAME = 0xFC// 什么也不做

            
    public const byte VK_ESC = 0x1B// Smartphone的回退键

            
    public const byte VK_F4 = 0x73// Home Screen

            
    public const byte VK_APP6 = 0xC6// Smartphone上锁定键盘

            
    public const byte VK_F22 = 0x85// PocketPC上锁定键盘 (VK_KEYLOCK)

            
    public const byte VK_F16 = 0x7F// 出发扬声器

            
    public const byte VK_OFF = 0x7F//电源键

            
    public const byte VK_TAB = 0x09//Tab键

            
    /// <summary>

            
    /// 将按键送至全局键盘缓冲区

            
    /// </summary>

            
    /// <param name="key"></param>

            
    public static void SendKey(byte key)
            {

                
    //const byte KEYEVENTF_SILENT = 0x0004;

                
    const int KEYEVENTF_KEYUP = 0x02;

                
    const int KEYEVENTF_KEYDOWN = 0x00;

                keybd_event(key, 
    0, KEYEVENTF_KEYDOWN, 0);

                keybd_event(key, 
    0, KEYEVENTF_KEYUP, 0);

            }

            [DllImport(
    "coredll", SetLastError = true)]

            
    private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

        }
  • 相关阅读:
    解决Android SDK Manager更新、下载速度慢
    selenium报错以及各解决方法
    webdriver对各种浏览器的支持
    selenium driver版本和Chrome浏览器版本对应关系
    selenium web driver
    js中变量注意事项
    js选项卡实现
    两种JS方法实现斐波那契数列
    三种JS方法确定元素在数组中的索引值
    javascript内置属性——arguments
  • 原文地址:https://www.cnblogs.com/glacierh/p/1374272.html
Copyright © 2011-2022 走看看