Autoclicker with ControlClick and Mouse Position? Topic is solved

Ask gaming related questions (AHK v1.1 and older)
KixenDK
Posts: 8
Joined: 24 Apr 2017, 18:05

Autoclicker with ControlClick and Mouse Position?

24 Apr 2017, 19:21

Code: Select all

#NoEnv
;#Warn
#MaxThreadsPerHotkey 2
SetControlDelay -1
SendMode Input
toggle := 0
return

F8::
IfWinExist[, ("ahk_exe program.exe")]
{
	toggle := !Toggle
	While Toggle
	{
		Click
	sleep 37
	}
}
IfWinNotExist[, ("ahk_exe program.exe")]
{
	MsgBox Not running.
}
return
Hi guys.
I'm VERY new at this... So if my code look scrambled, don't think to much about it.
This is my very first script. Started using AutoHotkey today, so go easy on me. :P

Anywho...
My issue is this. I am trying to create an autoclicker, which will work, even if the window isn't active, or even behind another window. This is why I thought of ControlClick. But since I'm new, I do not yet have the understanding nor the experience to complete this wish. So I thought some of the experienced guys here, could help me out. :D

But what I precisely want the script to do.
#1. First of, I want it to click for as long as it is toggled on, or the program closes.

#2. I would love if it could activate at the mouse position, when I activate the script. And stay there, even if I move the mouse away. Sort of like using coords. They should just be changeable from everytime I click F8, as the needed area for clicking changes.

#3. If the program ain't running, and I click F8, I want it to show a popup telling me so.
So the autoclicker doesn't randomly start, if I'm watching a movie, or sitting on facebook or whatever... It should toggle it on, if program.exe ain't running, simple. :D

I've tried putting else in, instead of IfWinNotExist, but that gives me an error. :/
Don't understand the if's and else's yet. xD

Also... When I toggle it on, it works. Haven't tested it, if the program isn't running yet, but.. When I toggle it off again, I get the MsgBox twice! Which means. It pops up, when I activate, but gets suspended, and I get one when I deactive, which gives me 2 in a row...

Please someone help me out! :crazy:

EDIT: Oh, I should maybe also mention.. The script should only work inside of the programs window, not outside.
KixenDK
Posts: 8
Joined: 24 Apr 2017, 18:05

Re: Autoclicker with ControlClick and Mouse Position?  Topic is solved

25 Apr 2017, 08:06

Okay. I figured out a solution. :dance:
I'm gonna post it here, if anybody can use it. :D

Code: Select all

#NoEnv
#MaxThreadsPerHotkey 2
SetControlDelay -1
SendMode Input
setBatchLines -1
banana := 0
toggle := 0
return

NumpadDiv:: 
SetTimer, WatchCursor, 30 ;Check for mouse position.
KeyWait, NumpadDiv  ;Wait for the key to be released.
SetTimer, WatchCursor, Off ;Remember mouse position.
Sleep, 60
;ToolTip ;Tooltip if needed, check WatchCursor for info.
Return

WatchCursor:
MouseGetPos, xpos, ypos ;Get mouse position.
WinGetTitle, Title, A ;Get window title. (if you want to use the autoclicker more than one program)
;ToolTip, The cursor is at X: %xpos% - Y: %ypos%`nin Window: %Title%. ;Tooltip to show position and window title, if needed.
Return

Activate:
NumpadMult::
toggle := !Toggle
While Toggle
{
	ControlClick, x%xpos% y%ypos%, %Title%,,,1,NA ;Sends virtual clicks to saved mouse position and window title.
	sleep, 100
}
Return

Hold:
XButton1::
banana := !Banana
while Banana
{
	sendInput, {LButton} ;Sends mouse clicks to current mouse position.
	sleep 70
}
Return
Instructions:

Numpad / = Hold down to gather mouse position, realease to save position.

Numpad * = Toggle autoclicker at saved position. (Mouse can be used outside window, and clicker will still run even if window is inactive)

Mouse Button 3 (Also used as 'Back' button) = Toggle autoclicker at mouse location.
I hope you enjoy my first ever script, and that you are satisfied with my work. :superhappy:
User avatar
bisoncool1
Posts: 18
Joined: 18 May 2020, 05:02

Re: Autoclicker with ControlClick and Mouse Position?

25 May 2020, 10:54

Just to let you know, you can't go into another window whilst this is clicking. I don't know why can you help?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 32 guests