Scroll Wheel Clicker

Ask gaming related questions (AHK v1.1 and older)
iot
Posts: 1
Joined: 21 Mar 2018, 18:57

Scroll Wheel Clicker

21 Mar 2018, 19:17

Hello. I have just joined the AutoHotkey Community and I started learning how to use AutoHotKey.

I'm trying to make a script that:
1. When you scroll your mouse up or down, it clicks.
2. To toggle, press the middle click button.
3. Has a delay or randomization so it as if a normal person is clicking at the same speed as the scroll wheel click.

I have this so far, but it doesn't work correctly:

Code: Select all

#NoEnv
SendMode Input

MButton::
Toggle := !Toggle
While Toggle {
SetMouseDelay, 250
WheelUp::MouseClick, Left,,,1
WheelDown::MouseClick, Left,,,1
}
Return
Can anyone help with just fixing the code, or help me add a randomization?

Thanks!
gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: Scroll Wheel Clicker

21 Mar 2018, 20:15

For context-sensitive hotkeys, use #-directives:

Code: Select all

MButton::
Toggle := !Toggle
if Toggle 
	SetMouseDelay, 250
else 
	SetMouseDelay, 10			; reset to default
return

#if toggle						; context-sensisitive hotkeys start here
WheelUp::MouseClick, Left,,,1
WheelDown::MouseClick, Left,,,1
#if							; turn off context-sensitivity
For randomization, you could use the Random command. Are you trying to to do this?

Code: Select all

MButton::
Toggle := !Toggle
if Toggle 
{	
	Random, ms , 150, 250		; create number between 150 and 250
	SetMouseDelay, % ms
}
else 
	SetMouseDelay, 10			; set to default
return
I have no experience in automating games and no idea if SetMouseDelay is the right kind of approach here. It might be better to modify Wheelup and Wheeldown to multiline hotkeys and add a Sleep instead - but it is just a guess:

Code: Select all

MButton::
Toggle := !Toggle
Return

#if Toggle
WheelUp::					; you can stack hotkeys that should do the same
WheelDown::
MouseClick, Left,,,1
Random, ms , 150, 250		; create number between 150 and 250
Sleep % ms
Return
#if
I am sure, our gaming experts can tell you the best way to go.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Scroll Wheel Clicker

22 Mar 2018, 08:33

Code: Select all

#if Toggle
WheelUp::					; you can stack hotkeys that should do the same
WheelDown::
MouseClick, Left,,,1
Random, ms , 150, 250		; create number between 150 and 250
Sleep % ms
Return
#if
The sleep does absolutely nothing.
Besides, you do not need it. The requirement was self-contradicting.
"Has a delay or randomization so it as if a normal person is clicking at the same speed as the scroll wheel click"
If you want it to click "at the same speed as the scroll wheel click", then by definition there is no randomization.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: sofista and 160 guests