0
votes

i'm writing a script that needs to copy and paste text from an entry in a dialogue box

set query to text returned of (display dialog "Enter Text" default answer "" buttons {"Input", "Cancel"} default button 1)
query
tell application "System Events"
    keystroke "c" using command down
    keystroke "v" using command down
end tell

when i run this script it copies and pastes "set query to text..."

how can I copy the query that I entered ? i'm going to paste the text somewhere else later but I need to figure out how to actually copy the text. I was using keystroke query but that was taking a long time when the strings were long

1

1 Answers

0
votes

Use set the clipboard:

display dialog "" default answer ""
set the clipboard to text returned of result

If others get here searching for how to for example copy a long error message from a dialog shown by OS X, you can use Accessibility Inspector, which is in /Applications/Xcode.app/Contents/Applications/.