start initiation of other ahk files

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

start initiation of other ahk files

21 Aug 2018, 02:31

Hi,
I would like to know if it's possible to "jump" to script code in another script (.ahk file)?

for example:

Code: Select all

^j::	
Run, notepad.exe
;initiate call to type_text.ahk
MsgBox, Done!
return
Also, I would like to know if it's possible to jump to a specific point in another script?
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: start initiation of other ahk files

21 Aug 2018, 02:33

afaik you can use the run command to run the AHK script, just like you did with notepad.
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

Re: start initiation of other ahk files

21 Aug 2018, 06:27

WalkerOfTheDay wrote:afaik you can use the run command to run the AHK script, just like you did with notepad.
that works. Thanks
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: start initiation of other ahk files

21 Aug 2018, 10:22

Another idea is that one script uses PostMessage/SendMessage, and the other script handles OnMessage.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
mgroen
Posts: 97
Joined: 13 Jul 2018, 02:22

Re: start initiation of other ahk files

21 Aug 2018, 10:37

jeeswg wrote:Another idea is that one script uses PostMessage/SendMessage, and the other script handles OnMessage.
That is new to me. Could you give me an example? (I am pretty new to AutoHotkey)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: start initiation of other ahk files

21 Aug 2018, 10:57

Here's an example.

Code: Select all

;script1.ahk
q::
DetectHiddenWindows, On
SetTitleMatchMode, 2 ;Contains
if !hWnd := WinExist("\script2.ahk ahk_class AutoHotkey")
	return
PostMessage, 0x5555, 1,,, % "ahk_id " hWnd ;WM_COMMAND := 0x111
Sleep, 5000
PostMessage, 0x5555, 2,,, % "ahk_id " hWnd ;WM_COMMAND := 0x111
return

;script2.ahk
OnMessage(0x5555, "MsgMonitor")
MsgMonitor(wParam, lParam, uMsg, hWnd)
{
	MsgBox, % wParam " " lParam " " uMsg " " hWnd
	Func%wParam%()
}
Func1()
{
	MsgBox, % A_ThisFunc
}
Func2()
{
	MsgBox, % A_ThisFunc
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: BPet, haomingchen1998, Rohwedder, Tvlao and 159 guests