以编程方式启用num Lock [英] Enabling num Lock programatically

查看:111
本文介绍了以编程方式启用num Lock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为使用eVC的内置键盘的PocketPC编写程序,我想知道是否有办法以编程方式激活数字/符号锁定键?实际上,用户必须按两次键盘上的橙色键才能启用锁定功能,我希望能够在我的程序中启用它,这样用户所要做的就是键入数字。谢谢。

I am writing a program for a PocketPC that has a built-in keyboard using eVC, and I was wondering if there was a way to activate the number/symbol lock key programatically? As it is, the user has to push the orange key on the keyboard twice to enable the locking feature, I would prefer to be able to enable it in my program so all the user has to do is type the numbers. Thanks.

以色列布鲁斯特
计算机支持技术
边境飞行服务公司
5245 Airport Industrial Wy
费尔班克斯,AK 99709
(907) 450-7250x293

Israel Brewster
Computer Suport Tech
Frontier Flying Service, Inc.
5245 Airport Industrial Wy
Fairbanks, AK 99709
(907)450-7250x293

推荐答案

我也在WinCe上编程,但我使用的是普通键盘,但我认为,以下也应该和你一起工作:

I'm also programming on WinCe, but I'm using a normal keyboard, but I think, the following should work with you, too:

[ DllImport " coredll.dll" )]

[DllImport("coredll.dll")]

public 静态 extern void keybd_event( int vk, byte bScan, int dwFlags, int dwExtraInfo);

public static extern void keybd_event(int vk, byte bScan, int dwFlags, int dwExtraInfo);

[ < font color ="#008080"size = 2> DllImport " coredll.dll" <字体大小= 2>)]

[DllImport("coredll.dll")]

public < font color ="#0000ff"size = 2> static extern short GetKeyState( int < font size = 2> nVirtKey);

public static extern short GetKeyState(int nVirtKey);

const int VK_NUMLOCK =( int )System.Windows.Forms。 Keys .NumLock ;

const int VK_NUMLOCK = (int)System.Windows.Forms.Keys.NumLock;

const byte KEYEVENTF_KEYUP = 0x0002;

const byte KEYEVENTF_KEYUP = 0x0002;

private static void EnableNumLock()

private static void EnableNumLock()

{

short keystate = GetKeyState(VK_NUMLOCK);

short keystate = GetKeyState(VK_NUMLOCK);

if (keystate == 0)

if (keystate == 0)

{ // Numlock已停用 - >激活它

keybd_event(VK_NUMLOCK,1,0,0);

keybd_event(VK_NUMLOCK, 1, 0, 0);

keybd_event(VK_NUMLOCK,0 ,KEYEVENTF_KEYUP,0);

keybd_event(VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0);

}

}

问候,

Sabine


这篇关于以编程方式启用num Lock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆