I need to detect if any key has been pressed during a set period, say 15 secs.
I looked at GetAsyncKeyState and others in the API group, but couldn't find anything for ANY key, only specific keys.
The PB keyboard commands are, I believe only for Console screens so that's no good. I need to detect any key pressed in windows during a period of say, 15secs.
Any comments welcomed.
Alan
Need equivalent of inkey$ in windows
Need equivalent of inkey$ in windows
PB v3.94 PVXP v2.13 JaPBe v2.5.4.22
I think I may have solved it but the secs variable is not incrementing.
I have this before the main loop.
Then this inside the main loop before the repeat - until stuff
Alan
I have this before the main loop.
Code: Select all
Procedure UpdateTime(Value)
Repeat
secs=secs+1
Delay(1000)
Until quitForm1=1
EndProcedure
thd=CreateThread(@UpdateTime(),0)Code: Select all
If secs>15
do something
EndIfAlan
PB v3.94 PVXP v2.13 JaPBe v2.5.4.22
Re: Need equivalent of inkey$ in windows
Code: Select all
Procedure KeyPressed()
For k=8 To 123 ; A-Z, 0-9, F1-F12, Numpad, Backspace, etc.
If GetAsyncKeyState_(k)<>0
Repeat : Delay(1) : Until GetAsyncKeyState_(k)=0
r=1 : Break ; Exit loop now since we're done.
EndIf
Next
ProcedureReturn r
EndProcedure
Repeat
Delay(1)
If KeyPressed()=1
Debug "A key has been pressed!"
EndIf
ForEver
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.

