Help with script (timing & toggled loop)

Get help with using AutoHotkey and its commands and hotkeys
JoeDin2056
Posts: 6
Joined: 25 Apr 2019, 08:20

Help with script (timing & toggled loop)

07 Jul 2019, 13:05

Hi all,

Im really bad at scripting, i can never seem to understand it. So i was hoping you could help me out.

Im after a script that i think may be a bit complex. I would like this to be toggled on/off with the F7 key.

While it is toggled on i need it to do 2 different things.

the first is to constantly hold down the right trigger on an xbox one controller

the second is to press the A button on the xbox one controller once, randomly between 10 and 30 second. i need it to keep doing this till the script is toggled off.

and lastly i need this to be sent to a target window as well, even if its minimized or in the background.

I have managed to worked out setting this "settitlematchmode,2" and then added "-WINDOWNAME" sends the script command to a window. But im at a loss on how to do the rest.
Please can someone help me out. I have spent the last hour trying to work it out and so far all i have is that tiny bit of code.

Thanks Joe.
nou
Posts: 21
Joined: 24 Feb 2019, 21:21

Re: Help with script (timing & toggled loop)

08 Jul 2019, 03:19

To toggle something on/off, I recommend using SetTimer. In this format:

Code: Select all

count := 0

x::SetTimer, label, % (toggle := !toggle) ? 50 : "Off"

label:
    ToolTip, % "AutoHotKey: " ++count
return

Then, find what key your xBox One Controller is for the right trigger, and just use this format:

Code: Select all

send {key down}
where "key" = the key you need to change it out with.

Same would be true for pressing the "A" key.

To get a random number, use the 'random' command.

Code: Select all

random, outvar, min, max
And to send things to the target window, use controlclick/controlsend.

G'luck Joe.
JoeDin2056
Posts: 6
Joined: 25 Apr 2019, 08:20

Re: Help with script (timing & toggled loop)

08 Jul 2019, 12:06

Hi thanks for taking the time to give me some help. But im afraid after reading that im more lost then ever.

So for the loop where would i set the key that starts and stops it, also does the rest of the script go with in the loop or after it?

As for finding out the key for what the Xbox Controllers are i dont know how to do that, i did a google search but nothing seemed to tell me.
JoeDin2056
Posts: 6
Joined: 25 Apr 2019, 08:20

Re: Help with script (timing & toggled loop)

14 Jul 2019, 07:45

Can someone please provide some more help? im still struggling with this.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], flyingDman, Google [Bot], scriptor2016 and 148 guests