Im trying to make a autoclicker that clicks when you hold

Ask gaming related questions
MundaneGD
Posts: 4
Joined: 21 Nov 2023, 09:43

Im trying to make a autoclicker that clicks when you hold

21 Nov 2023, 10:27

I know that there are forums for pretty much the same thing but for some reason, they only work half of the time when I hold in Minecraft. If anyone knows a way around this then please tell me, your help will be appreciated!
niCode
Posts: 319
Joined: 17 Oct 2022, 22:09

Re: Im trying to make a autoclicker that clicks when you hold

21 Nov 2023, 16:14

Games can be finicky. Hard to know what to try differently without seeing the code you've tried.

Try this:

Code: Select all

*LButton::HoldClick()

HoldClick()
{
    (enable := GetKeyState('LButton', 'P')) ? SendEvent('{Click}') : 0
    SetTimer(HoldClick, -50 * enable)
}
MundaneGD
Posts: 4
Joined: 21 Nov 2023, 09:43

Re: Im trying to make a autoclicker that clicks when you hold

22 Nov 2023, 12:16

It does work! Thank you for the script
Stealth7
Posts: 19
Joined: 12 Nov 2023, 17:21

Re: Im trying to make a autoclicker that clicks when you hold

23 Nov 2023, 19:09

MundaneGD wrote:
21 Nov 2023, 10:27
I know that there are forums for pretty much the same thing but for some reason, they only work half of the time when I hold in Minecraft. If anyone knows a way around this then please tell me, your help will be appreciated!

Code: Select all

~*XButton2::
	While GetKeyState("XButton2","P")
	{
		Click
	}
Return
This should work fine. Otherwise you can change the click to "Send {LButton down}" & "Send {LButton up}", but there are many ways.. Then add a sleep in the loop to adjust the CPS if you want to.
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 16:32

niCode wrote:
21 Nov 2023, 16:14
Games can be finicky. Hard to know what to try differently without seeing the code you've tried.

Try this:

Code: Select all

*LButton::HoldClick()

HoldClick()
{
    (enable := GetKeyState('LButton', 'P')) ? SendEvent('{Click}') : 0
    SetTimer(HoldClick, -50 * enable)
}
is there a way to modify this to work with a key like f on my keyboard, so while i hold down f its pressed repeatedly until i release it
niCode
Posts: 319
Joined: 17 Oct 2022, 22:09

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 17:05

Try:

Code: Select all

*LButton::SpamKey()
*f::SpamKey()

SpamKey()
{
    key := SubStr(A_ThisHotkey, 2)
    Spam := SendEvent.Bind('{' key '}')
    SetTimer(Spam, 50)
    KeyWait(key)
    SetTimer(Spam, 0)
}
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 18:14

niCode wrote:
16 May 2024, 17:05
Try:

Code: Select all

*LButton::SpamKey()
*f::SpamKey()

SpamKey()
{
    key := SubStr(A_ThisHotkey, 2)
    Spam := SendEvent.Bind('{' key '}')
    SetTimer(Spam, 50)
    KeyWait(key)
    SetTimer(Spam, 0)
}

works, if you have the time could you explain to me how this works? it makes very little sense to me (im a complete beginner to programing)
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 18:17

niCode wrote:
16 May 2024, 17:05
Try:

Code: Select all

*LButton::SpamKey()
*f::SpamKey()

SpamKey()
{
    key := SubStr(A_ThisHotkey, 2)
    Spam := SendEvent.Bind('{' key '}')
    SetTimer(Spam, 50)
    KeyWait(key)
    SetTimer(Spam, 0)
}

actually no its not working, it works amazing in text and browsers but not in the game i intended to use it in, are there any things i can try to make it work in this game?
User avatar
boiler
Posts: 17369
Joined: 21 Dec 2014, 02:44

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 18:23

You could try running the script as administrator or otherwise address UAC.
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 18:26

boiler wrote:
16 May 2024, 18:23
You could try running the script as administrator or otherwise address UAC.
it works in the games chat and search functions just not while actively playing, would this be the case if it was a problem of this nature?
User avatar
boiler
Posts: 17369
Joined: 21 Dec 2014, 02:44

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 18:29

No, if that were the issue, it really shouldn’t work at all, so it must be like a lot of games that it only responds to physical keystrokes, not virtual ones.
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 18:31

boiler wrote:
16 May 2024, 18:29
No, if that were the issue, it really shouldn’t work at all, so it must be like a lot of games that it only responds to physical keystrokes, not virtual ones.
is there a way to get around this? Ive seen cases where using up and down key commands fixes similar issues? is there a way to integrate those into this script if that is something worth trying?

Code: Select all

#Requires AutoHotkey v2.0

*f::SpamKey()

SpamKey()
{
    key := SubStr(A_ThisHotkey, 2)
    Spam := SendEvent.Bind('{' key '}')
    SetTimer(Spam, 50)
    KeyWait(key)
    SetTimer(Spam, 0)
}
Last edited by joedf on 16 May 2024, 18:36, edited 1 time in total.
Reason: fix [code] tags
User avatar
boiler
Posts: 17369
Joined: 21 Dec 2014, 02:44

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 19:43

You can try this just in case:

Code: Select all

#Requires AutoHotkey v2.0

*f::SpamKey()

SpamKey() {
	key := SubStr(A_ThisHotkey, 2)
	Spam := SendDownUp.Bind(key)
	SetTimer(Spam, 50)
	KeyWait(key)
	SetTimer(Spam, 0)

	SendDownUp(k) {
		Send '{' k ' down}'
		Sleep 20
		Send '{' k ' up}'
	}
}
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 20:04

boiler wrote:
16 May 2024, 19:43
You can try this just in case:

Code: Select all

#Requires AutoHotkey v2.0

*f::SpamKey()

SpamKey() {
	key := SubStr(A_ThisHotkey, 2)
	Spam := SendDownUp.Bind(key)
	SetTimer(Spam, 50)
	KeyWait(key)
	SetTimer(Spam, 0)

	SendDownUp(k) {
		Send '{' k ' down}'
		Sleep 20
		Send '{' k ' up}'
	}
}

THAT WORKS!!!

manny thanks, though if you have the time id love it if you could try to explain to me how it works
niCode
Posts: 319
Joined: 17 Oct 2022, 22:09

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 20:32

Theleifblower wrote:
16 May 2024, 20:04
though if you have the time id love it if you could try to explain to me how it works
Here's the code with comments. Let us know if you have any other questions.

Code: Select all

#Requires AutoHotkey v2.0

*f::SpamKey()                               ; Wildcard modifier * lets the key work even when holding down a modifier key i.e. Shift, Ctrl, Alt, Win

SpamKey() {
	key := SubStr(A_ThisHotkey, 2)          ; When *f is pressed, A_ThisHotkey is *f. SubStr is returning the string starting at the second position (f)
	Spam := SendDownUp.Bind(key)            ; Binds a value to a function that can be called later. When it is called later, the parameter is automatically inserted for you
    ; Spam := () => SendDownUp(key)           ; Alternative to above line if it makes more sense to you. Uses a fat-arrow function to call a function with a specific parameter

	SetTimer(Spam, 50)                      ; Start a timer that calls a function every 50ms
	KeyWait(key)                            ; Wait for the key pressed to be released
	SetTimer(Spam, 0)                       ; Turn off the timer

	SendDownUp(k) {
		Send '{' k ' down}'                 ; Send key down
		Sleep 20                            ; Wait 20ms
		Send '{' k ' up}'                   ; Send key up
	}
}
User avatar
Theleifblower
Posts: 12
Joined: 16 May 2024, 16:12

Re: Im trying to make a autoclicker that clicks when you hold

16 May 2024, 20:49

niCode wrote:
16 May 2024, 20:32
Theleifblower wrote:
16 May 2024, 20:04
though if you have the time id love it if you could try to explain to me how it works
Here's the code with comments. Let us know if you have any other questions.

Code: Select all

#Requires AutoHotkey v2.0

*f::SpamKey()                               ; Wildcard modifier * lets the key work even when holding down a modifier key i.e. Shift, Ctrl, Alt, Win

SpamKey() {
	key := SubStr(A_ThisHotkey, 2)          ; When *f is pressed, A_ThisHotkey is *f. SubStr is returning the string starting at the second position (f)
	Spam := SendDownUp.Bind(key)            ; Binds a value to a function that can be called later. When it is called later, the parameter is automatically inserted for you
    ; Spam := () => SendDownUp(key)           ; Alternative to above line if it makes more sense to you. Uses a fat-arrow function to call a function with a specific parameter

	SetTimer(Spam, 50)                      ; Start a timer that calls a function every 50ms
	KeyWait(key)                            ; Wait for the key pressed to be released
	SetTimer(Spam, 0)                       ; Turn off the timer

	SendDownUp(k) {
		Send '{' k ' down}'                 ; Send key down
		Sleep 20                            ; Wait 20ms
		Send '{' k ' up}'                   ; Send key up
	}
}
thanks! i actually do have some other questions, im trying make a different macro it should show up as a topic in ask for help v2 (sub category of gaming) if you'd be willing to help that'd be great

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 7 guests