Jump to content
Macro Express Forums

Make macro to play custom sound when a specific window is closed?


TsunamiZ

Recommended Posts

Anyone know how to make a macro to play a custom sound when a specific window is closed? In my case, it's Maxthon 2 web browser's download window. The download window's title has no static words and is always changing dependent on what's downloading and the window's .exe name is shared with maxthon.exe Is this doable?

Link to comment
Share on other sites

The answer is yes.

 

....but you probably want to know how! I've done this a few ways but some manual or timed intervention may be needed. Basically you are trying to tell if a window of any potential name disappears.

 

Get the window name at some point in time and have a repeat loop to tell if it does not exist

 

Get the pixel colour at a "good" point on the window and have a repeat loop to tell if it changes

 

Not having the browser I can only guess. Let's say you start the downloader during the night using the macro. After X secs when you are sure the window will exist and is stable, get the topmost window name into a variable. Use that variable in an "If window does not exist" loop. Probably the only bet if you are still working on the pc and changing windows. If you are around when the download window opens you could manually start the macro with no timer.

 

Does the download window have any unique but repeating part to the name? eg

Thefilethatisdownloading - Maxthon

In this case "If window does not exist" loop can be based on partial window title, Maxthon. Even jpg or avi in the window title may do (use multiple Ifs of all your standard file download extensions). Firefox would be easy because the window is "Downloads".

 

Although I avoid mouse moves and XY coordinates, the download window will usually be in the same place and maybe the same size. Pick a point that is unique in colour (but the same every time). Get the pixel colour at those coordinates into a variable (relative to window if it's not fullscreen). Every so many secs check the pixel colour and if it has changed, the window no longer exists.

 

This is more of a "loss of focus" rather than window has closed. You need to be aware of what may be behind the window. If you choose Windows grey and the Window behind is the same it will not work! If the download window is variable size, get the window height and width and calculate the pixel measurement point from there (eg from the bottom left corner).

 

I have a manually initiated macro that I use to temporarily monitor ANY window or applet by this method.

 

Slightly more flaky, use the Repeat with Windows command every so often and count up the number of visible windows with an integer variable that increments by one every time through the repeat. Save integer. When it diminishes by 1.....

Edit: A variation of this one combined with method above (if window title contains the filename) is to put every visible window name into a text variable and if any contain .jpg, .avi, .doc etc then the download window is still open. Effectiveness depends on other open windows.

 

You could investigate Controls. I've had very limited success with browsers (and most other things for that matter!)

 

I used to give a preemptive audible when my email was finishing downloading (slow connection). I monitored the colour of the end of the progress bar box.

 

Edit: When I have browser activity unattended, I open a fullscreen Notepad page called blank.txt before I open the browser. The idea is that if things go amiss I have an extra layer of protection against errant keystrokes re-formatting the drive etc! Using this method, you could have a repeat loop that says "If blank.txt is on top" once the download page has appeared, then the download window must have closed.

 

The above are basic outlines. If you can't figure how to implement, ask. If anyone else has workable methods I'd be interested to know too.

 

I use a Ding for minor events, Tada for medium events and Nero's Trumpet wav if I want the neighbourhood to know.

Edited by JohnS
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...