2015-10-21 144 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