当前位置:编程学习 > XML/UML >>

C# 控制小键盘锁 numlock

[DllImport("user32.dll")]
        static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
        const int KEYEVENTF_EXTENDEDKEY = 0x1;
        const int KEYEVENTF_KEYUP = 0x2;
        public Form2()
        {
         
           keybd_event((byte)Keys.NumLock, 0, KEYEVENTF_EXTENDEDKEY, 0);//锁上小键盘
           //  keybd_event((byte)Keys.NumLock, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);//2条语句都可以实现,这2条语句都执行则解锁
        
            InitializeComponent();
       
        }

摘自 Bychentufeiyang的专栏
补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,