ShawnSharon Posted March 26, 2012 Share Posted March 26, 2012 Have searched the forum and found nothing about my question, so start a new post for my question. Thanks for your help. My question is : I'd like to retrieve a handle of a window according to the title and text with WinGetHandle("window title“, "window text"). It does work when the state of window is normal, but I got a failure when the state of window is "No responding". Actually this window is waiting for the time-out period to elapse. Thanks again for your any opinion. Shawn Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2012 Moderators Share Posted March 26, 2012 ShawnLee, Welcome to the Autoit forum. The handle of the window will not change when it becomes unresponsive, so why not get the handle when the window first appears? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ShawnSharon Posted March 26, 2012 Author Share Posted March 26, 2012 ShawnLee,Welcome to the Autoit forum. The handle of the window will not change when it becomes unresponsive, so why not get the handle when the window first appears? M23M23, I really appreciate your quick reply.The reason is I can't assure it is responsive when I retrieve its handle. Also this program may have restarted and have a new handle. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2012 Moderators Share Posted March 26, 2012 ShawnLee,Then try WinList and see if you can determine the handle from the titles returned in the array. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ShawnSharon Posted March 26, 2012 Author Share Posted March 26, 2012 ShawnLee,Then try WinList and see if you can determine the handle from the titles returned in the array. M23Understand. This does work with the condition that only one instance of the program runs. When multiple instance exist, I have to get the right window by the text of the window. So maybe I should use a loop to wait for the end of non-response. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2012 Moderators Share Posted March 26, 2012 ShawnLee,Then run through the list of current windows and see which one is not responding: $aWinList = WinList() For $i = 1 tO $aWinList[0][0] ; Check for title If $aWinList[$i][0] <> "" Then ; Check if hung $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $aWinList[$i][1]) If @error Then ContinueLoop EndIf If $retArr[0] = 1 Then MsgBox(0, "Oops", "Window " & $aWinList[$i][0] & " is not responding" & @CRLF & "Handle: " & $aWinList[$i][1]) Else MsgBox(0, "OK", "Window " & $aWinList[$i][0] & " is responding" & @CRLF & "Handle: " & $aWinList[$i][1]) EndIf EndIf NextYou could also add parameters to the WinList function to reduce the number of returns if you know, foe example, the CLASS of GUI you are looking for. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ShawnSharon Posted March 26, 2012 Author Share Posted March 26, 2012 ShawnLee, Then run through the list of current windows and see which one is not responding: $aWinList = WinList() For $i = 1 tO $aWinList[0][0] ; Check for title If $aWinList[$i][0] <> "" Then ; Check if hung $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $aWinList[$i][1]) If @error Then ContinueLoop EndIf If $retArr[0] = 1 Then MsgBox(0, "Oops", "Window " & $aWinList[$i][0] & " is not responding" & @CRLF & "Handle: " & $aWinList[$i][1]) Else MsgBox(0, "OK", "Window " & $aWinList[$i][0] & " is responding" & @CRLF & "Handle: " & $aWinList[$i][1]) EndIf EndIf Next You could also add parameters to the WinList function to reduce the number of returns if you know, foe example, the CLASS of GUI you are looking for. M23 Thanks a lot! 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