2011-04-13 102 views
0

我試圖做一個簡單的AppleScript其沒有按如下:粘貼到Microsoft Word使用AppleScript

切換到Microsoft Word 型* 按粘貼(命令V) 按回車鍵

我來了與此,但它不會工作...任何想法,爲什麼?

tell application "System Events" 
    tell application process "Microsoft Word" to activate 
     keycode(42) 
     keycode(118) 
     keycode(3) 
    end tell 
end tell 

回答

2

你用錯了方式鍵代碼和你訴說塊是不正確的嘗試這個

tell application "Microsoft Word" 
    activate 
    tell application "System Events" 
     tell application process "Microsoft Word" 
      key code 42 
      key code 118 
      key code 3 
     end tell 
    end tell 
end tell 
+0

我認爲你有錯誤的代碼來獲取*雖然 – mcgrailm 2011-04-13 13:23:14

2

一般來說你的代碼更容易編寫和更可讀的,如果你使用的文字儘可能而比鍵碼。

tell application "Microsoft Word" 
    activate 
end tell 

tell application "System Events" 
    tell application process "Microsoft Word" 
     keystroke "*" 
     keystroke "v" using command down 
     keystroke return 
    end tell 
end tell 
相關問題