2015-10-21 55 views
0

构建了一个applescript代码后,我得到了这个错误。 error "Can’t get keystroke \"2\"." number -1728 from keystroke "2",我不知道它是什么意思,或者如何解决它。我的代码应该提出问题,打开粘贴,然后在框中键入返回的文本。我的代码如下,直到第5行的keystroke a。任何人都知道这个问题?这一直很烦人,现在我很感激任何帮助。涉及按键的AppleScript脚本错误

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

您需要告诉系统事件按下它,这是您的新代码!

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

谢谢......我给一个试试吧! – AHolasek

+0

总是乐于帮忙,告诉我它是否有效:D – Lucasware

+0

当你在这里时,你如何在applescript中执行类似Command +的命令(带按键) – AHolasek

0

使用使用命令下来的按键,在这里:

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