织梦CMS - 轻松建站从此开始!

罗索实验室

当前位置: 主页 > 嵌入式开发 > Windows CE >

Simulate key/pen input in Windows CE/Mobile

jackyhwei 发布于 2011-10-10 09:13 点击:次 
在Windows CE/Windows Mobile/Windows上模拟键盘和模拟鼠标输入
TAG:

APIs:

SendInput API ( it can take place of keybd_event, and mouse_event)

  http://msdn.microsoft.com/en-us/library/ms961447.aspx

Mouse Input:

  http://msdn.microsoft.com/en-us/library/ms931454.aspx

keybd_event API:

  http://msdn.microsoft.com/en-us/library/aa453245.aspx

Virtual Key code:

  http://msdn.microsoft.com/en-us/library/ms927178.aspx

Reference web page:

1. http://www.armce.com/bbs/archiver/tid-195.html

2. http://www.cnblogs.com/iVincentFeng/archive/2010/04/20/KeyboardInputSimulation_SendMessage_keybd_event_PostKeybdMessage.html

3. http://www.cnblogs.com/edobnet/archive/2004/06/09/14334.aspx

4. http://topic.csdn.net/t/20040626/16/3125079.html

Samples:

// work in Windows Mobile/Windows/CE

void MouseClickAt(int g_x,int g_y)
{
        tagINPUT Inputs[2];

        int dx = g_x * 65535 / 800;  //把实际坐标换算成为绝对坐标,0-65535
        int dy = g_y * 65535 / 600;
       
        Inputs[0].type = INPUT_MOUSE;
        Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
        Inputs[0].mi.dx = dx;
        Inputs[0].mi.dy = dy;
        Inputs[0].mi.mouseData = 0;
        Inputs[0].mi.time = 0;

        Inputs[1].type = INPUT_MOUSE;
        Inputs[1].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP;
        Inputs[1].mi.dx = dx;
        Inputs[1].mi.dy = dy;
        Inputs[1].mi.mouseData = 0;
        Inputs[1].mi.time = 0;

        SendInput(2,Inputs,sizeof(tagINPUT));
}

void MouseClickAt2(int g_x,int g_y) 

// g_x, g_y are in screen coordinate
{
                //直接执行设定
                SetCursorPos(g_x, g_y);
                mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                mouse_event(MOUSEEVENTF_LEFTDOW, 0, 0, 0, 0);
}

(xgzhang )
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www1.rosoo.net/a/201110/15104.html]
本文出处:blog.sina.com.cn/xgzhang  作者:xgzhang
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容