JohnBailey Posted March 12, 2007 Share Posted March 12, 2007 (edited) Basically, how do I get a notice/report of whether or not a window is a child and the name of it's parent?Here's the script I've been working on/with. It would be awesome if the text files showed which windows were children. I'm researching how to do this, but can't seem to arrive at a conclusion. Furthermore, I'm always open to comments on efficiency in the script!Much props to Smoke_N for awesome direction thus far!!expandcollapse popup#cs ------------------------------------------------- Author: John Bailey Modifier: John Bailey Date Modified: 03/13/2007 ScriptFunction: capture open window information AutoIt Ver: 3.2 NOTE: none Thanks: Smoke_N (http://www.autoitscript.com/forum/index.php?showtopic=40757) #ce ------------------------------------------------- Opt("WinSearchChildren", 1) Opt("TrayMenuMode",1) Opt("TrayOnEventMode",1) TrayTip("AutoIt Script", @ScriptName, 60, 1) #include <Array.au3> #include <File.au3> #include <Constants.au3> ;#compiler_icon HotKeySet('{F9}','captureDetails') HotKeySet('{F8}','captureList') TraySetIcon(@SystemDir&"\SHELL32.dll",171) Global $ListFile = "currentWindowList.txt" Global $DetailsFile = "currentWindowDetails.txt" Global $var $TrayOpListitem = TrayCreateItem("Open WinList") $TrayOpDetailsitem = TrayCreateItem("Open WinDetails") TrayCreateItem("") $TrayExititem = TrayCreateItem("Close") TrayItemSetOnEvent(-1,"close") TrayItemSetOnEvent($TrayOpDetailsitem,"OpenDetails") TrayItemSetOnEvent($TrayOpListitem,"OpenList") TraySetOnEvent($TRAY_EVENT_MOUSEOVER,"MouseOver") TraySetState() TraySetClick(16) Func captureDetails() If FileExists($DetailsFile) Then FileDelete ($DetailsFile) _FileCreate($DetailsFile) Sleep(100) FileOpen($DetailsFile, 1) $var = WinList() ;Props --- Smoke_N ---- ! For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then $write0 = FileWriteLine($DetailsFile,"<>========= Window "&$i&" ===========<>"&@CRLF&@CRLF) $write1 = FileWriteLine($DetailsFile, "WindowNAME: "&$var[$i][0]) $write2 = FileWriteLine($DetailsFile,@CRLF & @TAB & WinGetText($var[$i][0])&@CRLF&@CRLF& "<>==== Window Text End ====<>"&@CRLF&@CRLF&@CRLF&@CRLF&@CRLF&@CRLF) ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next FileClose($DetailsFile) TrayTip("WinGetInfo","Captured all window names and details",1) EndFunc Func captureList() If FileExists($ListFile) Then FileDelete ($ListFile) _FileCreate($ListFile) Sleep(100) FileOpen($ListFile, 1) $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then If _GetParent($var[$i][1]) = 0x00000000 Then $write = FileWriteLine($ListFile, $var[$i][0]) Else ;c = child $write = FileWriteLine($ListFile, @TAB&"c "&$var[$i][0]) EndIf ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next FileClose($ListFile) TrayTip("WinGetInfo","Captured all window names",1) EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Func OpenList() If FileExists(@ScriptDir&"\"&$ListFile) = 1 Then ShellExecute(@ScriptDir&"\"&$ListFile,"",@ScriptDir) Else TrayTip("WinGetInfo","List has not yet been captured",1) EndIf EndFunc Func OpenDetails() If FileExists(@ScriptDir&"\"&$DetailsFile) = 1 Then ShellExecute(@ScriptDir&"\"&$DetailsFile,"",@ScriptDir) Else TrayTip("WinGetInfo","Detail List has not yet been captured",1) EndIf EndFunc While 1 Sleep(5) WEnd Func close() Exit EndFunc Func MouseOver() TraySetToolTip ("Capture Window list F8 or Details F9") EndFunc Func _GetParent($hWnd) ;returns hex Local $v_Call = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hWnd) Return $v_Call[0] EndFuncEdit: Updated original posted script with the current script. Edited March 13, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 12, 2007 Moderators Share Posted March 12, 2007 (edited) IsChild and GetParent API call... I think I have done this once or twice already on the forum. Edited March 12, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JohnBailey Posted March 12, 2007 Author Share Posted March 12, 2007 (edited) Smoke_N, I'm really new to the dll calls in general. (It's soo cool though!)Is this sort of what you mentioned. I'm doing more research and will begin some testing in a bit.Just thought I'd ask and link this to this thread.http://www.autoitscript.com/forum/index.ph...&hl=IsChildLayer's FuncFunc _IsChild($hWndParent, $hWnd) Local $v_Call = DllCall("user32.dll", "int", "IsChild", "hwnd", $hWndParent, "hwnd", $hWnd) Return $v_Call[0] EndFuncAwesome direction btw Smoke_N!! This is going to be some "good learnin'" Edited March 12, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted March 12, 2007 Author Share Posted March 12, 2007 Smoke_N, I don't understand IsChild. I read about it on msdn (http://msdn2.microsoft.com/en-us/library/ms633524.aspx) and I looked through examples in the forums (which I only found one file and seven mentions of the ms function). I'd like to know more about IsChild so if you know of a good place, I'd appreciate it. I'm going to do some Wikipedia-searching. What I did for now is have the script use GetParent (see below) and test if the result is 0x000000 (that is a unowned window). Func _GetParent($hWnd) Local $v_Call = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hWnd) Return $v_Call[0] EndFunc What do you think. This only let's me do markers showing that a window is a child. I'd like to report what its parent is though. A decision is a powerful thing Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 12, 2007 Moderators Share Posted March 12, 2007 (edited) I thought you wanted the parent hwnd, which is why I suggested IsChild... to find out if a window is a child, I've always used this:Func _WinIsParent($hWnd) If IsHwnd($hWnd) = 0 And WinExists($hWnd) Then $hWnd = WinGetHandle($hWnd) Local $aGetParent = DllCall('User32.dll', 'hwnd', 'GetParent', 'hwnd', $hWnd) If IsArray($aGetParent) And $aGetParent[0] Then Return SetError(1, 0, 0) Return 1 EndFunc Edit: I pasted the function wrong... sorry. Edited March 12, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JohnBailey Posted March 13, 2007 Author Share Posted March 13, 2007 Smoke_N, this is great. One thing I'd really like to do is be able to organize the child windows under their parent windows. I can get it to readout what it's parent is but I'm at a loss for reorganizing the children. I really don't understand how WinList retrieves the window list. A decision is a powerful thing Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now