close an AHK scrip from another AHK script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BeginnerGamer
Posts: 1
Joined: 26 Jun 2022, 11:05

close an AHK script from another AHK script

Post by BeginnerGamer » 26 Jun 2022, 11:57

Hello,

I would like to close an AHK script that is running in a loop, FROM ANOTHER AHK SCRIPT.


I try something :

My loop is "LOOOP.ahk" :

Loop
{
MsgBox nice
}


And I want close my loop with "CLOSE LOOOP.ahk" :

ExitApp, LOOOP.ahk


But my script "CLOSE LOOOP.ahk" does not work. :(


I don't know if I was understanding, but if someone could help me ..

User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: close an AHK scrip from another AHK script

Post by mikeyww » 26 Jun 2022, 12:15

Welcome to this AutoHotkey forum!

See documentation & syntax for ExitApp, which does not accept a script as a parameter. You cannot make up your own syntax; you need to use what AHK provides.

To close another script, use DetectHiddenWindows, On, and then :arrow: WinClose followed by the script's window title. A script's window title starts with the full path to the script, which is sufficient. Window titles are case-sensitive.

Life gets easier if you combine your scripts. You can then just use a variable to indicate when to break the loop.

Code: Select all

DetectHiddenWindows, On
WinClose, %A_ScriptDir%\test.ahk ahk_class AutoHotkey
Explained: WinCloseWinTitle

Post Reply

Return to “Ask for Help (v1)”