0
votes

After building an applescript code, I got this error. error "Can’t get keystroke \"2\"." number -1728 from keystroke "2" and I don't know what it means, or how to fix it. My code is supposed to ask the question, open stickies, and then type the returned text into the box. My code below works until keystroke a on line 5. Anyone know the problem? This has been annoying me so long now, and I would appreciate any help.

set a to text returned of (display dialog "What is your name?" with title "Yo name" with icon 2 default answer "" buttons {"Continue…"} default button 1 giving up after 25)
(...)
delay 1
tell application "Stickies" to activate
delay 1
keystroke a
keystroke space
(...)
2

2 Answers

2
votes

You need to tell System Events to keystroke it, here is your new code!

set a to text returned of (display dialog "What is your name?" with title "Yo name" with icon 2 default answer "" buttons {"Continue…"} default button 1 giving up after 25)
delay 1
tell application "Stickies" to activate
delay 1
tell application "System Events"
    keystroke a
    keystroke space
end tell
0
votes

Use the using command down in the keystroke, Here:

tell application "System Events" to keystroke "+" using command down