Page 1 of 1

2 Macros in 1 Script With Toggle

Posted: 14 Sep 2017, 10:45
by dangerel
Hallo. I dont know Eng so much. I need to run 2 macros in 1 script with toggle key, i have a script but its not working. Msgbox saying to me "Line 23 SendTheKey - Error: Duplicate label - Program will exit."

Code

LShift::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey, 20
Else
SetTimer, SendTheKey, Off
Return

SendTheKey:
SendInput 7
SendInput 7
SendInput 8
Return

RShift::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey, 100
Else
SetTimer, SendTheKey, Off
Return

SendTheKey: line 23 is here
SendInput z
SendInput 3
SendInput z
SendInput 3
Return

Re: 2 Macros in 1 Script With Toggle  Topic is solved

Posted: 14 Sep 2017, 21:55
by yessorryno
Hi

The problem is duplicate label.

There can not be two identical to the address(SendTheKey:,SendTheKey1:)

Change the code to the following, you can successfully execute

Code: Select all

LShift::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey, 20
Else
SetTimer, SendTheKey, Off
Return

SendTheKey:
SendInput 7
SendInput 7
SendInput 8
Return

RShift::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey1, 100
Else
SetTimer, SendTheKey1, Off
Return

SendTheKey1: 
SendInput z
SendInput 3
SendInput z
SendInput 3
Return

Re: 2 Macros in 1 Script With Toggle

Posted: 16 Sep 2017, 02:08
by dangerel
yessorryno wrote:Hi

The problem is duplicate label.

There can not be two identical to the address(SendTheKey:,SendTheKey1:)

Change the code to the following, you can successfully execute

Code: Select all

LShift::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey, 20
Else
SetTimer, SendTheKey, Off
Return

SendTheKey:
SendInput 7
SendInput 7
SendInput 8
Return

RShift::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey1, 100
Else
SetTimer, SendTheKey1, Off
Return

SendTheKey1: 
SendInput z
SendInput 3
SendInput z
SendInput 3
Return
thx its working ^-^