Looping 'MouseClick's while held. HELP?!?! Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DoobieToTheHead
Posts: 10
Joined: 20 Dec 2017, 17:57

Looping 'MouseClick's while held. HELP?!?!

21 Jan 2018, 07:07

Right, so I currently have the following code, it's purpose as you can probably tell is so when I click Alt and LButton, it will perform the initial click where my mouse is, then click at the following 2 coordinates in that order.

What I am trying to achieve, is a loop of the 2 clicks afterwards, so I click at my mouse position, then it will loop between:

Code: Select all


		MouseClick, Left, 865, 986, 1, 0.1
		Sleep, 100
		MouseClick, Left, 845, 182, 1, 0.1
Until I release the LButton and Alt key.

Thanks in advance for any help anyone can give me :D :D :D

Code: Select all

#NoEnv 
SendMode Input 

#SingleInstance, force

Loop
{

	GetKeyState, LeftMouse, LButton
	GetKeyState, LeftAlt, Alt
	If (LeftMouse = "D" and LeftAlt = "D" )
	{ 	
		Sleep, 100
		MouseClick, Left, 865, 986, 1, 0.1
		Sleep, 100
		MouseClick, Left, 845, 182, 1, 0.1
		}
	
	Sleep, 100  ; To cut down on the massive CPU usage
}

Image
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: Looping 'MouseClick's while held. HELP?!?!  Topic is solved

21 Jan 2018, 07:19

Code: Select all

~*lbutton:: ;~ means do not block left click, * means works regardless of modifiers
while(GetKeyState("lalt","P") and GetKeyState("lbutton","P")) { ;P == physically held
	MouseClick, Left, 865, 986, 1, 0.1
	Sleep, 100
	MouseClick, Left, 845, 182, 1, 0.1
	Sleep, 100
}
return

f8::exitapp
f9::reload
DoobieToTheHead
Posts: 10
Joined: 20 Dec 2017, 17:57

Re: Looping 'MouseClick's while held. HELP?!?!

21 Jan 2018, 07:32

Spawnova wrote:

Code: Select all

~*lbutton:: ;~ means do not block left click, * means works regardless of modifiers
while(GetKeyState("lalt","P") and GetKeyState("lbutton","P")) { ;P == physically held
	MouseClick, Left, 865, 986, 1, 0.1
	Sleep, 100
	MouseClick, Left, 845, 182, 1, 0.1
	Sleep, 100
}
return

f8::exitapp
f9::reload


Thankyou very much!

Really helped me out, plus this will help me with future scripts knowing the 'P' state :D
Image
DoobieToTheHead
Posts: 10
Joined: 20 Dec 2017, 17:57

Re: Looping 'MouseClick's while held. HELP?!?!

21 Jan 2018, 07:58

Sorry man, I've just realised that when I Alt+Lbutton it does press in the 2 places I want on loop, but it doesnt seem to perform the initial mouse click in the place where my mouse is at the time of first click? :\ if you get what i mean....

Spawnova wrote:

Code: Select all

~*lbutton:: ;~ means do not block left click, * means works regardless of modifiers
while(GetKeyState("lalt","P") and GetKeyState("lbutton","P")) { ;P == physically held
	MouseClick, Left, 865, 986, 1, 0.1
	Sleep, 100
	MouseClick, Left, 845, 182, 1, 0.1
	Sleep, 100
}
return

f8::exitapp
f9::reload
Image
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: Looping 'MouseClick's while held. HELP?!?!

21 Jan 2018, 12:37

The initial click should be going through, however it won't perform a click up until you release left click.

I did change one of your sleeps in the loop so the first loop click was immediate, however that may have caused the issue if you also need the original click.

Try changing it to this

Code: Select all

~*lbutton:: ;~ means do not block left click, * means works regardless of modifiers
while(GetKeyState("lalt","P") and GetKeyState("lbutton","P")) { ;P == physically held
	Sleep, 100 ;changed this back, so there will always be a sleep before the first virtual click
	MouseClick, Left, 865, 86, 1, 0.1
	Sleep, 100
	MouseClick, Left, 845, 182, 1, 0.1
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mannaia666 and 413 guests