[Problems] Trying to make an autoclicker for windows in the background

I used to use non intrusive autoclicker for this on idle game I play on firefox, but a new update broke that program on firefox. I am trying to learn how to make an autoclicker with AHK that clicks in the background so I can play other games without my mouse being taken over by an autoclicker. Here is what I got so far.

​

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.

; #Warn ; Enable warnings to assist with detecting common errors.

SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

​

scriptState := true

​

zeWindow := Interactive Buddy v.1.01 - Mozilla Firefox

​

clickCoords := X950 Y430

​

time := 1000

​

f1::

{

while (scriptState) {

ControlClick, X950 Y430, Interactive Buddy v.1.01 - Mozilla Firefox

sleep, time

toolTip, fired

}

}

return

​

f2::

{

if (scriptState) {

scriptState := false

} else {

scriptState := true

}

}

return

​

^f2:: ; That is ctrl F2

{

ExitApp

}

return

​

Now most of that works just fine, although when I do %clickCoords% in the ControlClick then that does not work, but the tooltip still shows. (Tooltip is just to make sure the code doesn't just break the whole thing). Funny thing is the %clickCoords% works on chrome, but not on firefox for some reason.

​

I do get clicks in interactive buddy (Big clickable environment in case I get my click placement off). In firefox this works fine with the window in the background, but when I try this with chrome, then chrome becomes the top window every click, so I might try to play minecraft or look at notepad etc, and chrome keeps going at the top of the windows blocking my view.

​

There was also another small problem I found. The name of the window for the game I am mainly getting this script to work on is "Play The Perfect Tower, a free online game on Kongregate - Mozilla Firefox" and the comma makes the name not work, so I have to use part of the name. Any way I could use the full name just to be safe?

​

And for the BIGGEST problem, is that the clicking WORKS, but ONLY if I have my mouse hovering over the button in the game. If my mouse is not over the button, even just next to it, the button is not clicked.

​

Le edit (haha old maymay)

​

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.

; #Warn ; Enable warnings to assist with detecting common errors.

SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

​

scriptState := true

​

time := 5

​

; Apparently I don't need exact click locations, just in the area of the game works.

; Hover mouse over button and then alt tab out for it to run in background.

; firefox if clicked stays in the background, but chrome when clicked comes to foreground.

​

f1::

{

SetControlDelay, -1

while (scriptState) {

ControlClick, X700 Y600, Play The Perfect Tower`, a free online game on Kongregate - Mozilla Firefox,,LEFT,2,NA

sleep, time

}

}

return

​

f2::

{

scriptState := !scriptState

}

return

​

^f2:: ; That is ctrl F2

{

ExitApp

}

return

​

So basically I fixed the code. The clicks have to be in the game window, and all I have to do is leave my mouse over any particular button and it works, then I alt tab out to let my clicks run in the background exactly like NI Auto Clicker, except this clicks faster and is a lot nicer to use in my opinion.

​

I wouldn't really say this is solved since I found some backwards bug/glitch or whatever to get what I want done, since the way the code is supposed to work is not even close to how it actually works in practice and so I am left dumbfounded of what is even going on.

Posted Jul 11, 2019, 7:32 AM UTC · edited

25
Loading comments…