Author Topic: Need help with adding a wait for mouse click...  (Read 4749 times)

ibastavd

  • Guest
Need help with adding a wait for mouse click...
« on: April 11, 2018, 11:56:50 AM »
Hi,

I'm trying to add a wait until the left mouse button is pressed into a VA command. I'm not thick but I'm stumped!

My command has 10 of:

"Press R key and hold for 1.9 seconds before release commands"

I'd like it to wait until I've clicked the left mouse button before it proceeds with the next one

Any help would be great

Thanks

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Need help with adding a wait for mouse click...
« Reply #1 on: April 11, 2018, 12:25:51 PM »
Add this where you want the command to wait:
Code: [Select]
Start Loop While :  Left Mouse Button Is Not Pressed
End Loop

The loop will keep running until you press the left mouse button, at which point it will end and whatever actions are below it will be executed.

ibastavd

  • Guest
Re: Need help with adding a wait for mouse click...
« Reply #2 on: April 11, 2018, 02:01:54 PM »
Thanks Pfeil,

I hate to have to ask but how do I add that command?

Embarrassed or what!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Need help with adding a wait for mouse click...
« Reply #3 on: April 11, 2018, 05:28:03 PM »
In the "Edit a Command" window, click "Other >", go to "Advanced >", "Add a Loop Start", click "Single Condition(While Loop)".

Click the "Device State" tab, in the first dropdown select "Mouse button" in the second dropdown select "Left", in the third dropdown select "Is Not Pressed", click "OK" and the actions will be added to your command.

ralf44

  • Newbie
  • *
  • Posts: 41
Re: Need help with adding a wait for mouse click...
« Reply #4 on: April 13, 2018, 03:20:28 PM »
I'd make a command and call it what you want to say to start the 10 presses, like "Execute Combo."

You could also have it trigger when you press some key, to save your voice. VA allows multiple inputs to trigger one command.

Anyway the awesome Execute Combo command would have about two or three lines. Just to wait for mouse click and then press R.

Instead of copy pasting that to repeat it, there's a box near the bottom right of the VA Edit Command interface which lets you tell a command to repeat (X) times so you'd just type 10 in that box and you're done.

Myself I would add a cancel command, activated by voice and optionally a keypress, called Cancel Combo. That would only have one line, to stop the other command.

So the code for both could look like:

"Execute Combo" (or whatever you want to say):
Say something with text-to-speech: "Engaged"
Start Loop While :  Left Mouse Button Is Not Pressed
Pause for 0.05 seconds (just be sure the loop doesn't waste processor time)
End Loop
Press R key and hold for 1.9 seconds
(in bottom options, type 10 into the Repeat this command X times box)

(in top options, can add a keypress which will work as well as the voice control)

2nd VA Command, for safety -
"Cancel combo" (or whatever you want to say, and an optional keyboard equivalent):
Kill Command "Execute combo" (or whatever)
Say something with text-to-speech: "Cancelled"
(Do not type a number into the repeat box for this one!)

If you already have a big command full of steps which does other stuff with this 10-R pattern in the middle, you just put:
Start another Voice Attack command: "Execute combo" (and wait for it to complete)
in there.
« Last Edit: April 13, 2018, 03:37:12 PM by ralf44 »

ibastavd

  • Guest
Re: Need help with adding a wait for mouse click...
« Reply #5 on: April 16, 2018, 11:08:36 AM »
Thanks Guys! My heroes!

Mac

Krittol

  • Newbie
  • *
  • Posts: 16
Re: Need help with adding a wait for mouse click...
« Reply #6 on: September 20, 2021, 12:34:26 AM »
In the "Edit a Command" window, click "Other >", go to "Advanced >", "Add a Loop Start", click "Single Condition(While Loop)".

Click the "Device State" tab, in the first dropdown select "Mouse button" in the second dropdown select "Left", in the third dropdown select "Is Not Pressed", click "OK" and the actions will be added to your command.

Hi, Pfeil sorry to necro this post but I found it trying to do exact thing, so thanks for the information here. The only thing is I want the loop to end after a given amount of time if I don't press TAB, without the rest of the command completing - basically cancel the command if i haven't pressed TAB after say 30 seconds. How do I add to this command to achieve this.

Thanks

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Need help with adding a wait for mouse click...
« Reply #7 on: September 20, 2021, 12:12:00 PM »
Assuming you mean having a command wait until you press that key (I.E. rather than the mouse click), with a timeout, that could look something like
Code: [Select]
Set date [~timeout] to [~timeout] plus [30] Seconds
Start Loop While : (Keyboard Key 'Tab' Is Not Pressed AND [~timeout] Is After Current Date/Time)
End Loop
Begin Date Compare : [~timeout] Is Before Current Date/Time
    Write [Yellow] 'Timeout waiting for Tab' to log
End Condition - Exit when condition met
Write [Green] 'Tab pressed' to log

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Need help with adding a wait for mouse click...
« Reply #8 on: September 21, 2021, 11:19:52 AM »
Love the use of date/time instead of the more typical integer and integer increment/decrement in a for-loop!! VA is awesome!

FR4NK7Y

  • Newbie
  • *
  • Posts: 11
Re: Need help with adding a wait for mouse click...
« Reply #9 on: February 27, 2022, 04:15:21 PM »
Hey Pfeil!

Tho the looping thing is very much helpful. May you please tell me how to do this:

If I release "Controller: 1" below 0.25 seconds (0.24sec) - i want it to press "Keyboard: X"
If  I hold "Controller: 1" for more then 0.24 seconds (0.25sec) -  i want it to press "Keyboard: Y"

thanks!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Need help with adding a wait for mouse click...
« Reply #10 on: February 27, 2022, 04:23:10 PM »
Which part are you having trouble with? That should be nearly identical to the example with the Tab key, except that the loop would check whether the button is pressed (rather than not pressed), and rather than "Write a Value to the Event Log" actions you'd use keypress actions to press the relevant keyboard keys.

FR4NK7Y

  • Newbie
  • *
  • Posts: 11
Re: Need help with adding a wait for mouse click...
« Reply #11 on: February 27, 2022, 08:40:10 PM »
lol that works, thanks!