Trying to put multiple scripts in one file

Get help with using AutoHotkey and its commands and hotkeys
Fizzell-1
Posts: 3
Joined: 13 Jun 2018, 07:53

Trying to put multiple scripts in one file

13 Jun 2018, 08:05

The first two scripts work perfect together put whenever i put the third in it says duplicate label please help :P
1st script:

Code: Select all

XButton2::
    While GetKeyState("XButton2", "P"){
        Click
        Sleep 0.000000000000001 ;  milliseconds
    }
Return
2nd:

Code: Select all

F2::
If State=0.000000000000000001
State=Off
else
State=0.000000000000000001
SetTimer SendKey, %State%
Return

SendKey:
Send f
Return
3d
Numpad9::
If State=0.000000000000000001
State=Off
else
State=0.000000000000000001
SetTimer SendKey, %State%
Return

SendKey:
Send e
Return
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Trying to put multiple scripts in one file

13 Jun 2018, 08:09

Try renaming the two identical labels, eg. SendKey1: and SendKey2:
Fizzell-1
Posts: 3
Joined: 13 Jun 2018, 07:53

Re: Trying to put multiple scripts in one file

13 Jun 2018, 08:13

It says the target label does not exist these are the changes i did

Code: Select all

XButton2::
    While GetKeyState("XButton2", "P"){
        Click
        Sleep 0.000000000000001 ;  milliseconds
    }
Return

F2::
If State=0.000000000000000001
State=Off
else
State=0.000000000000000001
SetTimer SendKey1, %State%
Return

SendKey1:
Send f
Return

Numpad9::
If State=0.000000000000000001
State=Off
else
State=0.000000000000000001
SetTimer SendKey, %State%
Return

SendKey2:
Send e
Return
Fizzell-1
Posts: 3
Joined: 13 Jun 2018, 07:53

Re: Trying to put multiple scripts in one file

13 Jun 2018, 08:14

I found the mistake thank you :D
GeekDude
Posts: 854
Joined: 02 Oct 2013, 22:13

Re: Trying to put multiple scripts in one file

13 Jun 2018, 08:35

Where you have two things both named SendKey they conflict. If you rename them to be SendKey1 and SendKey2 they will not conflict anymore. Also, AutoHotkey can't sleep for less than ~15ms so trying to sleep for 0.000000000000001 milliseconds is somewhat pointless. Using 1 would have the same effect.

Code: Select all

XButton2::
While GetKeyState("XButton2", "P"){
	Click
	Sleep 1 ; milliseconds
}
Return


F2::
If State=1
	State=Off
else
	State=1
SetTimer SendKey1, %State%
Return

SendKey1:
Send f
Return


Numpad9::
If State=1
	State=Off
else
	State=1
SetTimer SendKey2, %State%
Return

SendKey2:
Send e
Return

Return to “Ask For Help”

Who is online

Users browsing this forum: A_Birdi, Bing [Bot], flyingDman, gDosomething, Google [Bot], niky45 and 62 guests