Anteaus Posted November 20, 2007 Share Posted November 20, 2007 Requirement: Launch a process wth Run() Identify the window belonging to this process. Wait until this window is in a minimised or trayed state. Proceed with rest of code. Bit I can't figure out is how to identify the window-title or other handle associated with the process-number, so as to determine the window state. Any ideas how to do this? Link to comment Share on other sites More sharing options...
sstouk Posted November 20, 2007 Share Posted November 20, 2007 Since you are starting the process yourself, I would enumerate all the windows existing before running the process and then enumerate the windows after the process was initiated, then parse the list through the filter and get your new windows ID. The filter is to make sure you are capturing the right window and not the one that was excedentally started by a user manually while you were waiting for the process to startup. Link to comment Share on other sites More sharing options...
Gestalt Posted November 20, 2007 Share Posted November 20, 2007 WinGetProcess() can filter it. For example, if your PID is 200, then you get the PIDs for the open windows and whichever one is 200 is your window. Link to comment Share on other sites More sharing options...
rasim Posted November 21, 2007 Share Posted November 21, 2007 Requirement: Launch a process wth Run() Identify the window belonging to this process. Wait until this window is in a minimised or trayed state. Proceed with rest of code. Bit I can't figure out is how to identify the window-title or other handle associated with the process-number, so as to determine the window state. Any ideas how to do this? Example: $pPID = Run("notepad") WinWait("Untitled") $wPID = WinGetProcess("Untitled") If $pPID = $wPID Then While Not WinState() Sleep(100) WEnd EndIf Func WinState() Return BitAND(WinGetState("Untitled"), 16) EndFunc Link to comment Share on other sites More sharing options...
Anteaus Posted November 21, 2007 Author Share Posted November 21, 2007 WinGetProcess() can filter it. For example, if your PID is 200, then you get the PIDs for the open windows and whichever one is 200 is your window.Should've thought of that, yes, it's basically just a question of polling to find the right one. Thanks. Link to comment Share on other sites More sharing options...
BrettF Posted November 21, 2007 Share Posted November 21, 2007 (edited) Have a look at this: Func _SetParentWindowPID($PID, $hGUI) $hWnd = 0 $stPID = DllStructCreate("int") Do $winlist2 = WinList() For $i = 1 To $winlist2[0][0] If $winlist2[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $winlist2[$i][1] ExitLoop EndIf EndIf Next Sleep(100) Until $hWnd <> 0 $stPID = 0 If $hWnd <> 0 Then $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20) $nExStyle = $nExStyle[0] DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOR($nExStyle, $WS_EX_MDICHILD)) DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI) WinSetState($hWnd, "", @SW_SHOW) _WinAPI_RedrawWindow ($hWnd) EndIf GUISetState() EndFunc ;==>_SetParentWindowPID See if you adapt it. Can't remember where I got it from... Edited November 21, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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