i just wondern why such a function like KeyboardPushed() is only available in 2D and there is no native function...
I need this function but without using 2D-OpenScreen etc.
Found this one somewhere here:
Code: Select all
Global HHOOK
Procedure SendKey(KeySwap.s)
SwapData.INPUT
SwapData\type = #INPUT_KEYBOARD
SwapData\ki\wVk = PeekB(@KeySwap)
SwapData\ki\wScan = 0
SwapData\ki\dwFlags = 0
SwapData\ki\time = 0
SwapData\ki\dwExtraInfo = 0
SendInput_(1, SwapData, SizeOf(INPUT))
EndProcedure
Procedure.s GetKeyName(KeyCode.i)
KeyName.s = Space(#MAX_PATH)
GetKeyNameText_(MapVirtualKey_(KeyCode, #MAPVK_VK_TO_VSC) * $10000, @KeyName, #MAX_PATH)
ProcedureReturn KeyName
EndProcedure
Procedure KeyboardHook(nCode, wParam, *kc.KBDLLHOOKSTRUCT)
If nCode = #HC_ACTION
KeyCode = *kc\vkCode
Select KeyCode
Case 27
UnhookWindowsHookEx_(HHOOK)
End
Case 65 To 90
Debug GetKeyName(KeyCode)
Default
SendKey(#Null$)
ProcedureReturn 1
EndSelect
EndIf
ProcedureReturn CallNextHookEx_(#Null, nCode, wParam, *kc)
EndProcedure
If OpenWindow(0, 0, 0, 0, 0, "Global Keyboard Hook", #PB_Window_Invisible)
HHOOK = SetWindowsHookEx_(#WH_KEYBOARD_LL, @KeyboardHook(), #Null, 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I just want the "last" key that has been pushed (no matter if pushed further or released).
Any ideas or other codes?
Thx!
