How to detect when a sub-child window WinTitle changes? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
TXShooter
Posts: 73
Joined: 13 Dec 2017, 09:27

How to detect when a sub-child window WinTitle changes?

21 Jan 2018, 16:40

How would one go about checking the following during some kind of while loop setup?

1) Detect when a button is enabled in a sub-child window whose title changes at the point of the button being enabled?
2) Detect when a sub-child window changes its title?

During a rendering process in Reaper, a child window appears to make the rendering settings. Upon clicking Render on that child window, a sub-child window appears whose title is "Rendering to file...". When the rendering process is finished, the title of that sub-child window changes to "Finished in xxxx.yyyyyy seconds", and then the "Close" button is enabled, as well as two other buttons are created.

Currently I am Sleep(ing) for about 3 minutes (Sleep, 1800000) to wait for this process to finish, but often times this is far more time than needed, and a few times it isn't enough. And then there's been times when launching the rendering process hasn't occurred because something hung in the system causing a delay prior to its execution.

I would much rather detect when these child windows appear before going on to the next step, but haven't learned how that works in AHK. I've looked up While-Loop, but that didn't seem like an option for detecting child window status. I've thought about using GetControl on the "Close" button (Button1 in this case), but I read somewhere that it depends on the window title, which changes.

Would you gurus have any advice?
TXShooter
User avatar
divanebaba
Posts: 704
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to detect when a sub-child window WinTitle changes?

21 Jan 2018, 17:12

You could use one timer or more instead of sleeping.
Instead of sleep 180000 you could start there a timer, which every 5 seconds looks for the existence of Win-Title called "Finished" or the one called "Rendering".
Don't forget to use SetTitleMatchMode 1 (window's title must start with the specified WinTitle to be a match.)

In this thread you find a timer. Modify it for own purposes.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
TXShooter
Posts: 73
Joined: 13 Dec 2017, 09:27

Re: How to detect when a sub-child window WinTitle changes?

19 Mar 2018, 19:09

With some help I have built this timer that is pauseable and escapeable. What I am not sure about is: is it possible to use the SetTitleMatchMode in conjunction with this in order to escape the timer?

Code: [Select all] [Download] GeSHi © Codebox Plus

^+s::running := false		; Ctrl+Shift+s
^!p::Pause ; Ctrl+Alt+p
Sleepy(TimeInSeconds)
{
global running := true
while (TimeInSeconds > 0) && (running)
{
Sleep, 1000
TimeInSeconds += -1
}
}


The window that I'm wanting to watch is a child window and titled as "Rendering to file...". When the rendering is complete, it changes to "Finished in xxxxx seconds...". It's at this point that I would like to escape the timer. Or, better yet, run until the title changes without using a timer at all.

Any thoughts on that? (I'm not sure if AHK detects child windows, so I'm pretty lost here.)
User avatar
divanebaba
Posts: 704
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to detect when a sub-child window WinTitle changes?

19 Mar 2018, 21:58

Hello TXShooter.

You write: "I've built this timer ...", but your posted code does not contain a timer, as described in help file.
Help file says: "Causes a subroutine to be launched automatically and repeatedly at a specified time interval."

So a classical timer is just a subroutine. The command SetTimer determines how to trigger this subroutine.

My suggestion was to create a subroutine which checks the existence of determined window titles.
For example:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

So this is a way, to detect if rendering process has finished. The only delay is the timer repeat time.
How to detect if your buttons are active or not, I don't really know without further information.
Maybe following code could do your job

Code: [Select all] [Download] GeSHi © Codebox Plus

ControlGet, OutputVar, Enabled,, Button1, Rendering to file
Remark to find the classNN name of the button to check. In example code, Button1 is just a placeholder.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
TXShooter
Posts: 73
Joined: 13 Dec 2017, 09:27

Re: How to detect when a sub-child window WinTitle changes?  Topic is solved

20 Mar 2018, 18:43

I just modified my Sleepy timer like so:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



This still works in its original fashion just so long as there aren't any other unintentional windows popping up with the title "Finished in", but I can't really see that happening. :)

Btw, if "Sleep, 1000" isn't a 1 second timer, what is it then?
User avatar
divanebaba
Posts: 704
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to detect when a sub-child window WinTitle changes?

21 Mar 2018, 06:01

Hello.
I've showed you, how to build a timer as described in help-file.
Your type of "timer" or whatever it is, I've never seen.
If your posted code is your whole code, the sleepy()-function is never executed.

I told you what I know. If you want to built your "timer" in a different way, I wish you good luck.

Sleep 1000 is Sleep, DelayInMilliseconds, means it is sleeping a second.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
TXShooter
Posts: 73
Joined: 13 Dec 2017, 09:27

Re: How to detect when a sub-child window WinTitle changes?

21 Mar 2018, 15:14

Sleepy() is a function to replace the command Sleep. It is called with Seconds as its parameter, and is pausable, escapable, and now has Check While functionality.

I only shared it to show how I solved my own request.
User avatar
divanebaba
Posts: 704
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to detect when a sub-child window WinTitle changes?

21 Mar 2018, 16:00

Hello TXShooter,

for me it makes no difference, if you use timer, function or something else.
I mean the timer solution, described in help-file, is easy to use and even easy to understand.
And, according to my knowledge, normal timer-solution should achieve desired results.

It is your script and you are free to do what you want.

BTW: A great (maybe greatest) german philosopher said: "You can do what you want, but do not want what you want." [Google translator]
English Wikipedia: "Man can indeed do what he wants, but he cannot will what he wants."
Original by Arthur Schopenhauer: "Du kannst tun, was Du willst, aber nicht wollen, was Du willst."

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.

Return to “Ask For Help”

Who is online

Users browsing this forum: Divvy, Ridwan and 39 guests