AppleScript的可以通过发送键箭头键了吗? [英] Can Applescript send arrow keys via key down?
问题描述
我试图使用箭头键来控制谷歌地球,但是,我想与AppleScript的做到这一点。本质上,这code应该工作,我会告诉你它实际上做。
I am trying to control google earth using the arrow keys, however, I want to do this with applescript. Essentially this code should work and I'll tell you what it actually does.
tell application "System Events"
delay 3
key down 124 #Value of key right
delay 3
key up 124
end tell
这code应该等待我去谷歌地球,那么它将按住右箭头键3秒。然而,它只是打A。我看到了一些建议,做到以下几点:
This code should wait for me to go to google earth, then it will hold the right arrow key for 3 seconds. However, it just hits 'a'. I saw some recommendations to do the following:
key down (key code 124)
这样的作品,它preSS右键只有一次,不持有它。
This sort of works, it press the right key only once and does not hold it.
如果你这样做与如D的键(也用于导航谷歌地球右)它完美。 (我觉得键,2做的)。
If you do this with a key such as D (also used to navigate right in google earth) it works perfectly. (I think "key down 2" does that).
所以我的问题是,是否有办法实际上使方向键的作用? 工作在这里是指发送不阕脚本,可以在以后用钥匙事件取消了key down事件。我真的很希望能够控制飞行模拟器(WASD不起作用 - 方向键一样)。
So my question is, is there a way to actually make the arrow keys work? "Working" here refers to sending a key down event that does not tie down the script and could later be canceled with a key up event. I would really like to be able to control the flight simulator (WASD does not work -- arrow keys do).
感谢您的所有建议,
杰克
推荐答案
本脚本presses右箭头键3秒:
This script presses the right arrow key for 3 seconds:
tell application "System Events"
set now to the seconds of the (current date)
set later to now + 3
if later > 60 then set later to later - 60
repeat while the seconds of the (current date) is not later
key down (key code 124)
end repeat
end tell
我不知道这是否会与谷歌地球的工作,但我知道剧本是正确的。
I don't know if this will work with Google Earth, but I do know that the script is correct.
这篇关于AppleScript的可以通过发送键箭头键了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!