注意对于下面参数dwFlags的描述。
遇到按钮只出发一次的问题:
这个参数的值是可以进行 | 运算的,如果只输入一个值,按钮的状态不会自动改变回为被触发的状态,需要编写代码的时候去主动切换按钮的状态。或者在传入时就进行 | 运算。
在Microsoft手册中有更详细的例子。
Syntax
C++
void keybd_event(
BYTE bVk,
BYTE bScan,
DWORD dwFlags,
ULONG_PTR dwExtraInfo
);
Parameters
bVk
Type: BYTE
A virtual-key code. The code must be a value in the range 1 to 254. For a complete list, see Virtual Key Codes.
bScan
Type: BYTE
A hardware scan code for the key.
dwFlags
Type: DWORD
Controls various aspects of function operation. This parameter can be one or more of the following values.
Table 1
Value Meaning
KEYEVENTF_EXTENDEDKEY
0x0001
If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
KEYEVENTF_KEYUP
0x0002
If specified, the key is being released. If not specified, the key is being depressed.
dwExtraInfo
Type: ULONG_PTR
An additional value associated with the key stroke.
Return value
None
https://baike.baidu.com/item/keybd_event/6372528?fr=aladdin 百度百科部分
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-keybd_event Microsoft手册
============================
其它资料整理:
导入命名空间
using System.Diagnostics
使用C#的Process.Start()执行
Process对象调用Kill()关闭
windows软键盘:
C:\Windows\System32\osk.exe
windows触摸键盘:
C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe
如何调用触摸键盘:
https://blog.csdn.net/qq_26355993/article/details/80228695