PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD20] Trapping Keyboard Events
[WD20] Trapping Keyboard Events
Iniciado por guest, 11,nov. 2016 19:17 - 5 respuestas
Publicado el 11,noviembre 2016 - 19: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.
Publicado el 11,noviembre 2016 - 20:49
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
Publicado el 11,noviembre 2016 - 21:24
TrapSystemKeys() is not being called. Any ideas?

PROJECT LEVEL CODE
Event(TrapSystemKeys,"*.*",WM_SYSKEYDOWN)


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
Trace("winkey")
RETURN
END
Publicado el 11,noviembre 2016 - 22:12
PROJECT LEVEL CODE
Event(TrapKeys,"*.*",WM_KEYDOWN) Event(TrapSystemKeys,"*.*",WM_SYSKEYDOWN)
PROCEDURE TrapKeys(aMessage, wParam, lParam)
IF wParam = VK_LWIN OR wParam = VK_RWIN THEN RETURN END
PROCEDURE TrapSystemKeys(aMessage, wParam, lParam)
IF wParam = VK_LWIN OR wParam = VK_RWIN THEN RETURN END
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?
Publicado el 12,noviembre 2016 - 12:56
Curtis,
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.
Publicado el 13,noviembre 2016 - 13:47
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...


Sascha