One window func for them all!

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Bugz000
Posts: 93
Joined: 30 Sep 2013, 10:01

One window func for them all!

11 Aug 2018, 07:49

https://pastebin.com/k8whGyFK

quick little function i put together due to someone having a bug where AHK_EXE was not working that can find any window attribute from any other attribute, for instance
if you want to get the PID from the window transparency? sure!
how about the name of the EXE from the window style? absolutely!
perhaps get the exe name from the PID, then the window name from the exe name? perfectly possible

leave all the parameters blank and it will return an array containing all the data it has from every window :)
see the 2d array lines below for a list of options you can choose from, enjoy!

Code: Select all

msgbox % st_printarr(WinGetAll(), 15)
msgbox % wingetall("proc", "notepad.exe", "PID")
msgbox % wingetall("PID", wingetall("proc", "notepad.exe", "PID"), "Name")

WinGetAll(InType = "", in = "", outtype = "")
{
WinGet,wParam, List
Window:={}
loop %wParam%
	{
		WinGetpos, X%A_Index%, Y%A_Index%, Width%A_index%, Height%A_index%, % "ahk_id " wParam%A_Index%	;m
		WinGetTitle, WinName%A_Index%, % "ahk_id " wParam%A_Index%											;a
		winget, State%A_index%, MinMax, % "ahk_id " wParam%A_Index%										;d
		winget, ID%A_index%,ID , % "ahk_id " wParam%A_Index%												;e
		winget, PID%A_index%,PID, % "ahk_id " wParam%A_Index%												;
		winget, Count%A_index%,Count, % WinName%A_Index%													;b
		winget, Proc%A_index%, ProcessName, % "ahk_id " wParam%A_Index%									;y
		winget, cList%A_index%, ControlList, % "ahk_id " wParam%A_Index%									;
		winget, cListHWND%A_index%, ControlListHWND, % "ahk_id " wParam%A_Index%							;b
		winget, trans%A_index%, transparent, % "ahk_id " wParam%A_Index%									;u
		winget, transc%A_index%, transcolor, % "ahk_id " wParam%A_Index%									;g
		winget, style%A_index%, style, % "ahk_id " wParam%A_Index%											;z
		Window[ A_index , "Name" ]		:= WinName%A_index%													;0
		Window[ A_index , "State" ]		:= State%A_Index%													;0
		Window[ A_index , "AHK_ID" ]	:= wParam%A_Index%													;0
		Window[ A_index , "ID" ]		:= ID%A_Index%
		Window[ A_index , "PID" ]		:= PID%A_Index%
		Window[ A_index , "Proc" ]		:= Proc%A_Index%
		Window[ A_index , "Count" ]		:= Count%A_Index%
		Window[ A_index , "cList" ]		:= cList%A_Index%
		Window[ A_index , "cListHWND" ]	:= cListHWND%A_Index%
		Window[ A_index , "trans" ]		:= trans%A_Index%
		Window[ A_index , "transc" ]	:= transc%A_Index%
		Window[ A_index , "style" ]		:= style%A_Index%
		Window[ A_index , "X" ]			:= X%A_Index%
		Window[ A_index , "Y" ]			:= Y%A_index%
		Window[ A_index , "Width" ]		:= Width%A_Index%
		Window[ A_index , "Height" ]	:= Height%A_Index%
		Window[ A_index , "Area" ]		:= Width%A_Index% * Height%A_Index%
		if (intype) AND (in) AND (outtype)
			if (Window[A_index, intype] = in)
				return % window[a_index, outtype]
	}
	if (intype) AND (in) AND (outtype)
		return "Error, intype or in not found."
	return % window								
}


st_printArr(array, depth=5, indentLevel="")
{ ;made by tidbit
   for k,v in Array
   {
      list.= indentLevel "[" k "]"
      if (IsObject(v) && depth>1)
         list.="`n" st_printArr(v, depth-1, indentLevel . "    ")
      Else
         list.=" => " v
      list.="`n"
   }
   return rtrim(list)
}
Image
||-------[-HP-ML350E-G8-]-------||-[-32-core-xeon-]-||--[-48gb-ECC-]--||
||----[-Dell-Poweredge-r610-]---||-[-16-core-xeon-]-||--[-16gb-ECC-]--||
||-[-Lenovo-ThinkPad-x201-tab-]-||---[-4-core-i7-]--||-[-8gb-nonECC-]-||
||---------------------------[-shack--img-]---------------------------||
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: One window func for them all!

11 Aug 2018, 08:51

@Bugz000 , thank you
can't see the many lines in msgbox, maybe use fileappend ?

Code: Select all

$!F5::
aa:= % st_printarr(WinGetAll(), 15)
fileappend,%aa%,test66.txt
;msgbox % st_printarr(WinGetAll(), 15)
msgbox % wingetall("proc", "notepad.exe", "PID")
msgbox % wingetall("PID", wingetall("proc", "notepad.exe", "PID"), "Name")
return
User avatar
Bugz000
Posts: 93
Joined: 30 Sep 2013, 10:01

Re: One window func for them all!

11 Aug 2018, 08:59

garry wrote:@Bugz000 , thank you
can't see the many lines in msgbox, maybe use fileappend ?

Code: Select all

$!F5::
aa:= % st_printarr(WinGetAll(), 15)
fileappend,%aa%,test66.txt
;msgbox % st_printarr(WinGetAll(), 15)
msgbox % wingetall("proc", "notepad.exe", "PID")
msgbox % wingetall("PID", wingetall("proc", "notepad.exe", "PID"), "Name")
return
yes i am aware the msgbox is huge but i prefer not to release ahk scripts that dump files, by all means use fileappend on your own computer if you wish :)
Image
||-------[-HP-ML350E-G8-]-------||-[-32-core-xeon-]-||--[-48gb-ECC-]--||
||----[-Dell-Poweredge-r610-]---||-[-16-core-xeon-]-||--[-16gb-ECC-]--||
||-[-Lenovo-ThinkPad-x201-tab-]-||---[-4-core-i7-]--||-[-8gb-nonECC-]-||
||---------------------------[-shack--img-]---------------------------||
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: One window func for them all!

11 Aug 2018, 09:43

thank you Bugz000 , maybe I make a small GUI with EDIT to see the result in edit

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: ruespe and 146 guests