Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 8 Monaten
Letzter Beitrag:
vor 1 Jahr, 8 Monaten
Beteiligte Autoren:
Curtis, Sascha77, Fabrice Harari, Arie

[WD20] Trapping Keyboard Events

Startbeitrag von Curtis am 11.11.2016 18:17

Does anyone have any code they want to share that traps and suppresses certain keyboard events such as Alt+F4 and the Windows key?

Right now I'm trying to use Event(), but I'm not sure how to detect key combinations in my event procedure. I'm also not sure how to suppress or cancel the key combination.


Hi Curtis,

if it's only one specific sequence, you can just create a button using it as shortcut and do nothing in it.
Otherwise, you'll need two event, one for the regular keys, the other for the system keys.
As for the transformer keys (shift/ctrl/alt), you just test them with the keypressed function in yor event code (ie you receive he event for F4 in the syskey event, and you check that alt is pressed (and not shift) by example

Best regards

von Fabrice Harari - am 11.11.2016 19:49
TrapSystemKeys() is not being called. Any ideas?


PROCEDURE TrapSystemKeys(AMessage, wParam, lParam)

//VK_LWIN is int = 0x5b
//nKey is int = VK_LWIN // Left Windows Key

// Checks whether left Windows Key was pressed
IF KeyPressed(VK_LWIN) _OR_ KeyPressed(VK_RWIN) THEN
// Insert the process to perform

von Curtis - am 11.11.2016 20:24


PROCEDURE TrapKeys(aMessage, wParam, lParam)

IF wParam = VK_LWIN OR wParam = VK_RWIN THEN

PROCEDURE TrapSystemKeys(aMessage, wParam, lParam)

IF wParam = VK_LWIN OR wParam = VK_RWIN THEN

If I press the windows key it actually goes into the TrapKeys procedure. I thought the windows key was a system key. It gets to the RETURN line, but this does not stop the windows start menu from displaying. Once I'm inside my procedure how do I stop the display of the start menu?

EDIT: Looks like I'm going to have to use the Windows API if I want to do this?

von Curtis - am 11.11.2016 21:12
I got this from the help for the function that is called like your TrapSystemKeys ()

Note: If the process returns a value (an integer), the Windows event is stopped: this value is returned. If the process returns NO value, the execution continues.

von Arie - am 12.11.2016 11:56
HI Curtis,

Windev comes with an example: WD Hotkey

I did use the example in order to build a password manager with the option to use short cuts to send user and password as a keystroke to my login fields...


von Sascha77 - am 13.11.2016 12:47
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.