2011-04-13 62 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