Help with using this function please, using multiple parameters Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gaberiel__2
Posts: 14
Joined: 18 Jan 2023, 14:18

Help with using this function please, using multiple parameters

Post by gaberiel__2 » 18 Jan 2023, 14:25

Hello,

I have been messing with this amazing function I found on the old forums. There is not much information on it.

I tried to figure it out on my own but to no avail. I could really use some help with. Here is the link to it.

So far I can only seem to pass one parameter to it, but reading his brief description it seems possible to pass multiple parameters to it. If I am mistaken please let me know.

I would like to invoke the function like this WinGetAll("Title", Class', 'Hwnd', 'Process', 'PID') , so that it will return all the properties of a window per line:

Code: Select all

[Window #1 Title],[Window #1 Class], [Window #1 Hwn], [Window #1 Process], [Window #1 PID]
[Window #2 Title],[Window #2 Class], [Window #2 Hwn], [Window #2 Process], [Window #2 PID]
[Window #3 Title],[Window #3 Class], [Window #3 Hwn], [Window #3 Process], [Window #3 PID]
<etc etc >
With my experimentations, I was only able to use two parameters at once:

Code: Select all

WinTitles := WinGetAll("Title", "On")
WinTitles := WinGetAll("Title", "Off")
I am very new to AHK, There may be much better solutions. If so please let me know.
I just need a reliabe way to get every window and its properties listed in a single line:

Code: Select all

[Window #1 Title],[Window #1 Class], [Window #1 Hwn], [Window #1 Process], [Window #1 PID]
With the option to hide system windows such as svchost.exe / csrss.exe / services.exe etc

Any help would be greatly appreciated!

ShatterCoder
Posts: 81
Joined: 06 Oct 2016, 15:57

Re: Help with using this function please, using multiple parameters  Topic is solved

Post by ShatterCoder » 18 Jan 2023, 19:05

Here is an example, you may want to tweak the 2nd function parse_out() to change the format of your output text, but play with it and see what you get.

Code: Select all

MsgBox, % parse_out(WinListAll())
return

WinListAll() ;this function returns an array containing title, pname, class, hwnd, and pid for all windows open
{
   out := {}
   WinGet, all, list ;get all hwnd
   loop, % all
   {
      WinGetTitle, WTitle, % "ahk_id " all%A_Index%
      WinGet, PName, ProcessName, % "ahk_id " all%A_Index%
      WinGetClass, WClass, % "ahk_id " all%A_Index%
      HWND := all%A_Index%
      WinGet, PID, PID, % "ahk_id " all%A_Index%
      out.push({title: WTitle, pname: PName, class: WClass, hwnd: HWND, pid: PID})
   }
   return out
}

parse_out(arr_in) ;this function takes in an array and returns an output string
{
   list := ""
   for key, val in arr_in
   {
      list .= "Window #" key " title: " val.title
      list .= ", Window #" key " Process Name: " val.pname
      list .= ", Window #" key " Class: " val.class
      list .= ", Window #" key " HWND: " val.HWND
      list .= ", Window #" key " PID: " val.PID
      list .= "`n"
   }
   return list
}

gaberiel__2
Posts: 14
Joined: 18 Jan 2023, 14:18

Re: Help with using this function please, using multiple parameters

Post by gaberiel__2 » 04 Feb 2023, 01:51

Wow! This is great. Thanks allot

Post Reply

Return to “Ask for Help (v1)”