Determine when an application/window has finished launching?

Get help with using AutoHotkey and its commands and hotkeys
johnny256ahk
Posts: 24
Joined: 04 Dec 2014, 07:47

Determine when an application/window has finished launching?

22 Jan 2015, 11:03

Are there any common tips and tricks I can use to help detect when an application has finished starting up? For instance a map viewing tool my launch instantly and display the rough outline of a country very quickly, but take several seconds as other layers and fine detail are loaded, etc.

I have a feeling this falls into "you need to know exactly how the application works" territory but maybe there are some neat tricks I haven't thought of?
User avatar
MilesAhead
Posts: 232
Joined: 03 Oct 2013, 09:44

Re: Determine when an application/window has finished launch

22 Jan 2015, 16:41

I don't know of any event or state information that would tell you a top level window has completed drawing after it is initially shown by Windows. All I can think of for the example you gave may be to look for a particular pixel color at a particular spot in the client window area that gives away the fact all the layers are drawn. As you say it's likely to be a case by case detection process.
"My plan is to ghostwrite my biography. Then hire another writer to put his
name on it and take the blame."

- MilesAhead
johnny256ahk
Posts: 24
Joined: 04 Dec 2014, 07:47

Re: Determine when an application/window has finished launch

22 Jan 2015, 16:42

Can I try and detect if the mouse-cursor stops being the busy one and goes back to normal, in AHK?
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Determine when an application/window has finished launch

22 Jan 2015, 17:08

A_Cursor Built-in Variable with a value of AppStarting or Wait
User avatar
boiler
Posts: 2897
Joined: 21 Dec 2014, 02:44

Re: Determine when an application/window has finished launch

22 Jan 2015, 21:42

You would have to somehow constrain the cursor to that app window for the A_Cursor approach to be reliable. It will return the current cursor shape no matter where it is, so it will often be an arrow (or a lot of other shapes), as this shows.

Code: Select all

Loop
{
	ToolTip, %A_Cursor%
	Sleep, 50
}
return

Esc::ExitApp
User avatar
boiler
Posts: 2897
Joined: 21 Dec 2014, 02:44

Re: Determine when an application/window has finished launch

22 Jan 2015, 21:44

I suppose you could have the script actively keep moving the mouse back over the window, then checking the shape of it. And you could have it move it right back to where it was so it doesn't interrupt the user from doing other things with it too much.
User avatar
berban
Posts: 88
Joined: 14 Apr 2014, 03:20

Re: Determine when an application/window has finished launch

22 Jan 2015, 21:47

You could also check the appearance of the window (with either GDI+ or alt+printscreen) and check to see when it stops changing. That would require however that your application doesn't have a blinking cursor or something else that is SUPPOSED to be changing.
User avatar
boiler
Posts: 2897
Joined: 21 Dec 2014, 02:44

Re: Determine when an application/window has finished launch

22 Jan 2015, 21:53

It might be possible monitor the window for messages and see if it receives a message that indicates it's finished drawing or whatever. Use Winspector Spy or something to see what messages are being sent to it.
User avatar
MilesAhead
Posts: 232
Joined: 03 Oct 2013, 09:44

Re: Determine when an application/window has finished launch

23 Jan 2015, 06:49

https://msdn.microsoft.com/en-us/librar ... wndprocret

Maybe with DllCall you can hook in.
"My plan is to ghostwrite my biography. Then hire another writer to put his
name on it and take the blame."

- MilesAhead

Return to “Ask For Help”

Who is online

Users browsing this forum: doctorafterman, Google [Bot], teadrinker and 220 guests