Retrieve all ID/HWNDs for a specific process with parameters

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Retrieve all ID/HWNDs for a specific process with parameters

27 Feb 2017, 18:34

I'm trying to list all open windows for a specific process with parameters. Can anyone help me out with this code? Much appreciated. :)

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		
		}
	}
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 202 guests