描述:
对于 WinCC 对象,您可以组态键盘的按下/释放事件。如果一个键被长时间按下,将会激活自动重复输入,动作将会在按键被按下时一直重复执行。n
为了阻止该动作或者查询哪一个键或组合键被按下,您可以在 C 脚本中使用“ nChar ”及“ nFlags ”参数。
| No. |
描述: |
| 1 |
C 脚本: 在本例中我们查询组合键 Shift - F1 : n
#include "apdefap.h" void OnKeyDown( char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName, UINT nChar, UINT nRepCnt, UINT nFlags) { // If the key is still pressed > no further processing if (nFlags & 0x4000) return; //Request on F1 if (nChar==112) {
if (GetAsyncKeyState(VK_SHIFT) & 0x8000) { printf("SHIFT-F1rn"); // Further instructions... } } } |
| 2 | 用于查询其它键的常量 n
| 描述 |
常量 |
| Shift - Key |
VK_SHIFT |
| Ctrl - Key |
VK_CONTROL |
| AltGr - Key |
KF_ALTDOWN |
| Alt - Key 1) |
VK_MENU |
1) 由于 Alt 键是“系统键”,因此无法对其进行查询。 |
关键字:
重复按键,自动输入
原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc335956.html