I need help
I need help
Hello, I need help with a script for auto clicking generally I need the script to click the letter Z and after a random time in the range of 6 to 10 seconds click the left mouse button wait again a random time in the range of 3 to 5 seconds and click the letter Z again all as a loop enabled by the HOME button and as a script stop END ;x
- WarlordAkamu67
- Posts: 279
- Joined: 21 Mar 2023, 06:52
Re: I need help
Hello and welcome.
Code: Select all
#Requires AutoHotkey v2.0+
#SingleInstance force
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
End::{
global toggle := 0
ToolTip("Off")
SetTimer () => ToolTip(), -1000
return
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
Home:: {
global
toggle := 1
while (toggle) {
the_Loop()
}
return
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
the_Loop() {
Send("z")
Sleep(Random(6000, 10000))
Click()
Sleep(Random(3000, 5000))
return
}
The End.
Re: I need help
Almost works only left click doesn't work I tried adding Left to your script in brackets and it doesn't work '=' I don't understand
- WarlordAkamu67
- Posts: 279
- Joined: 21 Mar 2023, 06:52
Re: I need help
If you need to test out some things, you can play around with the Click as needed. Information about it can be found here in the documentation. Below is a screen snippet of the examples of the Click() function
If you are still unable to get it to work, you can use the Send() function to try and send a {Click}.
If you are still unable to get it to work, you can use the Send() function to try and send a {Click}.
The End.
Re: I need help
I'm a bit new to this environment and previously wrote fairly simple scripts on the first version of autohotkey and they looked like this:
and such a script works normally I tried to ask gpt chat what is going on and what it is caused by but it only spit out its own code for me:
In general I have a feeling that the script and more so the mouse click by script is not working in the game just clicking "with" works fine but LMB and a little I don't understand I tried to change to different options you sent in the screenshot but still the same problem
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Code: Select all
global break_x = 0
Home::
break_x = 1
Send, {LButton down}
Loop
{
Send, {w down}
Sleep, 300
Send, {w up}
Sleep, 100
Send, {d down}
Sleep, 300
Send, {d up}
Sleep, 100
if( break_x = 2)
{
return
}
}
End::
break_x = 2
Send, {LButton up}
return
Code: Select all
#Persistent ; Keep the script running
SetTimer, TriggerClicks, 6000 ; Run the TriggerClicks function every 6000 ms (6 seconds)
return
~z:: ; ~ signifies that the script does not block the Z key
TriggerClicks() ; Call the TriggerClicks function
return
~PgDn:: ; Handling the PageDown key
Toggle := !Toggle ; Toggle the script state (Toggle) to the opposite
Tooltip, Script % (Toggle ? "enabled" : "disabled") ; Display script status
Sleep, 2000 ; Wait for 2 seconds to avoid accidental re-enable/disable of the script
Tooltip ; Hide the tooltip
return
TriggerClicks:
Random, SleepTime, 6000, 8000 ; Randomly choose a sleep time between 6 and 8 seconds
Sleep, %SleepTime% ; Wait according to the randomly chosen time
Click, 6 ; Simulate left mouse button click 6 times
return
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Re: I need help
I tried now to check in notepad is when you enable the script the cursor completely disappears
- WarlordAkamu67
- Posts: 279
- Joined: 21 Mar 2023, 06:52
Re: I need help
I was able to reproduce what you are explaining with the disappearing; however, if I move the mouse it reappears. I am still getting Click() to go through. If I move the mouse off the window it clicks out of Notepad.
The first script you posted looks fine, I didn't test it, and its for AutoHotkey Version 1- as you had said. The 2nd script is again written for AHK Version 1, and you would have to debug it yourself as its generated code.
I didn't need to create the extra function and you can use a Loop with (break/continue/whatever you want) instead of a while loop. There are numerous way to go about script it, so maybe others will have an approach you find more suitable. Here is version 2 code that should look/feel more familiar when compared with your V1 script.
The first script you posted looks fine, I didn't test it, and its for AutoHotkey Version 1- as you had said. The 2nd script is again written for AHK Version 1, and you would have to debug it yourself as its generated code.
I didn't need to create the extra function and you can use a Loop with (break/continue/whatever you want) instead of a while loop. There are numerous way to go about script it, so maybe others will have an approach you find more suitable. Here is version 2 code that should look/feel more familiar when compared with your V1 script.
Code: Select all
#Requires AutoHotkey v2.0+
#SingleInstance force
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
End::{
global break_x := 1
ToolTip("Breaking...") ; Display Notice
SetTimer () => ToolTip(), -1000 ; Clear the ToolTip after 1 second.
return
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
Home:: {
global break_x := 0
Loop {
if (break_x) {
break
}
Send("z")
Sleep(Random(6000, 10000))
Click()
Sleep(Random(3000, 5000))
}
return
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
The End.
- DuckingQuack
- Posts: 222
- Joined: 20 Jan 2023, 18:20
Re: I need help
I decided to try to come up with a version that did not use sleeps, but timers instead.
I came up with two ways to go about it, one function that uses variables or two functions that call each other. The single turned out better but I'm going to post both as options for you.
EDIT: Came up with a third one that's infinitely expandable, and it's super compact.
Single Function
Double Function
EDIT: Infinitely Expandable
I came up with two ways to go about it, one function that uses variables or two functions that call each other. The single turned out better but I'm going to post both as options for you.
EDIT: Came up with a third one that's infinitely expandable, and it's super compact.
Single Function
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
InstallMouseHook
InstallKeybdHook
Esc::ExitApp
on := False
;;;;;;;;;;;;;;;;;;;;;;;;;
; Single button toggle option (change to preferred key or remove)
F1:: {
Global
If on := !on
Next()
}
;;;;;;;;;;;;;;;;;;;;;;;;;
; Requested Home:Start button and End:Stop button
#HotIf !on
Home:: {
Global on := True
Next()
}
#HotIf
End:: Global on := False
;;;;;;;;;;;;;;;;;;;;;;;;;
; Function that does all the work
Next(){
Static Press := False
If Press := !Press
Key := "z", Period := Random(-6000, -10000)
else Key := "{Click}", Period := Random(-3000, -5000)
Send(Key), SetTimer(Next, Period * on)
If on = False
Press := False
}
Double Function
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
InstallMouseHook
InstallKeybdHook
Esc::ExitApp
Global on := False
F1:: {
Global on := !on
FnZ()
}
Home:: {
Global on := True
FnZ()
}
End:: Global on := False
FnZ(){
Send("z")
SetTimer(FnClick, Random(-6000, -10000) * on)
}
FnClick(){
Click
SetTimer(FnZ, Random(-3000, -5000) * on)
}
EDIT: Infinitely Expandable
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
InstallMouseHook
InstallKeybdHook
Esc::ExitApp
on := False
F1:: {
Global on := !on
Stuff()
}
a := ["z", -6000, -10000]
b := ["{Click}", -3000, -5000]
KeyArray := [a,b]
Stuff(){
Global
Try Key := KeyArray[(Mod(((++X:=on<1?-1:(X??0))-1),KeyArray.Length)+1)]
Send(Key[1]), SetTimer(Stuff, Random(Key[2], Key[3]) * on)
}
Best of Luck,
The Duck
The Duck
Who is online
Users browsing this forum: vanove and 19 guests