Jump to content
Sign in to follow this  
aland

Wait until windows finished loading

Recommended Posts

aland

Hi all,

I'm new to AutoIt and I'm trying to automate a program to load a (potentially large) file - I have written the automation without much problem, however the files I am loading can range between a few hundred KB to a couple of MB and thus the time it takes to finish loading ranges from a few seconds to, a minute or so.

WinWaitActive will return once the program has opened, is there a similar 'wait' command for when a program is ready/idle?

Of course, I could sleep for a few seconds in an effort to catch the 'worst case' but I'm looking for a more elegant solution :)

The window title does change when the file is opened, however there is still a delay between this change and the program truely being ready relative to the file size.

The program I'm scripting for is BEncode Editor which I believe is itself written in AutoIt (whether that makes a difference or not).

Cheers

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

How do YOU know when the file has loaded? Is there a text in the status bar ("file loaded") or some other change so you can se that the file has loaded?

If you can manually determine that the file has loaded AutoIt will do as well.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
aland

I can tell because the program window is populated with a large TreeView (with vertical scroll) and the mouse icon changes from 'loading' to normal.

Is it possible to detect these changes from AutoIt?

Share this post


Link to post
Share on other sites
water

Check the TreeView control. If the control is populated with data, then your script can go on processing.

Use The AutoIt Window Info Tool to get the ControlID of the TreeView and try function ControlTreeView.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
aland

Really appreciate your help with this. I've put a long sleep so I can be sure the data is loaded before running the below code, but I'm not able to get it to work. In place of "[iD:51]" I've tried [CLASS:Static; INSTANCE:11], [CLASS:Static] and 51, all return value of 0 (no error).

Local $treeview = ControlTreeView("BEncode Editor", "", "[ID:51]", "GetItemCount", "#0")
If @error Then
     MsgBox(4096, "Error", "ControlTreeView error")
EndIf
MsgBox(4096, "Control treeview output", $treeview)

Below is the summary from AutoIt Window Info -

>>>> Window <<<<
Title: resume.dat - BEncode Editor
Class: AutoIt v3 GUI
Position: 733, 345
Size: 466, 363
Style: 0x14CF0000
ExStyle: 0x00000110
Handle: 0x001C09D0
>>>> Control <<<<
Class: Static
Instance: 11
ClassnameNN: Static11
Name:
Advanced (Class): [CLASS:Static; INSTANCE:11]
ID: 51
Text:
Position: -5, -45
Size: 460, 355
ControlClick Coords: 163, 85
Style: 0x5000010E
ExStyle: 0x00000000
Handle: 0x00220B82
>>>> Mouse <<<<
Position: 899, 435
Cursor ID: 0
Color: 0xFFFFFF
>>>> StatusBar <<<<
>>>> ToolsBar <<<<
>>>> Visible Text <<<<
>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites
water

The following example will list the 3rd drive in the WIndows Explorer for Desktop -> Computer:

#AutoIt3Wrapper_UseX64=y
#include <array.au3>
$sTitle = "[Class:CabinetWClass]"
$sID = "Desktop|#0|#2"

$sResult = ControlTreeView($sTitle, "", 100, "Select", $sID)
ConsoleWrite($sResult &amp; "|" &amp; @error&amp; @LF)
$sResult = ControlTreeView($sTitle, "", 100, "GetText", $sID)
ConsoleWrite($sResult &amp; "|" &amp; @error&amp; @LF)
$sResult = ControlTreeView($sTitle, "", 100, "GetItemCount", $sID)
ConsoleWrite($sResult &amp; "|" &amp; @error&amp; @LF)
if you run a 64 bit OS and want to automate a 64 bit application you have to set "#AutoIt3Wrapper_UseX64=y". Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×