Author Topic: Key press and mouse click are not simultaneous  (Read 2621 times)

sergio56

  • Newbie
  • *
  • Posts: 4
Key press and mouse click are not simultaneous
« on: January 03, 2021, 01:30:35 PM »
I tried to send a voice command with the following combination :
right alt
left mouse click

Unfortunately mouse click is not simultaneous with right alt keypress, so the combination doesn't work.
Mouse click is always executed AFTER the keypress (i tried to prolonge keypress time without effect).
Mouse click always followed keypress
Is there a way to combine the two events at the same moment?

Of couse I activated "allow other commands to execute while this one is running"

Any suggestion?
Thank you

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Key press and mouse click are not simultaneous
« Reply #1 on: January 03, 2021, 01:36:06 PM »
How is your command set up? Actions are executed sequentially, I.E. one after the other, and unless the action has an option to be executed asynchronously (E.G. the "Wait until speech completes before continuing command" option for the "Say Something with Text-To-Speech" action), two actions should never overlap.

If your command is set up like this:
Code: [Select]
Press Right Ctrl+Right Alt keys and hold for 0,03 seconds and release
Click left mouse button
The right Alt key will be pressed, held down for ~30ms, and released, before clicking the left mouse button

To do both at once, you need to press the key first, click the mouse button, and only then release; E.G.
Code: [Select]
Press down Right Alt key
Pause 0,02 seconds
Click left mouse button
Release Right Alt key

sergio56

  • Newbie
  • *
  • Posts: 4
Re: Key press and mouse click are not simultaneous
« Reply #2 on: January 03, 2021, 02:24:35 PM »
Thank you very much for reply

I follow your instruction and made a simple test to check the code as follows :
if you right click on a pc desktop a menu appears, while if you hold right alt pressed nothing appears...
Unfortunately it doesn't work

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Key press and mouse click are not simultaneous
« Reply #3 on: January 03, 2021, 02:33:25 PM »
VoiceAttack is pressing the right Alt key while the mouse button is clicked.

The reason the context menu closes while you physically hold the right Alt key is likely because the keypress repeats itself when the key is held down. You can verify this by not pressing the right Alt key, clicking the right mouse button to open the context menu, and then pressing the right Alt key, which will close the context menu.

Keypresses generated by software do not cause an automatic repeat (E.G. holding the physical 'A' key would produce "aaaaa", while doing it through software just produces "a"), this does not mean the key is not being held down.


Have you tested this in the actual scenario you're looking to use it in?

sergio56

  • Newbie
  • *
  • Posts: 4
Re: Key press and mouse click are not simultaneous
« Reply #4 on: January 03, 2021, 02:42:30 PM »
I just tested in my scenario (e.g. MSFS 2020), it's working fine :)
Thank you very much indeed!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Key press and mouse click are not simultaneous
« Reply #5 on: January 03, 2021, 02:45:31 PM »
Have you tried increasing or adding pauses?

E.G.
Code: [Select]
Press down Right Alt key
Pause 0,30 seconds
Click left mouse button
Pause 0,30 seconds
Release Right Alt key

Also try increasing the click duration for the mouse click

Just for testing, to check if it registers at all; Obviously you'd want to try reducing those if it does work.

sergio56

  • Newbie
  • *
  • Posts: 4
Re: Key press and mouse click are not simultaneous
« Reply #6 on: January 03, 2021, 02:50:20 PM »
No i didn't because it's working as i would  :) :)
I appreciated very much your (quick and smart  :)) support