0
votes

I cannot close Everything.exe with autohotkey. I cant even get the window id using this;

if WinExist("ahk_class Notepad") or WinExist("ahk_class" . ClassName)
WinActivate  ; Uses the last found window.

MsgBox % "The active window's ID is " . WinExist("A")
Return

it should return similar to this which all other apps on PC do!

The Active Windows ID is 0x013017e 

I have already tried

StartClose("Everything.exe")

StartClose(exe)
    {
    Process, Exist, %exe% ; check to see if program is running
    If (ErrorLevel = 0) ; If program is not running -> Run
    {
    Run, %exe%
     }
 Else ; If program is running, ErrorLevel = process id for the target program -> 
 Close
    {
     Process, Close, %ErrorLevel%
     }
 }
 return

and this

Process, Close, Everything.exe

Process, Close, ahk_class EVERYTHING

Process, Close, ahk_exe Everything.exe

Help!

1
Everything has two processes, one for the service running in the background, and the other for the UI. For me, Process, Exist returns the PID of the service, which is running in the SYSTEM context and therefore fails to close unless you run AHK as SYSTEM.Endre Both

1 Answers

-1
votes
CloseProcess(PidOrExe){
    Processes:=ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
    for Process in Processes
        If (Process.Name=PidOrExe || Process.ProcessID=ParentPidOrExe)
            Process,Close,% process.ProcessID 
}