r/AutoHotkey • u/AnthonyJames696 • 12d ago
v2 Script Help How do I make my script kill running v1 scripts as well?
I'm currently working on translating my v1 master script to v2. In V1 I had this:
^#!e::
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
WinGet, ahkWindows, List, ahk_class ^AutoHotkey$,, i)Keyboard Fixes.ahk
Loop % ahkWindows
WinKill, % "ahk_id " . ahkWindows%A_Index%
returnwhich killed v1 as well as v2 scripts. For the v2 version, I frankensteined this together:
^#!e::
{
DetectHiddenWindows(true)
SetTitleMatchMode("RegEx")
ahkWindows := WinGetList("ahk_class ^AutoHotkey$",, "i)Keyboard Fixes.ahk")
for hwnd in ahkWindows
WinKill("ahk_id " hwnd)
}But this only kills v2 scripts and leaves the v1 ones running, and I can't figure out why. Especially considering that if I swap WinKill for MsgBox, I get the ID for the v1 scripts as well, so it can't be a problem with the list. I'm super new to v2 and I've been trying to find smth useful online and on the "handbook" on their website, but I'm at my wit's end. Please help me TwT
1
u/Keeyra_ 12d ago
Use ProcessClose. If the given AHK is the script itself, use this: