Display message when a window is frontmost

I am unable to do something that should be easy. I want to display a text box when the front window of Outlook is Calendar. I want this to be automatic: no Hot Key Trigger, Status Menu Trigger, or Macro Palette Trigger. I can do this by:

Trigger
This Application: Microsoft Outlook Is Running (or Is Active) Repeating Every ___
Actions
If/Then/Else Front Window of Microsoft Outlook Contains Calendar
Growl message
[Cancel This Macro] – added later with no affect

The problem is the repeat time. Keyboard Maestro will not display the message as soon as Calendar is frontmost. It waits for the Repeating Every interval. If I set the interval to 1 minute, then the message doesn’t appear for a minute, which is worthless to me. If I set the interval to 1 second, the Growl message appears immediately and a repeat message is displayed every second. That’s quite annoying. The macro completely ignores a Cancel This Macro action

I thought Repeating Every was about checking the status of [whatever] at specified intervals. Why is it essentially a repeat loop for the entire macro? Why can’t it be stopped with Cancel This Macro. The only way to stop it is to change one of the starting conditions. (In my case, switching to a different Outlook window or a different application.)

I’m having a very difficult time with KM. Macros that should take a few minutes to build take so long to develop that I will have to use them for ten years before the time saved with the macro exceeds the time required to make it. FWIW: I just accomplished what I wanted in QuicKeys. It took three minutes.

It is easy for me since I have previously used the Focused Window trigger (KM Wiki) . It took me about 1 minute to create this macro, and then perhaps another 2 or 3 minutes to test it to make sure it is performing as I want/expect.

This macro uses a Trigger (KM Wiki) of Focused Window trigger (KM Wiki). Specifically, it uses this variation of the trigger:

1. the focused window’s title changes.
Occurs only when the title of the Front Window changes.

There is another variation that you may be interested in:

2. the focused window title changes.
Occurs when either:
The front window changes (to a window with a different title)
or
The title of the front window changes.

Since I don't know exactly what behavior you want/prefer, I chose #1, which works best for me.
You may have to invest more than 3 minutes to determine which works best for you. But then you will know how the behavior works, and next time you need this type of action it will be easier and for you.

##Macro Library   @OL Display Prompt When Calendar is Shown


####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/a/a810d3290cf639f8758f52423365a84b6bc74ac5.kmmacros">@OL Display Prompt When Calendar is Shown.kmmacros</a> (6.3 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---

###Use Case

* Display a Prompt for User Input when the Outlook main window changes TO "Calendar"

* With the current TRIGGER of "the focused window’s title changes", and the Macro Group of "Outlook", it will automatically execute when:
  * The frontmost app is Outlook
  * The Title of the Outlook main window changes, like from "Inbox" to "Calendar"

It will NOT trigger/execute when the FrontMost app is changed.

Then, IF the Outlook window Title is "Calendar", a "Prompt for User Input" will be displayed.

---

###ReleaseNotes

Author.@JMichaelTX

**NOTICE: This macro/script is just an _Example_**

* It is provided only for _educational purposes_, and may not be suitable for any specific purpose.
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete.  It is provided as an example to show you one approach to solving a problem.

**MACRO SETUP**

* **Carefully review the Release Notes and the Macro Actions**
  * Make sure you understand what the Macro will do.  
  * You are responsible for running the Macro, not me.  😉
.
* TRIGGER as uploaded:  
  * the focused window’s title changes
* Test and Review the behavior this Trigger provides.
  * You may also want to consider this trigger:
    * the focused window title changes
* MACRO GROUP:  Outlook
  * Active ONLY when Microsoft Outlook is FrontMost app.
* ENABLE this Macro.
.
* **REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:**
  * ALL Actions that are shown in the magenta color

**USE AT YOUR OWN RISK**

* While I have given this limited testing, and to the best of my knowledge it will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
  * **Ask first**
  * Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.


---

<img src="/uploads/default/original/2X/f/ffb75b12f6c456f4da5bb04d64e483755f42c878.png" width="566" height="874">

Like any app when you first use it, you will need to invest some time in learning the features and use cases for Keyboard Maestro. Whether or not it is easy or hard depends mostly on the individual user, and that user's background, experience, and aptitude. It is not surprising that you find KM initially harder to use than Quickeys, if you have been using QuicKeys for years.

However, I can assure you that the small amount of time you invest in learning KM will yield many, many rewards. KM is by far, the best Mac automation tool I have ever used or tested.

Have you taken the time to go through the KM Tutorial and Getting Started document? If not, please do so.

Whenever you hit a stumbling block trying to concieve of, or create, a KM Macro, please feel free to post in this forum. We have lots of talented KM users, as well as the KM developer, who are happy to help.

Getting Started with Keyboard Maestro

  • Read the Quick Start.
    • This is essential to become familiar with KM terminology
  • Do the tutorial (Help ➤ Tutorial) in the KM Editor.
    • Gives you a live walkthrough of creating a macro in the KM Editor
  • Review/Browse the Available Macro Actions
  • For Help with an Action in your Macro, click on the gear icon at the top right of the Action, and select "Help"
  • Search the Keyboard Maestro Wiki for detailed help.
  • Start small, and grow your macros organically.
  • Be prepared for some trial and error in the beginning.
  • Make good use of this Keyboard Maestro Forum
    • Search for existing macros
    • Post your questions/issues if you get stuck
1 Like

I tried that originally, and it didn’t work. That’s why I tried the other
method that featured the timed repeat of looking for a running or active
application. That macro worked except for the delay and the repeats. I just
went back to my first attempt using the focused window trigger. I set it up
with a title match to the Outlook window Cadlendar. I guess that’s an
uncouth man who loans money. Correcting the transposed letters fixed the
macro. I think I should stop creating macros late at night. Sorry.

Greg Tetrault

Learning how to use the KM Macro Debugger (KM Wiki) will help you save hours of time and frustration. IMO, it is an essential tool/skill.

Nothing wrong with creating macros at night or when you are tired. Just remember to revisit any issues the next day when you are fresh. I actually have solved issues as I am going to sleep or waking up. :wink: