Please help adding to a script

Get help with using AutoHotkey and its commands and hotkeys
polorsport
Posts: 5
Joined: 09 Jun 2018, 15:35

Please help adding to a script

09 Jun 2018, 15:41

I found this script online. But, would like to add the following to it if possible. Any help would be appreciated. Thanks

Please add:

left mouse button 3 times

pause (like a delay)

R key

pause 2 seconds (2 second delay)

Q key

F key

Left mouse button 3 times

Original script:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

SetGlobals(void)
{
global
endLoop := 0
return
}

F5 UP::
{
SleepDuration := 1000
Loop
{
if(endLoop = 1)
{
endLoop := 0
break
}
Send, {W DOWN}
Sleep, %SleepDuration%
Send, {W UP}
Sleep, %SleepDuration%
if(endLoop = 1)
{
endLoop := 0
break
}
Send, {S DOWN}
Sleep, %SleepDuration%
Send, {S UP}
Sleep, %SleepDuration%
if(endLoop = 1)
{
endLoop := 0
break
}
Send, {Space DOWN}
Sleep, %SleepDuration%
Send, {Space UP}
Sleep, %SleepDuration%
}
return
}

F6 UP::
{
if(endLoop = 0)
endLoop = 1
else
endLoop = 0
return
}

F4 UP::
{
SetGlobals(0)
return
}
Last edited by polorsport on 09 Jun 2018, 16:14, edited 1 time in total.
AHKStudent
Posts: 313
Joined: 05 May 2018, 12:23

Re: Please help adding to a script

09 Jun 2018, 15:45

What do you mean by pause?
polorsport
Posts: 5
Joined: 09 Jun 2018, 15:35

Re: Please help adding to a script

09 Jun 2018, 16:04

AHKStudent wrote:What do you mean by pause?
Like a delay between inputs.
AHKStudent
Posts: 313
Joined: 05 May 2018, 12:23

Re: Please help adding to a script

10 Jun 2018, 18:39

polorsport wrote:
AHKStudent wrote:What do you mean by pause?
Like a delay between inputs.
That is a sleep command

Code: Select all

Sleep, 3000 ; = 3 seconds
To send a key the command is

Code: Select all

send, q
Many options to send mouse clicks more than once, see this https://autohotkey.com/board/topic/5028 ... -in-a-row/
polorsport
Posts: 5
Joined: 09 Jun 2018, 15:35

Re: Please help adding to a script

11 Jun 2018, 02:28

Thanks for the reply. I keep getting an error message.

"Error at line 65.

Line Text: xbutton1
Error: Duplicate hotkey.

The program will exit."

So I went, and deleted line 65.

Then I get these errors.

Error: Unexpected "}"

And ever entry I did.

This is what my script looks like after your suggestion. (It doesn't work)

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

SetGlobals(void)
{
global
endLoop := 0
return
}

F5 UP::
{
SleepDuration := 1000
Loop
{
if(endLoop = 1)
{
endLoop := 0
break
{
xbutton1::
Loop 3
{
Send {lbutton down} ; Auto-repeat consists of consecutive down-events (with no up-events).
Sleep 30 ; The number of milliseconds between keystrokes (or use SetKeyDelay).
}
}
Send, {W DOWN}
Sleep, %SleepDuration%
Send, {W UP}
Sleep, %SleepDuration%
if(endLoop = 1)
{
endLoop := 0
break
}
Send, {S DOWN}
Sleep, %SleepDuration%
Send, {S UP}
Sleep, %SleepDuration%
if(endLoop = 1)
{
endLoop := 0
break
}
Send, {Space DOWN}
Sleep, %SleepDuration%
Send, {Space UP}
Sleep, %SleepDuration%
}
return
}
Sleep, 3000 ; = 3 seconds
}
send, r
}
Sleep, 3000 ; = 3 second
Send, q
Sleep, 3000 ; = 3 second
Send, f
Sleep, 3000 ; = 3 second
xbutton1::
Loop 3
F6 UP::
{
if(endLoop = 0)
endLoop = 1
else
endLoop = 0
return
}

F4 UP::
{
SetGlobals(0)
return
}

AHKStudent wrote:
polorsport wrote:
AHKStudent wrote:What do you mean by pause?
Like a delay between inputs.
That is a sleep command

Code: Select all

Sleep, 3000 ; = 3 seconds
To send a key the command is

Code: Select all

send, q
Many options to send mouse clicks more than once, see this https://autohotkey.com/board/topic/5028 ... -in-a-row/
AHKStudent
Posts: 313
Joined: 05 May 2018, 12:23

Re: Please help adding to a script

11 Jun 2018, 03:51

I think you need to learn what { } does.

First two example shows you when you only have one item in a loop you don't have to use { } although it is good practice.

Third example shows that if you have more than one item and you do not use { } only the first item will get looped three times the others (in this case msgbox) will only get looped once (not really looped, the program just executes that line.

The forth shows that if you want to loop more than one item, use { }

Run this code, and press the keys Q etc to try each code and edit it and play with it. ESC key to exit the program.

The error "Error: Unexpected "}"

Means you had an extra } somewhere in your code.


Code: Select all

q::
loop, 3 ;turn on your sound 
{
	SoundBeep, 600, 300
}
return

t::
loop, 3 ;turn on your sound 
SoundBeep, 600, 300
return

w::
loop, 3 ;turn on your sound 

	SoundBeep, 600, 300
	msgbox, Test
return

x::
loop, 3 ;turn on your sound 
{
	SoundBeep, 600, 300
	msgbox, Test
}
return

z::
loop, 3 ;turn on your sound 
{
	SoundBeep, 600, 300
	msgbox, Test
}
return

esc::ExitApp
polorsport
Posts: 5
Joined: 09 Jun 2018, 15:35

Re: Please help adding to a script

22 Jun 2018, 10:30

I tried, but I can't figure this out. I'm not trying to learn coding. This is just a one time code. That I can use for years. If you could do it for me I would really appreciate it.
AHKStudent wrote:I think you need to learn what { } does.

First two example shows you when you only have one item in a loop you don't have to use { } although it is good practice.

Third example shows that if you have more than one item and you do not use { } only the first item will get looped three times the others (in this case msgbox) will only get looped once (not really looped, the program just executes that line.

The forth shows that if you want to loop more than one item, use { }

Run this code, and press the keys Q etc to try each code and edit it and play with it. ESC key to exit the program.

The error "Error: Unexpected "}"

Means you had an extra } somewhere in your code.


Code: Select all

q::
loop, 3 ;turn on your sound 
{
	SoundBeep, 600, 300
}
return

t::
loop, 3 ;turn on your sound 
SoundBeep, 600, 300
return

w::
loop, 3 ;turn on your sound 

	SoundBeep, 600, 300
	msgbox, Test
return

x::
loop, 3 ;turn on your sound 
{
	SoundBeep, 600, 300
	msgbox, Test
}
return

z::
loop, 3 ;turn on your sound 
{
	SoundBeep, 600, 300
	msgbox, Test
}
return

esc::ExitApp

Return to “Ask For Help”

Who is online

Users browsing this forum: AmDeG 11, Evil-e, hanslhansl, makro88, Mipha, vvhitevvizard and 127 guests