"Open a File, Folder, Application" not accepting variable?

Sorry, my sarcasm detector was off-line. :wink:
But then, you could have given me a clue, like a wink or something. :wink:

I’ve found that humor doesn’t travel very well these days online, unless there is some overt indication of it. I just witnessed a big blowup in another forum because several people missed the humor of the first poster. :smile:

Do you by any chance remember a late night comedian of yesteryear by the name of Dick Cavett? He had a very dry wit, which most people didn’t get, so his show didn’t last.
But I thought he was hilarious.

Oh? I don’t know about that…

ABC This Morning/The Dick Cavett Show ABC Daytime March 1968-January 1969
The Dick Cavett Show ABC Primetime May 1969-September 1969
The Dick Cavett Show ABC Late Night December 1969-January 1975
The Dick Cavett Show PBS Late Night October 1977-October 1982
The Dick Cavett Show USA Network September 1985-September 1986
The Dick Cavett Show ABC Late Night September-December 1986
The Dick Cavett Show CNBC Primetime April 1989-January 1996

Good point. I forget that there is always at least one elephant in the room. :wink:[quote=“ccstone, post:13, topic:7042”]
The Dick Cavett Show ABC Late Night December 1969-January 1975

This is the show I was referring to. 5 years isn’t bad.

So I take it you were a fan?

Okay, makes sense :slight_smile:

You Bet. Someone with a bonafide 3-digit IQ was on TV for once…

Tom Snyder, Bill Moyers, and Charlie Rose as well.


1 Like

Actually, I now realize what would really be helpful: clicking the error notification bringing up Keyboard Maestro at the step where the error happened, optionally in debug mode! This would decrease the need to go in and out of debug mode and set break points.

Even moreso, it would decrease the most painful experience of using KM, which is having to search for a macro to edit. This happens not only when tracking down a bug, but also when trying to get to the macro you just ran, and, of course, a macro called by another macro :).

You would probably want there to be an option so that this could be turned on or off, but when turned on this would be extremely helpful!

On this same topic: would appreciate ability to set hotkeys for back and forward (preferably Cmd+[ and Cmd+], even though they’re already used). I know I can do it myself but hesitate to make KM search for a graphic just to go back/forward :slight_smile: [and I don’t have UI Browser :P]

Hey Aaron,

See these two posts:

Select the previously edited macro

Select the next edited macro

And examine the rest of the thread.


Unfortunately, the API for Notifications makes dealing with this very difficult - you cannot create different kinds of notifications within a single application (unless you’re Apple anyway). It may be possible, but every time I’ve tried to do anything with notifications it has failed. Also, actions don’t have UIDs so they are hard to target.

There are several popup menus in the top of the editor that let you select recently edited or triggered macros.

Also, any time you select a macro to trigger (eg in a menu or palette), if you hold down the Option key it will edit the macro instead.

This is not exactly what you are asking for, but I think it might help:
###MACRO: [KM] Display Macro Error

Please feel free to post any feedback on the macro topic.

OMG this is gold! It forced me to poke around and find the recently-run and recently-used buttons. They were not obvious, and I recommend putting them next to each other. Perhaps both buttons would have a clock, one with an inset key and the other with an inset pencil?

Also not obvious was press-and-holding those gives a pop-up of the most-recent run/edited (it wasn’t clear what clicking once did)–so ideally have a drop-down arrow (like with font size button) as part of the button.

Great to know about option key as well :slight_smile:

Maybe an option could be that any time a KM notification is clicked that at least the running macro is shown in the editor?

Thanks JMichael, will check it out! I assume you’re also from Australia given the hat? :wink: [or TX!]

@ajg23, you’re welcome.

Well, the “TX” is a BIG clue. :wink:
I guess you didn’t recognize the avatar as being from Indiana Jones. :wink:

I do like the outback hats though.

yeah I thought it was Harrison Ford, but just continuing to play with the Australian topic :wink:

I once had this problem because my variable was a date that was formatted with slashes. So rule that out…

Hey Folks,

One last thing.

When troubleshooting paths always output the complete path to a variable.

Then output that variable to a text editor like BBEdit, so you can visualize it completely.

If it’s an existing path you can test it in the Terminal like this:


file ~/test_directory/test.txt


/Users/myUserName/test_directory/test.txt: ASCII text

You can do the same thing without leaving BBEdit by:

Using a worksheet if you have the commercial version.

OR by writing it as a shell script (in either the commercial or “lite” versions).

#!/usr/bin/env bash

file ~/test_directory/test.txt

Run using the “Run” menu item in the shebang menu (#!). I have this bound to Cmd-R for convenience.

Bitter experience has taught me to NEVER write a macro like:

(Open or some other command) <some complicated string with text-tokens and/or variables>

This makes troubleshooting a nightmare.

If possible I always construct path-strings in such way that I can easily eyeball them.


1 Like

I completely agree with Chris.

To All:

Here’s an AppleScript handler you can use to validate whether or not a file/folder exists:

on doesItemExist(pPosixPath) -- @Path @File @Finder @ASObjC
  (*  VER: 1.0    2017-03-02
  PURPOSE:  Determine if the Path Actually Exists
    • pPOSIXPath    | text  | POSIX Path to check
  RETURNS:  boolean │  true IF the file/folder does exist; else false
  AUTHOR:  JMichaelTX
  BASED ON:  Script by Chris Stone & Shane Stanley
    1. Does a NSURL Have a Valid Target
  ##  Requires:  use framework "Foundation"
  local myNSURL, doesItExistBool
  --- Expand tilde (~) in Path (if it exists) ---
  set pPosixPath to (current application's NSString's stringWithString:pPosixPath)'s stringByExpandingTildeInPath
  set myNSURL to current application's |NSURL|'s fileURLWithPath:pPosixPath
  set doesItExistBool to (myNSURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean
  return doesItExistBool
end doesItemExist
--~~~~~~~~~~~~~~~ END OF handler doesItemExist ~~~~~~~~~~~~~~~~~~~~~~~~~

You could easily put this in a Execute_an_AppleScript action (KM Wiki), and pass the path from a KM Variable:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

tell application "Keyboard Maestro Engine" to set posixPathStr to getvariable "File_Path"

return doesItemExist(posixPathStr)

--- Put the doesItemExist() Handler below ---


I'm using the US International PC keyboard on my MacBook Pro to insert the tilde. The key to insert it is positioned at the right of the left SHIFT key. When I press it, the dead key mechanism is activated:


Then I press space to have the tilde actually inserted: ~.

It took me ages to notice that in Keyboard Maestro the thus inserted tilde isn't the correct one: it's positioned higher. So I copied the correct one from your macro. Is there an easier way to insert the correct tilde, even with the US International PC keyboard activated?

This is probably farfetched, but should Keyboard Maestro have warned my for using the wrong tilde?

Anyway, thanks for your example macro that finally solved this mystery for me.

You could use a KM-only macro that waits for a certain string to be typed and then replaces with the ‘right’ tilde.

I don’t suppose the ‘wrong’ tilde would work in that case because of the dead-key thing, perhaps you could automatically substitute two hyphens -- instead?

So typing:

would result in:

1 Like

My reading (and testing) indicates that these sequences work on the US International PC keyboard:

  • ~ followed by an accentable character (eg a) give that accented character (ã).
  • ~ followed by a space gives the tilde character (~).
  • ~ followed by any other character (eg / in your example) gives the accent by itself followed by the character (˜/).

So my guess is that you simply didn’t press the space after the tilde in this case and got the accent.

No, the accent character (˜) is perfectly legal in file names. Note that in places where Keyboard Maestro excepts a full path (eg reading or writing a file), that path would not be acceptable since it is not an absolute path, however if you renamed or moved a file to that path, then the path would look like a relative path and so it might work as a file name, depending on the circumstances.

1 Like