虚拟键盘CTRL + A. [英] Virtual keyboard CTRL+A

查看:130
本文介绍了虚拟键盘CTRL + A.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用visual C#并尝试自动按CTRL + A按钮组合。

I am using visual C# and trying to make automation press CTRL+A button combination.

我正在使用此代码:

keybd_event(A, 0, KEYEVENTF_EXTENDEDKEY, 0);
    Task.Delay(TimeSpan.FromMilliseconds(100)).Wait();
    keybd_event(ctrl, 0, KEYEVENTF_KEYUP, 0);
    keybd_event(A, 0, KEYEVENTF_KEYUP, 0);

变量

public const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag
public const int KEYEVENTF_KEYUP = 0x0002; //Key up flag
public const int A = 0x41; //A key code
public const int ctrl = 0xA2; //ctrl key code


但是当程序执行代码时,它始终按下CTRL按钮。我不知道为什么不释放它。如果我按下并释放键盘上的右CTRL按钮。什么时候发布。也许知道如何解决这个问题?

But when program executed code it all time leave pressed CTRL button. I don't know why don't release it. If I press and release right CTRL button in my keyboard. When it release. Maybe know how solve this problem?

推荐答案

你好pcwortex,

Hi pcwortex,

以下文件还提供关于CTRL + A的示例

The following document also provide a sample about CTRL+A

// Simulating a Ctrl+A keystroke
keybd_event(VK_CONTROL,0x9d,0 , 0); // Ctrl Press
keybd_event(VkKeyScan('A'),0x9e,0 , 0); // ‘A’ Press
keybd_event(VkKeyScan('A'),0x9e, KEYEVENTF_KEYUP,0); // ‘A’ Release
keybd_event(VK_CONTROL,0x9d,KEYEVENTF_KEYUP,0); // Ctrl Release

https://www.codeproject.com/Articles/7305/Keyboard-Events-Simulation-using-keybd-event-funct

祝你好运,

张龙


这篇关于虚拟键盘CTRL + A.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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