This has to be fairly simple. I'm using Applescript with Pashua: Native macOS dialogs for scripting languages. What I'm trying to do is enter data into a text field in a dialog, and then copy that text field to the clipboard when the dialog box closes. Simply setting the clipboard to the variable tf
doesn't work.
How can I get this script to copy the contents of tf
to the clipboard? The Applescript results window shows {tf:"testme"}
for an input of testme
, but I don't want the output markup, only the text testme
copied to the clipboard.
The relevant part of the script is at the bottom of the full script:
-- Get the path to the folder containing this script
tell application "Finder"
set thisFolder to (container of (path to me)) as string
if "Pashua.app:" exists then
-- Looks like the Pashua disk image is mounted. Run from there.
set customLocation to "Pashua:"
else
-- Search for Pashua in the standard locations
set customLocation to ""
end if
end tell
try
set thePath to alias (thisFolder & "Pashua.scpt")
set pashuaBinding to load script thePath
tell pashuaBinding
-- Display the dialog
try
set pashuaLocation to getPashuaPath(customLocation)
set dialogConfiguration to my getDialogConfiguration(pashuaLocation)
set theResult to showDialog(dialogConfiguration, customLocation)
on error errorMessage
display alert "An error occurred" message errorMessage as warning
end try
end tell
on error errStr number errorNumber
display dialog errStr
end try
-- Returns the configuration string for an example dialog
on getDialogConfiguration(pashuaLocation)
if pashuaLocation is not "" then
end if
return "
# Set window title
*.title = Page Settings
# Add a text field
tf.type = textfield
tf.label = Example textfield
tf.width = 310
"
set the clipboard to tf -- how do I set this variable to the clipboard?
end getDialogConfiguration
do shell script “‘abcd’ | pbcopy”
. See if you can get the variable in place of abcd string