Input Text Without Seeing It Typing?

I'm using the "Insert Text by Typing", but it shows the actually typing and all that, adding some extra time to the whole macro.

Is there a way to just make it run without showing the action itself running on screen?

In Finder I want the CMD+i to go to a specific folder, so I'm using the Go To Folder by using the shift+cmd+G shortcut, then "Insert Text by Typing", then "Return".

I'm using this, because I want it go to the folder, but opening that folder on the same window. I noticed that the "Open a File, Folder or Application" goes to the folder, but as a new window and I would like to avoid opening extra windows.

If there's another easy and quick way to achieve this, please let me know.

But even then, if you can help me with my initial question so I can understand how to make it work for other macros, that would be awesome as well!! :smiley:

Thanks!

If you are in Finder you can go to the Folder in a more direct way. Use the Open a File Folder or Application Action and set it to open with Finder.

For this question, Instead of using insert text by typing set it to pasting. Sometimes one method is better than the other depending on the circumstances. Insert by Typing usually is good if a field won't allow text to be pasted in (lots of forms on websites won't allow pasting).

One possible downside of using by Pasting is that whatever the text is becomes the latest entry in the System Clipboard. The way to get around that is to add another Action at the end of your Macro to reset the Clipboard to whatever it was before.

2 Likes

Thanks for the reply!

As I mentioned, this action opens a new window. I want the current window to go to the folder, so if Finder only has 1 window open, I want it to keep it that way instead of now having 2 windows. This is the reason I was using the shift+cmd+G shortcut, because that sends the current folder to the new one.
Is there a way to make it behave this way, using the "Open a File Folder or Application" action?

This seems a bit confusing... didn't you mean something different? More like "Insert by Typing usually is good if a field won't allow text to be pasted (lots of forms on websites won't allow pasting)."

Also, my goal is to actually avoid using the shift+cmd+G so even the Pasting option would have an extra step (open the Go To panel), and I would still see the whole macro running. I was thinking of maybe running an AppleScript, but I'm not familiar with scripting at all.

Basically my idea behind the script would be like:
Tell finder to change the most upfront window to XYZ location
Similar to when you click a location on the sidebar, you know? It changes the current folder to the new location, it doesn't open a new window (unless you hold CMD, of course).

Hope I'm making sense here :slight_smile:

You're so very close to an actual AppleScript step that would do what you want! Say I want the frontmost Finder window to to change from being "whatever_Folder" to the "Wine Extract" folder on my Desktop. In long, very explicit, form so you can see all the steps:

tell application "Finder"
	set targetFolderName to "Wine Extract"
	set pathToDesktop to path to desktop folder as text
	set newTarget to pathToDesktop & targetFolderName
	set newTarget to newTarget as alias
	set target of window 1 to newTarget
end tell

AppleScript is very English-like. So this is "Tell the Finder that the folder I want to see is named 'Wine Extract'. Get the path to my Desktop, then turn that path into text so I can concatenate the folder name on the end. Turn that longer string back into an alias reference the Finder can use, and tell the frontmost window to open that reference".

If you only ever want to go to one location you could hard-code the path. You could feed a KM variable in as the "targetFolderName" variable. You could always start at your home folder and have KM feed in a relative path from there. Plenty of options to make this work how you want, without having to manipulate the Finder via the GUI.

1 Like

Thank you so much for the detailed and helpful reply :slight_smile:

Yes, AppleScript seems very English-like as you said. I have some super hyper basic understanding of JavaScript (and I mean, SUPER basic) and so it's not 100% unfamiliar, but still don't know the specifics. I will save this thread for future reference, though!

I have this complex script someone wrote for me and this is what they start with to set the folder where the action takes place:

set rootFolder to "" & (path to home folder) & "Backups:"

So my guess is that when you say set rootFolder you are just creating a variable, right? It could be any name like set oceanPacific, right? Of course we want to have names that make sense, but just making sure I understand it.

Then I can set a folder relative to another location, in this case the home folder.

So now I have 2 questions:

  1. Besides desktop folder and home folder that seem to be recognized by the script and then other targets will be relative to them, what other folders can be used that way? Hope it makes sense what I'm asking.

  2. If I wanted to target a folder inside Backups, would I do this for example:
    set rootFolder to "" & (path to home folder) & "Backups:NewFolderName"
    Right?

  3. What is the purpose of the "" in the beginning? Do you know?

I don't really understand what you mean by this... can you clarify?

Thank you :)O

Yes, you are right. I meant pasted. I've changed it to avoid confusion if ever anyone ever reads it again :grinning:

1 Like

Sorry, the script you sent me probably has something wrong, because it's opening another application and is acting all weird... I don't even want to run it again, because it was renaming a folder that was somewhere else and when I ran it again and opened Firefox, it seems like it was still running it and wanted to save the webpage... super weird... :confused:

Screen Shot 2022-04-18 at 1.36.26 PM

Screen Shot 2022-04-18 at 1.39.47 PM

Screen Shot 2022-04-18 at 1.40.04 PM

So, unpacking the line of code:

set rootFolder to "" & (path to home folder) & "Backups:"

Yes, that's a variable called "rootFolder". The stuff to the right of "to" takes precedence over the variable assignment, as you would expect.

AppleScript does its best to implicitly coerce types. "path to home folder" will return an alias -- a file/folder reference, the "&" is the concatenation operator. By starting with the empty string "" it is saying "We're building a string, so coerce everything that follows to a string wherever necessary". The long form, with brackets to show you precedence, would be:

set rootFolder to ( ( (path to home folder) as text) & "Backups:")

Every scriptable application has an AppleScript dictionary which you can view in Script Editor with File->Open Dictionary... then choosing from the list. "Special" folders can be found in the System Events dictionary, listed in "user domain object". Have a look in the Finder dictionary, specifically "Finder window" in "Window classes" to see what the script line containing "target" is all about.

To properly target a folder inside "Backups" you should finish with ":", just as a *nix path to a directory should finish with a "/". It doesn't matter if you're going to resolve that text string to a file system alias, your Mac is smart enough to work things out, but it's good practice that will stop you making mistakes when building paths with text concatenation (you don't have to remember to keep adding the ":" before adding a file/folder name).

The clarification bit... If you only ever want to go to one folder on one computer with your script you can use an explicit reference, eg "Macintosh HD:Users:danny:Desktop:Backups:". If you wanted to use it on multiple computers, which might have different disk names or user short names, you could build the path starting "path to desktop folder" so the script would work on whichever computer you were at, eg '(path to desktop folder) as text)) & "Backups"'. And you can also use KM variables within your AppleScript, there's an example here, so you could make a decision earlier in your KM macro and use the result of that to create your path.

2 Likes

That's seriously weird -- there's nothing in that script that would do any of the things you describe!

What happens if you run it from Script Editor instead (note that the script doesn't activate the Finder, so you'll have to manually switch to Finder to see the result of running it)?

What OS and Keyboard Maestro versions are you running? I'll see if I can set up similar and replicate the issue.

1 Like

That works, no issues.

My OS is 10.15.7 (Catalina)
KM: 10.0.2

Thanks for the clarification. I understand it now. If I use those terms that are not relevant only to my computer, the script can be used by other people. Makes sense.

I will also check those links and resources you mentioned. I appreciate your time and help :slight_smile:

I span up a Catalina system, put the KM 10.0.2 trial on it, and the following worked first time every time:

Test Folder.kmmacros (2.0 KB)
Test Folder

I tried to do the same as you, but couldn't use the Control key in a trigger over VNC -- hence the different shortcut. I've since tested with an attached keyboard and the same shortcut as you, and everything still works fine.

So I don't know what your problem is, but it seems specific to you rather than being a general Catalina/AppleScript/Keyboard Maestro issue.

Dident know about delete past clipboard very useful.
It should be included in the “paste by typing” command bf default.

@peternlewis perhaps a good idea to have a checkbox for that in “insert by pasting” action?

A checkbox for what? Deleting the clipboard? No, it would not be a good idea as it is not a good idea in general to delete the clipboard after pasting for the reasons described in the FAQ Why is the clipboard not restored after any clipboard action?

1 Like

Run this from Apple's Script Editor.app – then search for “path to” in the resulting dictionary window. When you find the right entry you'll see a listing of the available folder path shortcuts:

set standardAdditionsOsaxFile to alias ((path to system folder as text) & "Library:ScriptingAdditions:StandardAdditions.osax:")

tell application "Script Editor"
   activate
   open standardAdditionsOsaxFile
end tell