简体   繁体   English

Applescript:“密钥代码”命令不起作用

[英]Applescript: “key code” command not working

I'm trying to run a code to open an app and execute a keyboard shortcut while in it. 我正在尝试运行代码以打开应用并在其中执行键盘快捷键。 When I try to run the code, I receive a message saying: 'Expected end of line but found property' while highlighting the "key". 当我尝试运行代码时,在突出显示“键”的同时,收到一条消息:“预期行尾但找到了属性”。 Is the "key code" registering as two different commands? “键码”是否注册为两个不同的命令?

tell application "Evernote"
activate

tell application "Evernote" keycode 45 using {command down, shift down}

end tell

You have to invoke "System Events" to use UI scripting. 您必须调用“系统事件”才能使用UI脚本。

tell application "Evernote"
    activate
    delay 1
    tell application "System Events"
        tell process "Evernote" to key code 45 using {command down, shift down}
    end tell
end tell

More info at http://macbiblioblog.blogspot.com/2014/12/key-codes-for-function-and-special-keys.html 有关更多信息,请访问http://macbiblioblog.blogspot.com/2014/12/key-codes-for-function-and-special-keys.html

key code belongs to System Events and consists of two words key code属于System Events ,由两个词组成

tell application "System Events" to key code 45 using {command down, shift down}

As keystrokes are always sent to the frontmost application it's actually not needed to refer to the target process when it has been explicitly made active. 由于击键总是发送到最前端的应用程序,因此在明确地将其激活后,实际上不需要引用目标进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM