a quicker alternative to keystrokes in the GUI (long lines of text)

EDIT: The text is being entered into a safari “save as…” text box.

The posix paths of the files I use the script in question for get kinda long, this command “keystroke pOSIXPathOfTargetFile” takes forever. What’s the best practice for speeding it up?


keystroke pOSIXPathOfTargetFile

I’d rather not go by the clipboard and copy/paste cause that’s messy and potentially surprising to users besides me --and not in a good way.

In which context? Seeing your previous post you’re writing for Safari. you can open url’s with the default or designated browser using open command in CLI.

do shell script "open 'file:///Users/<user>/Desktop/myfile' -b org.mozilla.firefox"

entering text into the “save as…” field

the method to set the value of the text field is preferable if the text field supports it

It supports it and is indeed the best way indeed to fill a text field because a user can press keys too during this action. also it doesn’t need to be the first responder as well.

this code worked for me when opening safari (at least 1 window is open) and manually pressed ‘save as’ from the main menu and then run the code below.

--This expects that there is a save panel open in the first window.
tell application "System Events"
	tell process "Safari"
		set value of text field 1 of sheet 1 of window 1 to "DJ Bazzie Wazzie"
	end tell
end tell