Code: Select all
ProcessList()
{
;This is the correct order for when the apps were started
PL := new ObjectOrder()
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process")
{
if (process.CommandLine != "")
{
CL:=Trim(StrReplace(process.CommandLine,"""","",,2)," ")
PL[CL]:={Process:process.Name,PID:process.ProcessId}
if InStr(CL,"chrome.exe --disable-preconnect")
{
;how can I make this return all window id's/hwnds?
; this returns pid (not id) -> msgbox % CL "`n" process.ProcessId
}
}
}
}
class ObjectOrder
{
order := []
__Set(k){
this.order.push(k)
}
_NewEnum(){
return new this.customEnum(this)
}
class customEnum
{
__New(obj){
this.obj := obj
this.order := obj.order
this.counter := 1
}
Next(ByRef k, ByRef v := ""){
if (this.counter <= this.order.maxIndex()){
k := this.order[this.counter++]
v := this.obj[k]
return true
}
return false
}
}
}