Need help with hotkey script Topic is solved
Need help with hotkey script
Hello,
I'm really new to autohotkey but I would like some help with a script. I need it for a steam mmo so I dont have to click my mouse right key endlessly to attack enemies in game. What I wanted to do was to be able to have a key, for example Num0 key as the activation key to toggle my right mouse button to continuously click until that same Num0 key is pressed again to stop it.
So when I press num0 my right mouse clicks 3-5 times per second. The cps isnt important in the game as it will only click as fast as your attack speed level is raised to but this script would be great if anyone can educate me please?!
I'm really new to autohotkey but I would like some help with a script. I need it for a steam mmo so I dont have to click my mouse right key endlessly to attack enemies in game. What I wanted to do was to be able to have a key, for example Num0 key as the activation key to toggle my right mouse button to continuously click until that same Num0 key is pressed again to stop it.
So when I press num0 my right mouse clicks 3-5 times per second. The cps isnt important in the game as it will only click as fast as your attack speed level is raised to but this script would be great if anyone can educate me please?!
Re: Need help with hotkey script Topic is solved
Welcome to this AutoHotkey forum!
Code: Select all
#Requires AutoHotkey v2.0
Numpad0:: {
Static on := False
SetTimer () => Click('R'), 80 * on := !on
}
Re: Need help with hotkey script
Thanks very much this script works. But for some strange reason it will only work on any other window except the game window. Would I have to enter the game window program at the top of the script for example:mikeyww wrote: ↑21 Jan 2023, 17:43Welcome to this AutoHotkey forum!
Code: Select all
#Requires AutoHotkey v2.0 Numpad0:: { Static on := False SetTimer () => Click('R'), 80 * on := !on }
Also would it be possible to lower the click count. I tried setting a timer for 5 clicks per second as the current one is 1000 cps.
Code: Select all
Redstone.exe
Numpad0:: {
Static on := False
SetTimer () => Click('R'), 80 * on := !on
}
Re: Need help with hotkey script
I cannot troubleshoot your specific game, but these are the tips, which include testing running as admin. viewtopic.php?f=7&t=11084. Some games block scripting. Search the forum for tips about your specific game.
The 80 is the timer frequency in milliseconds. The click will execute at that frequency. You can try different values. Since other things are happening with this script and other programs at the same time, the effect is never precise, or, well, not usually.
#IfWinActive can be used to define a window context for a hotkey. There is no point in adding it until you get the basic script working.
The 80 is the timer frequency in milliseconds. The click will execute at that frequency. You can try different values. Since other things are happening with this script and other programs at the same time, the effect is never precise, or, well, not usually.
#IfWinActive can be used to define a window context for a hotkey. There is no point in adding it until you get the basic script working.
- DuckingQuack
- Posts: 221
- Joined: 20 Jan 2023, 18:20
Re: Need help with hotkey script
@mikeyww Is the state of "on" being toggled by the assignment in the period parameter?
Also, is this the correct page for the documentation regarding the "Fat Arrow Function?" The section on this page does not seem to support the way you have it working, at least, it doesn't explain the syntax you used.
Code: Select all
Static on := False
Code: Select all
on := !on
Best of Luck,
The Duck
The Duck
Re: Need help with hotkey script
Hello,
Yes, you have cited the toggle correctly. A timer specifies the function object to call. A fat arrow function defines a simple function and returns the function object. Thus, a fat arrow function can be used in a SetTimer, because it returns the function object. My script confirms it.
The documentation for fat arrow function notes that specifying the function name is optional.
Just as with other function definitions, if parameters are not used, then () can be specified.
Yes, you have cited the toggle correctly. A timer specifies the function object to call. A fat arrow function defines a simple function and returns the function object. Thus, a fat arrow function can be used in a SetTimer, because it returns the function object. My script confirms it.
The documentation for fat arrow function notes that specifying the function name is optional.
Just as with other function definitions, if parameters are not used, then () can be specified.
- DuckingQuack
- Posts: 221
- Joined: 20 Jan 2023, 18:20
Re: Need help with hotkey script
That’s outside my realm of understanding at the moment, but I’ll get there.
Best of Luck,
The Duck
The Duck