Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The program only wants to run once . . .
#18
(07-31-2024, 09:23 AM)RhoSigma Wrote:
(07-31-2024, 04:18 AM)DSMan195276 Wrote: I might have an idea, do you start the program by hitting F5? If you hold the F5 key too long then the release event of F5 will go to the newly started program, that would trigger the behavior you're describing since the F5 release will be returned by _KeyHit first before the spacebar.

That can't be the case as Steve added a release wait loop in PR #399 to avoid the program is started before F5 is released. That was back in v3.10.0, no idea what version KP is using though.

This would only trap if someone was starting the program via the IDE.  If you're starting it from the compiled EXE, then you could still carry over keypresses and such, if your keyboard has the proper repeat rates and such, and you hold whatever key you use to start it too long at start up.

The best way I know to try and avoid stray junk from previous input messing up current input, is to place a _KEYCLEAR statement in the program before you go to fetch the new buffer, such as perhaps:

Code: (Select All)
Dim As Integer x

Print "Taste"
_KEYCLEAR 'clear the old keyboard buffer of any junk in it at this point
_Delay 2 'pause the program so the user now has two seconds at this point to press a key

x = _KeyHit
If x = 32 Then
  Print "Leertaste "; x
ElseIf x = 27 Then
  Print "Esc-Taste "; x
Else
  Print "Unbekannt"; x 'go ahead and print x here to see what key it did catch.  0 if none, otherwise see what actually got picked up
End If
Reply


Messages In This Thread
RE: The program only wants to run once . . . - by SMcNeill - 07-31-2024, 12:39 PM



Users browsing this thread: 6 Guest(s)