Can't figure out what I'm doing wrong

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Naeksu
Posts: 1
Joined: 04 Feb 2022, 20:38

Can't figure out what I'm doing wrong

04 Feb 2022, 20:42

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?.
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

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

04 Feb 2022, 20:52

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.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

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

04 Feb 2022, 21:00

@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 )
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

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

04 Feb 2022, 21:26

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, Bing [Bot], RickC, Spawnova and 64 guests