Use Keyboard Maestro to automate closing of repetitive popup windows?

Hi

Is there any way to use Keyboard Maestro to automate closing of repetitive popup windows?

I use my ipad with mac every day with the Duet app, and every time its connected i get a popup from itunes every day that says something like “itunes can’t connect to the ipad”. I always hit the same option to ignore (or the escape key to ignore). Can Keyboard Maestro automate this action?

Yep. Take a look at this, and adjust as necessary:

• Actual window title
• Actual name of button to ignore

MACRO:   @UI Pause Until Window and Press Button @Example


#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/d/6/d6ac95abb22fa794470bc924ace46a7e105ac6a2.kmmacros">@UI Pause Until Window and Press Button @Example.kmmacros</a> (4.7 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---



![image|476x857](upload://1GuP8INSLXgDxj8k20aetB34Fla.jpg)
1 Like

Awesome, thanks!

I just tried repurposing this macro to use with another repetitive popup window that opens often when i launch ableton live and it doesn't seem to be working yet. I've duplicated the macro you provided, adjusted the actions, enabled it, and moved the macro to a group where only ableton live is available. Pic below of the popup and the macro.

When i launch ableton live, the popup appears but the macro is not doing anything about it. Am i doing something wrong here?

Since this occurs when the app is launched, the macro group is not active yet. So you may need to move the macro to a global group.

1 Like

Thanks again. I still haven't been able to get this macro to work with the itunes popup yet. Can you think of any other reasons that i might be having difficulty with it?

I've tried this macro in both the itunes group and the global macro group, but haven't seen it work either way. I've also tried ending the macro with an action to hit the escape key, in case something was going wrong with the 'press button' action. Not sure what the issue could be, although i wonder if the fact that the If/Then macro specifies about the window title might cause the issue because i don't know if its actually the title of the popup screen or just the text. Or if there's something else that i'm missing?

Also, is there any way to use Keyboard Maestro to quickly select and stop hopping icons on the mac dock? This popup menu always causes dock hopping to happen whenever it occurs ( and it doesn't bring the itunes popup to the front until i click on itunes) and im considering whether a different route could be better solution.

there could be lots of reasons, but you have not provided enough information for us to properly diagnose. Exactly how is it not working? Where does it fail? Have you tried stepping through the Actions using the KM Debugger?

You also need to post your macro (image and file).

Thank you. Still haven't figured out how to make this work in any situations yet.

In all cases, i believe that its not failing in that the macro never starts being triggered. In other words, the if/then action that is conditional on whether the window title contains the words that are in the popups is always false. I tried using the Debugger, but didn't resolve any questions. It was my first time using the debugger so its possible that I used it incorrectly.

New example:

Trying to make Keyboard Maestro automatically close this popup by hitting the Reopen button. The window is open and in front, but the if/then condition is false. Pic and file below.

Questions:

  1. This window seems to be from the mac OS, not any specific app, right? If so, how can i trigger the if/then condition if the condition seems to only give me the option to trigger by the 'application'?

  2. I'm not sure if the text is in the title. Usually the window title is on the top bar of a window , right? But this text is in the middle of the popup window. Do i need to do something different with the macro to get it to target the text instead of the title?

@UI Pause Until Window and Press Button - musicIO quit unexpectedly.kmmacros (3.8 KB)

Everything that "pops up" in the macOS is NOT a window, strictly speaking. IOW, the macOS frameworks have not defined it as a window. If so, then KM cannot detect it as a window.

So, it is unlikely that you will be able to build a KM Macro that works 100% of the time to auto-close all of these popups. And, while they may sometimes be irritating, sometimes these are key, critical popups about your system or security that you definitely need to take notice of.

In your "musicIO quit unexpectedly" macro, that popup does not look like a window me, but it's hard to tell. Your macro looks OK to me, IF it is a window with the title you used. But then, this popup does not appear to have a title, so. . .

I doubt this macro will ever trigger. The best you can probably do is trigger a macro manually (with a hotkey) that clicks on the button.

1 Like

Hey @danklim,

musicIO quit unexpectedly is NOT the window title. It's in a text field somewhere in that alert window, and Keyboard Maestro can't see it.

The first question is whether Keyboard Maestro's Focused Window Changes trigger is actually triggered when that alert shows up.

If the trigger works then it should be possible to work with the alert window with AppleScript UI-Scripting.

-Chris

1 Like

Thank you both!

I tested the Music IO window and it didn't trigger the focused window to change in Keyboard Maestro. Assuming that I won't be able to fix that unless i hear otherwise.

Just tried it on another window that comes up often (when i try to quit an app called Lumen) and it does trigger that the focused window has changed in Keyboard Maestro.

I'm not sure what i'd do here to make the window automatically select "quit" and don't know much about AppleScript UI-Scripting. Is there anything that i can implement relatively easily to make this window auto-quit when it opens? If so, what/how?

Hey @danklim,

I'm looking into that and waiting for info from Peter.

When the dialog comes up in Lumen then run this from the Applescript Editor.app.

set procname to "Lumen" --<-- Change as needed.

tell application "System Events"
   set frontProcess to first process whose frontmost is true
   
   tell application process procname
      set frontmost to true
      tell front window
         set stList to value of every static text
         set bList to name of buttons
      end tell
   end tell
   
   tell frontProcess to set its frontmost to true
   
   return {stList, bList}
   
end tell

Post the result.

-Chris

1 Like

Thanks, looking forward to hearing more about it.

Ok its showing the text:

{{"Are you sure you'd like to quit?", "You have an active fullscreen output or connected Syphon clients.", ""}, {"Cancel", "Quit"}}

Please let me know if there's anything else that i should do or do differently.

Thanks, Dan

Hey @danklim,

Try this when the window focus changes.

Execute an AppleScript.kmactions (1.2 KB)

You can use the local_QuitWindowFlag variable for flow-control if needed.

-Chris