Open a File From a Notification Banner Using Keyboard Maestro

Hi, i want to open a specific file by clicking on the "show" button on notification using keyboard maestro.. i know how to open a specific file on the app, i just don't know which trigger to use for this action ? or if it is even possible to do this..

Hey @Imed,

The macOS doesn't offer hooks to allow Keyboard Maestro to process clicks in a Notification banner.

If you explain your task in more detail we might be able to offer alternatives.

-Chris

Every day at specific times I need to open and read a pdf. I don't want it to open automatically as it would cause some problems if I was using the mac. If there was an option that could show me a message/reminder that km will open the specified pdf with 2 options :

  • yes : open it now
  • no : I'll open it myself later

Thank you for your concern.

Hey @Imed,

This may or may not import into Keyboard Maestro v8.2.4, as it is from the as yet not released KMv9.0.

In any case it should give you the basic idea.

-Chris


Timed Macro Example v1.00 (km9.0d5).kmmacros (7.2 KB)

1 Like

You can use the Text condition to test the PromptButton token directly, no need for the variable.

You may also want to add an action like:

Pause Until calculation IDLE() > 10

to reduce the intrusiveness of the dialog appearing while working.

Hi @Imed here is my solution.

I use an AppleScript to display a dialog window. In this window I integrated the KM macro AppleScript, which is executed after pressing the "Yes" button.

All you have to do is create a macro to open your PDF and of course customize the app icon :wink:

2019_07_28_Support_1

Daily backup.kmmacros (2,7 KB)

My AppleScript with it:

display dialog "Want to start a backup?" with icon file "Applications:BetterTouchTool.app:Contents:Resources:AppIcon-2.icns" buttons {"Later", "Yes"} default button "Yes"
if button returned of result = "Show" then
   tell application "Keyboard Maestro Engine"
      do script "CEA5F53E-73DD-4138-9B1D-4AB3C058655F"
   end tell
end if

Unfortunately I haven't found any instructions yet to do this in KM or with a script @Imed.
Since I like to combine the possibilities of different apps, I use the notification alert of the ChronoSync App.
Besides the sync tasks I can also execute only one AppleScript at a time.

So insert a reference to the KM macro AppleScript and I can work with the ChronoSync Notification Alert.

Looks also a little more stylish, than with the display dialog :wink:

2019_07_28_Support_4