Comments are appreciated! It works on my computer, but there might be bugs, please tell me if you find any.
Heres the code:
;create Running Scripts context menu menu,ScriptsMenu,Add,Edit Script,ScriptEdit menu,ScriptsMenu,Add,Reload Script,ScriptReload menu,ScriptsMenu,Add,Close Script,ScriptClose gui, add, text,,Below is a list of all currently running, uncompiled AutoHotkey scripts.`nRight Click on a script to Edit, Reload, or close it. gui, add, button,gUpdateList,Update List gui, add, ListView,AltSubmit r20 w580 vScriptList gListViewClick,ScriptName:|PID gui, show,,Script Manager return UpdateList: output := CMDret_RunReturn("WMIC path win32_process get Processid,Commandline") LV_Delete() loop, parse, output,`n, { ifinstring,A_loopfield,autohotkey.exe { ;extract the script name and pid from each line that contains "autohotkey.exe" stringgetpos,pos3,A_loopfield,",l3 stringgetpos,pos4,A_loopfield,",l4 pos3 := pos3 + 1 stringmid,scriptname,A_loopfield,% pos3 +1 ,% pos4 - pos3 stringtrimleft,pid,A_loopfield,% pos4+1 stringreplace,pid,pid,%A_space%,,A stringtrimright,pid,pid,2 LV_Add("",scriptname,pid) } } LV_ModifyCol() return ListViewClick: ;open context menu if A_guievent = RightClick { if A_eventinfo > 0 { LV_GetText(rc_scriptname,A_eventinfo,1) LV_GetText(rc_scriptPID,A_eventinfo,2) menu, ScriptsMenu, show, %A_guix%, %A_guiy% } } return ;actions to perform on scripts ScriptEdit: ; read from the regsitry how this person edits scripts and run accordingly regread,editcommand,HKey_Classes_root,Autohotkeyscript\shell\edit\command stringreplace,editcommand,editcommand,`%1,%rc_scriptname% run, %editcommand% return ScriptReload: ;extract the scripts dir and run it from its own dir stringreplace,rc_scriptname,rc_scriptname,/,\,a stringgetpos,pos,rc_scriptname,\,r1 stringleft,dir,rc_scriptname,%pos% run, %rc_scriptname%, %dir% return ScriptClose: ;end the process using its pid process, close, %rc_scriptPID% Gosub, UpdateList return ;CMD return function CMDret_RunReturn(CMDin) ; CMDret 1.08 beta by corrupt { Global cmdretPID idltm := A_TickCount + 20 CMsize = 1 VarSetCapacity(CMDout, 1, 32) VarSetCapacity(sui,68, 0) VarSetCapacity(pi, 16, 0) VarSetCapacity(pa, 12, 0) Loop, 4 { DllCall("RtlFillMemory", UInt,&pa+A_Index-1, UInt,1, UChar,12 >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&pa+8+A_Index-1, UInt,1, UChar,1 >> 8*A_Index-8) } IF (DllCall("CreatePipe", "UInt*",hRead, "UInt*",hWrite, "UInt",&pa, "Int",0) <> 0) { Loop, 4 DllCall("RtlFillMemory", UInt,&sui+A_Index-1, UInt,1, UChar,68 >> 8*A_Index-8) DllCall("GetStartupInfo", "UInt", &sui) Loop, 4 { DllCall("RtlFillMemory", UInt,&sui+44+A_Index-1, UInt,1, UChar,257 >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&sui+60+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&sui+64+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8) DllCall("RtlFillMemory", UInt,&sui+48+A_Index-1, UInt,1, UChar,0 >> 8*A_Index-8) } IF (DllCall("CreateProcess", Int,0, Str,CMDin, Int,0, Int,0, Int,1, "UInt",0, Int,0, Int,0, UInt,&sui, UInt,&pi) <> 0) { Loop, 4 cmdretPID += *(&pi+8+A_Index-1) << 8*A_Index-8 Loop { idltm2 := A_TickCount - idltm If (idltm2 < 10) { DllCall("Sleep", Int, 10) Continue } IF (DllCall("PeekNamedPipe", "uint", hRead, "uint", 0, "uint", 0, "uint", 0, "uint*", bSize, "uint", 0 ) <> 0 ) { Process, Exist, %cmdretPID% IF (ErrorLevel OR bSize > 0) { IF (bSize > 0) { VarSetCapacity(lpBuffer, bSize+1) IF (DllCall("ReadFile", "UInt",hRead, "Str", lpBuffer, "Int",bSize, "UInt*",bRead, "Int",0) > 0) { IF (bRead > 0) { TRead += bRead VarSetCapacity(CMcpy, (bRead+CMsize+1), 0) CMcpy = a DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", &CMDout, "Int", CMsize) DllCall("RtlMoveMemory", "UInt", &CMcpy+CMsize, "UInt", &lpBuffer, "Int", bRead) CMsize += bRead VarSetCapacity(CMDout, (CMsize + 1), 0) CMDout=a DllCall("RtlMoveMemory", "UInt", &CMDout, "UInt", &CMcpy, "Int", CMsize) } } } } ELSE break } ELSE break idltm := A_TickCount } } cmdretPID= DllCall("CloseHandle", UInt, hWrite) DllCall("CloseHandle", UInt, hRead) } IF (StrLen(CMDout) < TRead) { VarSetCapacity(CMcpy, TRead, 32) TRead2 = %TRead% Loop { DllCall("RtlZeroMemory", "UInt", &CMcpy, Int, TRead) NULLptr := StrLen(CMDout) cpsize := Tread - NULLptr DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", (&CMDout + NULLptr + 2), "Int", (cpsize - 1)) DllCall("RtlZeroMemory", "UInt", (&CMDout + NULLptr), Int, cpsize) DllCall("RtlMoveMemory", "UInt", (&CMDout + NULLptr), "UInt", &CMcpy, "Int", cpsize) TRead2 -- IF (StrLen(CMDout) > TRead2) break } } StringTrimLeft, CMDout, CMDout, 1 Return, CMDout }