Author Topic: ANYKEYDOWN detects activating key press  (Read 3294 times)

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
ANYKEYDOWN detects activating key press
« on: July 05, 2017, 10:02:28 AM »
I was fiddling around with the new {STATE_ANYKEYDOWN} token and I noticed that the below code seems to detect a key down event when the code is executed "when I press keys," even if the option "do not allow key to be passed through" is enabled.

So by executing the bellow code when (for example) the "Page Up" key is pressed:

Code: [Select]
Pause 1 second
Set integer [counter] value to 1
Start Loop While : [counter] Is Less Than Or Equals 5
    Set integer [keystate] value to the converted value of {STATE_ANYKEYDOWN}
    Begin Integer Compare : [keystate] Equals 1
        Write '[Blue] key pressed' to log
        Pause 0.5 seconds
        Set integer [keystate] value to [Not Set]
        Set integer [counter] to [counter] plus 1
    End Condition
End Loop
Write '[Blue] done' to log

...there is a "key pressed" output after the initial 1 second pause. Again, this happens without any additional keyboard input. Making the initial pause longer has no impact.

Thoughts?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: ANYKEYDOWN detects activating key press
« Reply #1 on: July 05, 2017, 01:37:59 PM »
As you've noted in your feature request, this is because VoiceAttack counts the keys it itself presses for the token.

That behavior was actually changed from the original which didn't, with the release of v1.6.2:

Quote
{STATE_KEYSTATE} token was not showing keys that were down when VoiceAttack was pressing them down (oddly, this is kind of by design).  This should produce expected results now.

So it is by design.
« Last Edit: July 05, 2017, 04:03:16 PM by Pfeil »

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: ANYKEYDOWN detects activating key press
« Reply #2 on: July 05, 2017, 03:37:35 PM »
But it almost seems like VA "remembers" the first keypress. That's why I tried inserting an initial pause of 1 second, hoping that VA had stopped pressing the activation key and that its state was back to "unpressed." Guess not though! :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: ANYKEYDOWN detects activating key press
« Reply #3 on: July 05, 2017, 04:40:31 PM »
Disregard my initial response, while your command would normally indicate a keypress every time you pressed a key because the loop is set up in such a way that the command progresses only when a key is pressed, it does appear the detection can "lag" at times and show a key as pressed when it has already been released.

When the command is triggered by a key, that keypress doesn't show up for me, however, if you press multiple keys in rapid succession(well within 1000ms), once the loop starts it will still detect those keypresses despite the keys long being released.

E.G.
  • Set the command up to be triggered by pressing "N"
  • Quickly press "N", "B", and "V"
  • Note that "key pressed" appears in the log twice, despite the keys not remaining pressed

This seems to work up to many keypresses. Even increasing the command's loop limit to 10 will show 10 keypresses if pressed before the pause expires and the loop starts.


This is something for Gary to look into.

EDIT: This also happens when "Do not allow key to be passed through" is not checked, and when "Shortcut is invoked only when all keys are released" is checked, or both are checked.
« Last Edit: July 05, 2017, 04:53:06 PM by Pfeil »