Jump to content

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


Recommended Posts

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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.

Link to comment
Share on other sites

  • Moderators

ShawnLee,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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.

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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:
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...