Popleft > 2025-08-04 14:28
taskkill /t /f /im AutoHotkey.exe > nul 2>&1
taskkill /t /f /im AutoHotkeyU64.exe > nul 2>&1
taskkill /t /f /im AutoHotkeyUX.exe > nul 2>&1
taskkill /t /f /im InternalAHK.exe > nul 2>&1
taskkill /t /f /im AutoHotkey > nul 2>&1#Requires AutoHotkey v1.1.33
DetectHiddenWindows On
WinGet ahk, List, ahk_class AutoHotkey
Loop % ahk
If (ahk%A_Index% != A_ScriptHwnd)
WinClose % "ahk_id" ahk%A_Index%
ExitAppQuote:ahk_class
ahk_exe
ahk_pid
Quote:ahk_class JeanLalonde.ca
ahk_exe QuickAccessPopup-64-bit.exe
ahk_pid 20344
Jean Lalonde > 2025-08-04 15:12
DetectHiddenWindows On
WinGet, ahk, List, ahk_class AutoHotkey
Loop % ahk
{
WinGet, OutputVar, ProcessName, % "ahk_id " . ahk%A_Index%
If (ahk%A_Index% != A_ScriptHwnd) and (OutputVar != "QuickAccessPopup.exe")
WinClose % "ahk_id" ahk%A_Index%
}
ExitAppPopleft > 2025-08-05 14:21
Xavier > 2025-08-08 00:38
Xavier > 2025-08-09 21:07
;; above first return, in auto-exe
iniread, KillAHK, Logging, KillAHK, 0
if (KillAHK)
{
tooltip x AHKs x is `n Killing It...
iniwrite, 0, %inifile%, Logging, KillAHK
sleep 150
goto KillAHK
}
if ( RestartAfterKill )
{
RunScriptsonBOOT() ;; define which side scripst you want to run on a fresh main script run here (if any)
IniWrite, 0, %inifile%, Logging, RestartAfterKill
}
;; Return ; First Return
;-------------------------
;; below auto-exe
^#!End:: ;; Kill all AHK Scripts running in background
KillAHK:
If !A_IsAdmin
{
iniwrite, 1, %inifile%, Logging, RestartAfterKill
sleep 100
Run *RunAs "%A_ScriptFullPath%"
}
run, cmd.exe /c "taskkill /f /im AutoHotkeyU64.exe"
sleep 100
run, cmd.exe /c "taskkill /f /im autohotkey.exe"
sleep 100
Run, cmd.exe /c "taskkill /f /im autohotkeyu32.exe"
sleep 100
run, cmd.exe /c "taskkill /f /im autohotkeyux.exe"
sleep 100
run, cmd.exe /c "taskkill /f /im autohotkey64.exe"
sleep 100
run, cmd.exe /c "taskkill /f /im autohotkey64_UIA.exe"
sleep 100
run, cmd.exe /c "taskkill /f /im AutoHotkeyU64_UIA.exe"
;; I run all my scripts with UI Access, found it best to keep this one at the bottom of this kill list.
sleep 100
Exitapp
return
returnPopleft > 2025-08-11 16:17
(2025-08-09 21:07)Xavier Wrote: Try this snippet in your script.
[...]
Run, cmd.exe /c taskkill /f /im AutoHotkeyU64.exe,, Hide
Run, cmd.exe /c taskkill /f /im autohotkey.exe,, Hide
Run, cmd.exe /c taskkill /f /im autohotkeyu32.exe,, Hide
Run, cmd.exe /c taskkill /f /im autohotkeyux.exe,, Hide
Run, cmd.exe /c taskkill /f /im autohotkey64.exe,, Hide
Run, cmd.exe /c taskkill /f /im autohotkey64_UIA.exe,, Hide
Run, cmd.exe /c taskkill /f /im AutoHotkeyU64_UIA.exe,, Hide
Run, "%A_ScriptDir%\the script i need to automatically re-run.ahk"
ExitApp/*
This scripts closes all running AHK scripts - except this one. It does this by identifying them by the EXE that runs them i.e. it does not identify them by their Windows class nor the title of their window
It does not close [on purpose]:
● AutoHotkey Help [because that process uses the hh.EXE file of Windows]
● Quick Access Popup [because that process has its own EXE]
● SciTE4AutoHotkey [because that process has its own EXE]
*/
; #SingleInstance ; Do not use this - so that the user will have a greater chance to end a whack-a-mole situation by being able to manually execute this panic button multiple times
WMI_query := "Select * from Win32_Process where " ; This looks in Windows Management Instrumentation list for all running processes matching defined AutoHotkey executable variants
. "Name='AutoHotkey.exe' " ; V1 / V2 main runner
. "or Name='AutoHotkey32.exe' " ; V2 32-bit
. "or Name='AutoHotkey32_UIA.exe' " ; V2 32-bit User Interface Automation build
. "or Name='AutoHotkey64.exe' " ; V2 64-bit
. "or Name='AutoHotkey64_UIA.exe' " ; V2 64-bit User Interface Automation build
. "or Name='AutoHotkeyA32.exe' " ; V1 32-bit ANSI
. "or Name='AutoHotkeyU32.exe' " ; V1 32-bit Unicode
. "or Name='AutoHotkeyU32_UIA.exe' " ; V1 32-bit User Interface Automation build
. "or Name='AutoHotkeyU64.exe' " ; V1 64-bit Unicode
. "or Name='AutoHotkeyU64_UIA.exe' " ; V1 64-bit User Interface Automation build
. "or Name='AutoHotkeyUX.exe' " ; V1 experimental build
. "or Name='InternalAHK.exe'" ; SciTE4AutoHotkey editor internal runner
WMI_COM_item := ComObjGet("winmgmts:") ; This runs system-level queries and fetches information about running processes
AHK_processes_list := WMI_COM_item.ExecQuery(WMI_query) ; This returns a collection of process objects matching the query criteria
this_file_ID := DllCall("GetCurrentProcessId") ; This gets the PID of this file in order to prevent its closure - so that this script will remain being able to automatically execute pre-defined commands after performing the task of killing all others scripts
for each_process in AHK_processes_list ; This loop through each found AutoHotkey process and kills it - if it is not this file
{
process_an_ID := each_process.ProcessId
if (process_an_ID != this_file_ID)
Process, Close, %process_an_ID%
}
; The below repeats the above task in order to deal with any [re]executions of AHK scripts that might happen in middle of initial kiliing procedure
max_retries_number := 3
retry_delay_in_miliseconds := 555
Loop % max_retries_number
{
Sleep, %retry_delay_in_miliseconds%
new_AHK_processes := WMI_COM_item.ExecQuery(WMI_query)
found_new := false
for proc in new_AHK_processes
{
if (proc.ProcessId != this_file_ID)
{
Process, Close, % proc.ProcessId
found_new := true
}
}
if (!found_new)
break
}
Run, "%A_ScriptDir%\the script i need to automatically re-run.ahk" ; This re-executes necessary script
ExitApp(2025-08-11 16:17)Popleft Wrote: [...]
I have tested the above script and I think my problem became solved
Popleft > 2025-08-12 08:32
(2025-08-11 16:17)Popleft Wrote: Although this script could use
[...]
WMI_query := "Select * from Win32_Process where " . "and not CommandLine like '%TillaGoto.ahk%'" ; [exclude](2025-08-04 14:28)Popleft Wrote: [...]
A] A panic button in form of BAT file pinned at the beginning of always visible Taskbar of Windows
[...]
:: In order to work this BAT file must be executed As Administrator
@echo off
setlocal enabledelayedexpansion
set "AHK_executables=AutoHotkey.exe AutoHotkey32.exe AutoHotkey32_UIA.exe AutoHotkey64.exe AutoHotkey64_UIA.exe AutoHotkeyA32.exe AutoHotkeyU32.exe AutoHotkeyU32_UIA.exe AutoHotkeyU64.exe AutoHotkeyU64_UIA.exe AutoHotkeyUX.exe InternalAHK.exe"
for %%E in (%AHK_executables%) do (
for /f "skip=1 delims=" %%L in ('wmic process where "name='%%E'" get CommandLine^,ProcessId 2^>nul') do (
set "line_currently_processed=%%L"
if defined line_currently_processed (
for /f "tokens=* delims=" %%a in ("!line_currently_processed!") do set "line_currently_processed=%%a"
echo !line_currently_processed! | findstr /i "ProcessId" >nul && (
) || (
echo !line_currently_processed! | findstr /i /c:"TillaGoTo.ahk" >nul
if errorlevel 1 (
for /f "tokens=* delims= " %%p in ("!line_currently_processed!") do (
for %%z in (!line_currently_processed!) do set "process_ID=%%z"
taskkill /f /pid !process_ID! >nul 2>&1
)
)
)
)
)
)
endlocal