Jump to content

Test for Window Responsiveness


wth
 Share

Recommended Posts

Hi There,

I'm writing a script for a java program and at one part I have to wait for it to scan some items. I'm using Not Winexist() to wait for the window to disappear. This is working correctly. The issue that I'm having is that the main screen it returns to is now active but not responding so WinWaitActive doesn't work. Unfortunately the not responding can be from 7 seconds to 7 minutes.

Is there anything I can do to check for window responsiveness or will I be stuff with a 10 minute sleep to buy it plenty of time to respond?

Link to comment
Share on other sites

  • Moderators

wth,

Welcome to the AutoIt forum. ;)

Is there anything about this window (title, colouring of a control or area, etc) that indicates when it is ready to go again?

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

wth,

Welcome to the AutoIt forum. ;)

Is there anything about this window (title, colouring of a control or area, etc) that indicates when it is ready to go again?

M23

The titling no but I could probably use pixel color of something. I had to do that at another point in the macro, didn't think to try it here. The window goes completely blank when unresponsive so I'll find a point when it's good and test. I'll let you know if it works.

Thanks!

Link to comment
Share on other sites

Perhaps try using the API call 'IsHungAppWindow' in a loop to wait until it reports the window as not 'hung'?

Link to comment
Share on other sites

The titling no but I could probably use pixel color of something. I had to do that at another point in the macro, didn't think to try it here. The window goes completely blank when unresponsive so I'll find a point when it's good and test. I'll let you know if it works.

Thanks!

Hi, this worked perfectly. Thanks!

I'll take a look at IsHungAppWindow because that would probably be a cleaner solution if it works.

Link to comment
Share on other sites

Perhaps try using the API call 'IsHungAppWindow' in a loop to wait until it reports the window as not 'hung'?

Hi, just to make sure that I wrote this correctly. I added...

Dim $hWin

$hWin = WinGetHandle("name")
While dllCall("User32.dll", "BOOLEAN", "IsHungAppWindow", "HINSTANCE", $hWin)
    Sleep(1)
Wend

This didn't work but it doesn't mean that it's written correctly. I don't know how to force a window to be unresponsive so it's a bit difficult to test.

Link to comment
Share on other sites

That's not how you check the value of an API return. Any DLLCall() that succeed will return an array, otherwise it will return something like ''.

What you want is something like this:

While 1
    $aRet=DLLCall('user32.dll',"bool","IsHungAppWindow","hwnd",$hWnd)
    If @error Or $aRet[0]=0 Then ExitLoop
WEnd
; If @error Then... (if the DLLCall failed, you should probably try another method)

As far as forcing a window to be unresponsive.. well, it can't really be done with a 'Suspend' command, or any other simple command, really (unless you force it to crash maybe). Since you were getting a window that was being unresponsive in the first place, thats why I chimed in with that API call (which returns non-zero in $aRet[0] if a window doesn't look for or respond to any Window messages within a given amount of time). If you no longer have the problem, then no need to use the call.

Link to comment
Share on other sites

Right, because it makes so much more sense to use a gigantic UDF for one API call.

Link to comment
Share on other sites

  • Moderators

Ascend4nt,

it makes so much more sense to use a gigantic UDF for one API call.

I share your sentiments absolutely and try to avoid using #include files in my UDFs for this very reason.

But it is worth remembering that if you use Obfuscator with the /STRIPONLY parameter it removes all the unused functions (and constants) when you compile. So you just get the sections you need from any massive (but very handy) #include files. :)

I would recommend this approach to those who are not very confident about coding DLL calls directly. ;)

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

This is bordering on moronic. The API call was provided, as well as the method to call it. Why waste your breath telling someone to use another UDF when the answer is here in the thread.

Melba, I'm well aware of the /striponly Obfuscator parameter, as well as others that are useful in shrinking UDF's down. I'm also aware of the usefulness of some UDF's to newbies.

However, the answer was provided, and wakillon decided to ignore it and suggest someone go look at the WinAPIEx UDF for the same exact thing, only in a gigantic package. In what world does that make sense.

Link to comment
Share on other sites

  • Moderators

Ascend4nt,

This is bordering on moronic

My comments above were not intended to cause you personal offence and my apologies if any was caused. There are differing views expressed in this topic - that makes none of the contributing members borderline moronic. ;)

You and I are happy using DllCall, but many other coders take one look at the syntax and immediately the "Too Difficult" light comes on - I freely admit that my "Caution" light starts flashing brightly. Suggesting the use of a UDF function from an #include file gives these coders access to the functionality but puts them at a nice safe distance from the "dirty" syntax - which is why the UDFs like WinAPIEx were written in the first place (thanks Yashied!).

And I was absolutely sure that you would be aware of the "slimming" properites of Obfuscator - the comment was aimed at any newer coders reading who might have thought that using a largish UDF for a single function was not a good idea when it is extremely simple to remove the unwanted functions when compiling. ;)

Let us hope that the OP manages to get what he wants - whichever of the methods he uses. Have a nice weekend. :)

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

Melba, my apologies for my remarks.. really I was directing the 'borderline moronic' comment towards wakillon's post. And honestly, I usually try not to say things like that but this whole discussion over a few lines of code is overkill. I gave the necessary code and calling syntax, nothing more was needed other than a copy-and-paste.

However, as you said - its up to 'wth' what they choose to do or use.

And don't worry, your words aren't lost on me. You seem like a pleasant enough person with good intentions. And the main point is to help others, so whatever productive advice you put out there is all good.

take it easy

Link to comment
Share on other sites

Melba, my apologies for my remarks.. really I was directing the 'borderline moronic' comment towards wakillon's post. And honestly, I usually try not to say things like that but this whole discussion over a few lines of code is overkill. I gave the necessary code and calling syntax, nothing more was needed other than a copy-and-paste.

However, as you said - its up to 'wth' what they choose to do or use.

And don't worry, your words aren't lost on me. You seem like a pleasant enough person with good intentions. And the main point is to help others, so whatever productive advice you put out there is all good.

take it easy

my dear ascend4nt

How can I say this politely?

It makes no sense is to answer to someone who says to someone else to take a look to an existing function, that is moronic !

It makes no sense because my first intention was to Confirm your solution by indicate a Yashield Udf like a great reference !

It makes no sense because to talk about udf size, like if some kb were important in the functioning of a script !

It makes no sense on this nice forum to be rude and contemptuous for impose his opinion !

wakillon.

Thank you, Melba for your diplomacy !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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