Page 1 of 1

Run label in another ahk

Posted: 29 Aug 2019, 04:24
by Pilu
Hi,

I have two ahk script how can i run the secound script label from the first script?
What are the options?

Re: Run label in another ahk  Topic is solved

Posted: 29 Aug 2019, 06:39
by wolf_II
One way would be to "RemoteControl" Second.ahk from inside First.ahk, using onMessage() and SendMessage

Example:

Code: Select all

;  First.ahk

DetectHiddenWindows, On
SendMessage, 12345,,,, R:\Temp\Second.ahk ; this remotely controls a script

Code: Select all

;  Second.ahk

OnMessage(12345, "RemoteControl")
return ; end of auto-execute section



;-------------------------------------------------------------------------------
Foo: ; some label
;-------------------------------------------------------------------------------
    MsgBox,, %A_LineFile%, Line %A_LineNumber%: %A_ThisLabel%
return



;-------------------------------------------------------------------------------
RemoteControl() { ; remote control this script
;-------------------------------------------------------------------------------
    goSub Foo
}
I hope my simple example helps you to get started.

Re: Run label in another ahk

Posted: 30 Aug 2019, 04:14
by Pilu
Thanks your help @wolf_II It worked :)