Comment #24 of the thread:
That post includes AppleScript code that lists the filename, position
, bounds
, and comment
properties of each file in the hardcoded folder. That's probably what you remember.
One thing I discovered, when AppleScript gets the filename from KBM, it doesn't know initially that KBM is giving it a POSIX path, you have to tell it. And you have to convert that POSIX path to an alias
to be able to get the properties of the file. It reminds me of Alice talking to Humpty Dumpty in "Through the Looking Glass" where he explains, "That's not the name of the poem, that's what the name of the poem is called."
(Elsewhere I posted a version of that which added the default application, which is not a Finder property, you have to get it from System Events. If you need that, I can find the thread.)
Here is AppleScript code that works inside a KBM macro to get the position
property:
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set thisKBMFile to getvariable ¬
"local_ChosenIconFilename" instance kmInst
end tell
set selectedFile to POSIX file thisKBMFile as alias
tell application "Finder"
set thePosition to position of selectedFile
end tell
return thePosition
This is the core of what will probably become a subroutine for other macros to use in getting any particular file icon's position in the Finder window.
For testing, I put the above code in a macro that demonstrates that it has found the position by drawing a KBM rectangular highlight around the icon when that icon has been selected and the macro is run.
Get Center of Icon, Show Rectangle Macro (v10.2)
Get Center of Icon- Show Rectangle.kmmacros (10 KB)
Thanks for your help on this!