Sign in to follow this  
Followers 0
ShawnSharon

WinGetHandle can't work with window of "No responding" ?

7 posts in this topic

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

Share this post


Link to post
Share on other sites



ShawnLee,

Welcome to the Autoit forum. :oops:

The handle of the window will not change when it becomes unresponsive, so why not get the handle when the window first appears? :bye:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

ShawnLee,

Welcome to the Autoit forum. :oops:

The handle of the window will not change when it becomes unresponsive, so why not get the handle when the window first appears? :bye:

M23

M23, 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.

Share this post


Link to post
Share on other sites

ShawnLee,

Then try WinList and see if you can determine the handle from the titles returned in the array. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

ShawnLee,

Then try WinList and see if you can determine the handle from the titles returned in the array. :bye:

M23

Understand. This does work with the condition that only one instance of the program runs. :oops:

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.

Share this post


Link to post
Share on other sites

ShawnLee,

Then run through the list of current windows and see which one is not responding: :oops:

$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. :bye:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

ShawnLee,

Then run through the list of current windows and see which one is not responding: :bye:

$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. :doh:

M23

Thanks a lot! :oops:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0