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.
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
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? [or TX!]
@ajg23, youβre welcome.
Well, the βTXβ is a BIG clue.
I guess you didnβt recognize the avatar as being from Indiana Jones.
I do like the outback hats though.
yeah I thought it was Harrison Ford, but just continuing to play with the Australian topic
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:
Command:
file ~/test_directory/test.txt
Result:
/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.
-Chris
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
PARAMETERS:
β’ 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
REF:
1. Does a NSURL Have a Valid Target
https://lists.apple.com/archives/applescript-users/2017/Mar/msg00010.html
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
*)
## 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
--- GET NSURL & DETERMINE IF IT ACTUALLY EXISTS ---
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
--- CHANGE THE KM VAR NAME "File_Path" TO MATCH YOUR NAME ---
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:
--/Dropbox/
would result in:
~/Dropbox/
My reading (and testing) indicates that these sequences work on the US International PC keyboard:
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.