Page 1 of 1

Can't figure out what I'm doing wrong

Posted: 04 Feb 2022, 20:42
by Naeksu
So basically, here's my current code

Code: Select all

toggle := 0

F1::
MouseGetPos, MouseX, MouseY
Click, Right
if toggle := !toggle
 gosub, MoveTheMouse
else
 SetTimer, MoveTheMouse, off
return

MoveTheMouse:
MouseMove, 582, 256
Click
SetTimer, MoveTheMouse, -3000  ; every 3 seconds 
MouseMove, %MouseX%, %MouseY%
Click, Right
return


My issue here is the "SetTimer,MoveTheMouse -3000 ;every 3 seconds. As I would want this to be "randomized" between, let's say 10000MS to 40000MS.

And, I've once downloaded a script for FFXIV where it supposedly kept clicking certain buttons trying to buy a house. But the AHK did this, with the game minimized without interfering with my keyboard, is there also a way to do the same here?.

Re: Can't figure out what I'm doing wrong

Posted: 04 Feb 2022, 20:52
by mikeyww
To randomize, you can use :arrow: Random. Example

Would have a look, too, at ControlClick. I doubt that it would work with a minimized window, but since you already found a working example, you could adapt it.

Re: Can't figure out what I'm doing wrong

Posted: 04 Feb 2022, 21:00
by TLM
@Naeksu you're using an assignment operator := in a conditional statement and trying to evaluate incorrectly.
Change: if toggle := !toggle to if ( !toggle ) or if ( toggle = 0 )

Re: Can't figure out what I'm doing wrong

Posted: 04 Feb 2022, 21:26
by mikeyww
Assignments can be used in conditional statements, and frequently are. Proving the viability is straightforward.

Code: Select all

Loop, 2
 If toggle := !toggle
      Send x
 Else Send y