Jump to content
Hyperion

Wait until a program is fully loaded

Recommended Posts

Hyperion

Hello AutoIt forums, I'm trying to execute a keypress combination after a certain program is fully loaded, by which I mean that it isn't acting as frozen to any user inputs. But so far, I haven't been able to find a reliable solution to do this, not even WinWaitActive seemed to work properly on this one. I've tried to solve it by using the sleep function, but the program takes a longer time to start if it's being started for the first time, and I want the action to take place as soon as it is ready, without the need to imprecisely guess the time it takes to load.

I thought of getting the memory usage of it and comparing it to a value in a while loop, but this didn't work as my attempt to get the memory by $Mem = ProcessGetStats("name") has failed, and it would also get a bit more complicated. If there is any reliable way to check whether a window is responding or not, I'd be glad to know it

Share this post


Link to post
Share on other sites
MikahS

Have a look at _WinAPI_IsHungAppWindow


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Herb191

If there are some controls that get loaded last you can also do something like this:

Run("notepad.exe")

Do
    Sleep(250)
Until ControlGetHandle("[CLASS:Notepad]", "", "Edit1") <> 0

ControlSetText("[CLASS:Notepad]", "", "Edit1", "It worked!")

You can also try using functions like ControlClick and ControlSetText to see if the program is responding yet.

Share this post


Link to post
Share on other sites
Hyperion

I've tried to use this, but it didn't work:

Do
   Sleep(500)
Until _WinAPI_IsHungAppWindow ("X3TC") == 0

If I understood correctly, the $hWnd argument should be the window name, but it looks like I'm wrong.

I cannot use the ControlGetHandle method, since it isn't a windows program but rather a game, which has no text input upon startup, I just have no idea how to properly use your method on that.

Share this post


Link to post
Share on other sites
Melba23

Hyperion,

Welcome to the AutoIt forum.

it isn't a windows program but rather a game

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game interaction - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

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

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×