So lucky to see this post. This is the answer I have been searching for a long time.
Cannot believe it was answered in 2015.
And I just do some edits to make it become a general finder-subroutine.
FINDER Input File path LBL > select in Finder (AS-mtd) v0.kmmacros (8.8 KB)
I think I can create more new macros with this sub
Hello @Yu_Cai
Just a reminder for you - depending on your Text Conditionā¦
If these two Tokens contain the same String youāve got an indication that your Macro was not called by another Macro. They should always be different - or at least if not different Tested even further in using the UUID Variant of these Tokens to ensure the UUIDās are different.
Something like this would be better:
- 1: %ExecutingMacro% is not empty
- 2: %ExecutingMacro% is not %ExecutingThisMacro%
The first indicates there is a Macro it was called by and the second indicates that the calling Macro has a different name.
Be sure you set both conditions using the AND schema.
After doing this youāre definitely good to go.
I hope this helps getting a better understanding of these Tokens.
Greetings from Germany
Tobias
@ Nr.5-need_input
I use this
for purposes:
1st:
Test if the subroutine works good. When you want to test a subroutine, you need a caller to pass variable. But I find if you use this way, you dont need a caller to test subroutine. It's much easier to do test.
2nd:
Some subroutine can be executed independently. I use this way to Initialize starting variables.
I think this method is also from one post on this Forum. Maybe
TIP: How To Determine if Macro is Used a Sub-Macro, Called by a Execute Macro Action - Tips & Tutorials - Keyboard Maestro Discourse
https://forum.keyboardmaestro.com/t/tip-how-to-determine-if-macro-is-used-a-sub-macro-called-by-a-execute-macro-action/16572
Im not sure it's completely correct. But it appears in almost all my subroutine. And I never see strange thing happened.
But I think this is OFF topic. Go back to this post I keep thinking, go further I have two questions.
1st:
we input some file paths, then this macro show them in finder and select/hightlight them. But what if these files belong to different parent folder.
for example, our input is:
/Users/chris/Downloads/Office/3.txt
/Users/chris/Downloads/Office/1.txt
/Users/chris/Desktop/1.png
they belong to differnt folder. What to do in this case?
When you do search in Finder, you can see files belong to different folders appear as search result in one Finder window, can we do this with KM?
2nd:
is there a way to do this in Choose File prompt window?
NOTE that the Choose File prompt window can be opened by another non-Finder APP.
For example. when we want to upload files to Google Drive, we will see this File Choose window
NOTE that It looks like Finder. But I think this window is not belong to Finder, it belongs to Google Chrome. So if you want to do something in AppleScript, it has a lot of trouble here.
I ve been thinking about this for long time. cannot solve this.
Hello @Yu_Cai
Here is what Jim posted 4 years ago ā¦
Itās nothing else than I was saying⦠to determine if a Sub-Macro was triggered by another Macro the Strings have to be different - not the same ā¦
Subroutines (KM10+) are working in the same way ⦠but they can only truly be tested when called from another Macro with parameters, defined via Local or Instance Variables. If you donāt have them defined at the time the Subroutine is triggered it will not act as Subroutine - it acts as a normal Macro or even possible, as Sub-Macro insteadā¦
I have nearly 200 Macros that are written to either be used as main Macro or Sub-Macro as well - and I have more than 500 Macros written to either be used as Main Macros or called via Subroutine Parameters.
To make it clear .. No.
Files can only be selected this way if the Location they are in is exactly the same. As soon as there is another Location available, each file in that location has to be selected from another execution instance of the Macro.
What I can say here is that every File inside a Open File Dialog is handled as a reference to the original File in its original Location.
Maybe it could be done when it is possible to combine talking to the Open File Dialog Instance via GUI Scripting and using the Files as references in AppleScript but
-
thatās far away from what I am able to do with AppleScript.
-
I even donāt have a clue if something like this is possible with AppleScript.
Even in Open File Dialogs - especially there - it is impossible selecting Files from different Locations.
If the location is a .savedSearch (Smart Folder) you are working with the File references (aliases) of the original Files in their respective original Locations. Not the original Files. But it is possible getting the original Fileās Locations from these aliases in bulk and the File Aliases will all be available for selection but the Location (the Smart Folder) is treated as it is - a single Location. As if it would be a normal Folder.
Greetings from Germany
Tobias
Hi
You really know what im thinking.
I want to use programming way to play with file chooser window.
the macro should be
Input file path list
>
KM open file Chooser
>
KM reveal first file in file chooser window
>
KM select all needed files
>
KM press OK
By now, I only can go to third step - locate file.
When you see the file chooser. you can locate file by press shift+cmd+G.
But you cannot go further. You cannot use Applescript select files in file chooser like how to do in Finder.
What's interesting is that this shift+cmd+G command is belong to Finder. It's a finder function. But the left up corner of screen is till showing the current APP is Google Chrome.
what can do, what cannot do, a lot of confusion here.
It is not easy to do this for my level.
Greetings
Hey @Yu_Cai
Since Open & Save File Dialogs are instances of the Finder Application integration provided via Apples APIās you can use the mentioned Shortcut to jump to a desired Location. If you provide a full File Path including a single File it will automatically be selected because you told the Dialog to select the File by passing its full path. But the result is that the reference to the File is used in the task behind the instance of the Dialog.
If it might eventually work using AppleScript to select multiple Files in a desired Location referenced by the Dialog the script would be quite different to the script that is used in your Macro. But again if this is possible, it is far beyond my skills.
It also "belongs" to standard macOS file-picker dialogs (Open, Save, etc...).
Think of your screenshot above as "Chrome is the active app, but the dialog has the context of Finder and some Finder commands are available there".
And not just ā§āG -- you could, for example, right-click and rename a file or folder.
@Yu_Cai - these two variants are meant to be absolutely the same. While mine is more technical, Nigeās post uses just a non technical term to describe whatās going on.
Greetings from Germany
Tobias
Anyone using SATIMAGE.OSAX on macOS 15.1?
I can't get it to run/install...
You might want to read these:
Here's a revised Select Finder Files script that doesn't require anything else (ie: SatimageOSAX) but KM. Works well in my brief testing on macOS Sequoia 15.1 with KM 11.0.3
Select Finder Files.kmmacros (41.3 KB)
Hope this helps someone!