When starting a new script, I want to catch the PID so that i can close it later, but I get the autohotkey laucher PID, not the scripts PID:
Code: Select all
run 'vlc.ahk', "D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\",,&vlc_pid1 ; starting a script containing my vlc-hotkeys + saving the pid (this is actually the laucher PID)
sleep 200
vlc_pid2 := Wingetpid("D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\vlc.ahk - AutoHotkey") ; catching the PID again for the same script (the path + "AutoHotkey" is part of the script name)
OutputDebug vlc_pid1 ; 15772
OutputDebug vlc_pid2 ; 18120
title_pid1 := Wingettitle("ahk_pid" vlc_pid1)
title_pid2 := Wingettitle("ahk_pid" vlc_pid2)
OutputDebug "title_pid1: " title_pid1 ; C:\Program Files\AutoHotkey\UX\launcher.ahk - AutoHotkey v2.0.11
OutputDebug "title_pid2: " title_pid2 ; D:\Albin\Code\Autohotkey\Autohotkey scripts\Scripts_v2\vlc.ahk - AutoHotkey v2.0.11
ok, so what im getting when trying to catch the PID on run, is the autohotkey launcher PID..
I have other ways to make it work, im mostly curious if there is some workaround for this ?