Wait for a window to finish loading

Get help with using AutoHotkey and its commands and hotkeys
SimPlayer
Posts: 72
Joined: 01 Apr 2016, 05:57

Wait for a window to finish loading

01 Apr 2016, 06:15

Hi everybody.

I`m running the Live for speed cargame using four AutoHotkey scripts.
I´m using three of the games windows and Ahk is "jumping" between these.

The problem is to know "the state" of the windows.

Sometimes a timer of 2000millisec is enough, but sometimes it would require 5 seconds to load a graphic element.

If you press a key before the window has been loaded, the script jumps to another script, but the window doesnt, and the Ahk script is "in wrong window".

So, my question is:

Is there any way of getting information when a window has finisched loading, and is in a "waiting state" ??

Thanks,

SimPlayer
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: Wait for a window to finish loading

01 Apr 2016, 09:38

One way is to use pixel and image search to find some visual indication that the process isn't busy.
The downside to this approach is that it need to be customised to every application, and if the application is inconsistent in its visual indicators, the script becomes messy.
There may well be a better way to determine if a window is busy, but if I understand your problem it is really processes behind the window that are interesting. I believe these processes would need to implement a way to determine if they are busy themself.
Please excuse my spelling I am dyslexic.
SimPlayer
Posts: 72
Joined: 01 Apr 2016, 05:57

Re: Wait for a window to finish loading

01 Apr 2016, 11:02

Hi, and thank you for your answer.

I have tried to use the pixel and image search, but I didnt get it to work at all.
It could be possible since its only in one part of the screen that the image changes when an image of a track is coming up. And its that process that varies with different tracks. If it would be possible to wait on that part of the screen being "idle", meaning no pixels are changing colours, than it would work.

SimPlayer
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Wait for a window to finish loading

01 Apr 2016, 11:18

One real ugly way to accomplish is (given that the window does not respond on attempts to move the window under loading) to grap at top of the window (loop) and have a loop to determine when the wondow has actually changed position.
SimPlayer
Posts: 72
Joined: 01 Apr 2016, 05:57

Re: Wait for a window to finish loading

02 Apr 2016, 06:11

Hi all.

In right corner there is a "run" button that you click when you enter race, could it be possible to find this RUN text ?

SimPlayer
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Wait for a window to finish loading

11 Apr 2016, 11:42

Yes it would be possible:
You need to fill out the blanks:

Code: Select all

While, windowsStillLoading()
	Sleep 200
	
windowsStillLoading() {
	imageSearch, foundX, foundY, x1, y1, x2, y2, imagefile.bmp
	If !errorlevel
		Return 1
}

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, ameyrick, Arsonistic, Bing [Bot], Haan, hotkeyuser1234, Jose Hidalgo, mikeyww and 70 guests