Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何在AppleScript上执行其他任务时单击后台应用程序?_Macos_Applescript - Fatal编程技术网

Macos 如何在AppleScript上执行其他任务时单击后台应用程序?

Macos 如何在AppleScript上执行其他任务时单击后台应用程序?,macos,applescript,Macos,Applescript,好的,我正在尝试制作一个applescript,它在每一个设定的时间点点击一个设定的点。问题是我不知道如何在后台使用脚本,而不干扰其他应用程序。我不能用GUI编写脚本,因为我正在编写脚本的应用程序是用Java编写的。Applescript不会很好地做到这一点,但可以使用从Applescript启动的其他语言来完成,如Python: set x to 30 set y to 5 set l to 50 -- click same location 50 times do shell script

好的,我正在尝试制作一个applescript,它在每一个设定的时间点点击一个设定的点。问题是我不知道如何在后台使用脚本,而不干扰其他应用程序。我不能用GUI编写脚本,因为我正在编写脚本的应用程序是用Java编写的。

Applescript不会很好地做到这一点,但可以使用从Applescript启动的其他语言来完成,如Python:

set x to 30
set y to 5
set l to 50 -- click same location 50 times

do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent);             # Save current mouse position
for x in range(0, " & l & "):
          mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y));      # Restore mouse position
END"

我怀疑你的方法注定要失败:-想想为什么你需要点击那个点,并找到一种不同的方式来做它-刷新一个页面,或下载一个文件,还是什么?我用这个脚本来点击Java游戏中的一个点。