如何使用 AppleScript 在 Safari 中实现屏幕点击?
我正在尝试创建一个脚本来单击特定的游戏“水晶骑士” 然后单击“将所有礼物排队”
while loop forever
then click "accept"
then do keyboard command "command w"
then wait 5 seconds
我正在使用 AppleScript,这就是我到目前为止所拥有的:
tell application "Safari"
activate
open location "http://apps.facebook.com/gfriendfinder/?ref=bookmarks&count=0"
delay 5
tell application "System Events"
click at {750, 550}
end tell
end tell
我不确定为什么单击功能不起作用。它在正确的地方吗?
I am trying to create a script that will click on the specific game "knights of the crystals"
then click "Queue all Gifts"
while loop forever
then click "accept"
then do keyboard command "command w"
then wait 5 seconds
I am using AppleScript and this is what I have so far:
tell application "Safari"
activate
open location "http://apps.facebook.com/gfriendfinder/?ref=bookmarks&count=0"
delay 5
tell application "System Events"
click at {750, 550}
end tell
end tell
I'm not sure why the click at function is not working. Is it in the right place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,这是一种不好的形式,并且可能会因为在不需要时将一个告诉块置于另一个告诉块内而导致问题。例如,您告诉 safari 告诉系统事件点击,而您不需要 safari 这样做。 “打开位置”命令或“延迟”命令甚至不需要 Safari。因此,一般来说,如果不需要,不要告诉应用程序执行某些操作。其次,我发现执行点击对于系统事件多次不起作用。我开发了一个鼠标单击命令行工具,可以在发生这种情况时使用。您可以在此处获取它。下载该文件并将其放在桌面上,然后运行此脚本并查看是否有帮助。
另一种想法是学习 javascript,因为 Safari 可以理解 javascript,并且您可以用它来按下 Safari 网页中的按钮。我不是 javascript 专家,所以我无能为力。
First, it's bad form and could cause issues by having one tell block inside of another when it's not needed. For example you are telling safari to tell system events to click, when you don't need to have safari do that. Safari is not even required for the "open location" command or the "delay" command. So in general do not tell an application to do something if it's not required. Second, I have found that performing clicks doesn't work many times with system events. I have developed a mouse-clicking command line tool to use when that happens. You can get it here. Download that and place it on your desktop, then run this script and see if that helps.
One other idea would be to learn javascript, because Safari understands javascript and you can probably press the buttons in a Safari web page with that. I'm not a javascript expert though so I can't help with that.