tell application "Adobe InDesign CC 2015" to activate
tell application "System Events"
tell application process "Adobe InDesign CC 2015"
keystroke return
end tell
end tell
If I run your script in Applescript Editor the dialog appears.
If I then use Script Debugger to execute the System Events part, that hits the return key, the dialog generated by Applescript Editor is cancelled and it disappears.
This is a bit of a guess but I’m wondering if you can’t target the AppleScript Editor like that.
I’m sure someone will correct me if I’m wrong
It cannot work because display dialog works modally,
that means the execution of the next line is suspended
until display dialog receives the button pressed or gave up timeout event
So you can’t script a button pressed with GUI script in a display dialog?
One of the things I am trying to do is action dialog boxes when importing into Calendar from an ics file. So i need to GUI script that. So something like this would work.
tell system events
tell calendarfilehandler
keystroke return
end tell
end tell
. although this still works. Apologies for posting it again.
on showError(msg)
set b to {"¢", ""}
repeat 6 times
do shell script "osascript -e 'say \"Error\" using \"Zarvox\"' -e 'tell application \"System Events\" to keystroke return' > /dev/null 2>&1 & "
display dialog msg buttons b default button "" with title "OH NO! WE'RE ALL GOING TO DIE!" cancel button "¢" with icon caution
delay 0.1
set b to reverse of b
end repeat
say "Ah ha ha" using "Hysterical"
error number -128
end showError
try
set fire to my trousers
on error msg
showError(msg)
end try