it took me a while to comprehend it.. wonder how you do it!

have almost finished adapting the code for my script...
will let you know if I have any stubborn problems

I am aware that reviving old posts is generally frowned upon, but I thought I would point out an alternative solution in case someone (as I did) finds this post in a search for a similar problem.
This issue can also be resolved using a hidden gui in the running script and using the ControlSetText command to send data.
main script:
gui, add, edit, w50 h20 vedit1_var gedit1_sub ;lines 1 and 2 create a hidden gui with an edit control. gui, show, hide, scriptcomwin_1 return edit1_sub: ;whenever the text in the edit control is changed this subroutine is launched. { gui, submit gosub, label%edit1_var% ;this gosub launches a subroutine based on the number entered into the edit control. } return label1: ;subroutine launched if the number 1 is sent to the edit control. { msgbox, ABC } return label2: ;subroutine launched if the number 2 is sent to the edit control. { msgbox, XYZ } return
command1:
detecthiddenwindows, on ;allows the script to detect hidden windows. controlsettext, edit1, 1, scriptcomwin_1 ;sends a text string to the first edit control in a specified window.
command2:
detecthiddenwindows, on ;allows the script to detect hidden windows. controlsettext, edit1, 2, scriptcomwin_1 ;sends a text string to the first edit control in a specified window.
If you have the main script running, launching one of the command scripts will cause the main script to run the corresponding subroutine. This method is reliable, simple and (IMHO) easier to work with than the other solutions posted above.