Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.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
Python Sikuli脚本减速-鼠标向下:延长延迟_Python_Mouseevent_Python Multithreading_Sikuli - Fatal编程技术网

Python Sikuli脚本减速-鼠标向下:延长延迟

Python Sikuli脚本减速-鼠标向下:延长延迟,python,mouseevent,python-multithreading,sikuli,Python,Mouseevent,Python Multithreading,Sikuli,我正在使用sikuli实现游戏自动化。完整代码相当长,但移动/单击鼠标的部分如下所示:- class click_thread(threading.Thread): def __init__(self, reg_to_click): threading.Thread.__init__(self) self.reg_to_click = reg_to_click def run(self): click_lock.acquire()

我正在使用sikuli实现游戏自动化。完整代码相当长,但移动/单击鼠标的部分如下所示:-

class click_thread(threading.Thread):
    def __init__(self, reg_to_click):
        threading.Thread.__init__(self)
        self.reg_to_click = reg_to_click
    def run(self):
        click_lock.acquire()
        click_func(self.reg_to_click)
        click_lock.release()

def click_func(reg_to_click):
    while True:
        if auto_mouse == 'go': #this is global variable to 'pause' the mouse actions if need be by reassigning it somewhere else
            Settings.MoveMouseDelay = 0.1
            Settings.DelayBeforeMouseDown = 0.1
            Settings.ClickDelay = 0.1
            click(reg_to_click.getCenter())
            mouseMove(0,50)
            break
        else:
            print((time.asctime(time.localtime(time.time()))),"click func recd call - waiting 1s")
            wait(1)

click_lock = threading.Lock()
我使用线程来处理鼠标操作。代码中的其他函数在需要鼠标单击屏幕上的某个对象时,按以下方式创建线程实例:-

        click_thread_instance = click_thread(reg_to_click)
        click_thread_instance.start()
        click_thread_instance.join()
程序运行时会变慢,导致我使用它的游戏中出现很多“超时”。当我检查日志时,最常见的条目似乎是“MouseDown:ExtendedDelay”。我试着从IDE和命令行运行它。这似乎对这个问题没有影响。你知道是什么导致了这种情况,以及可以采取什么措施来纠正它吗

我的环境:-

操作系统:-Microsoft Windows 10 Home,64位 Java:-版本8,更新151,版本1.8.0_151-b12 西库利:1.1.1

提前谢谢

其他一些信息:- 我尝试通过一个函数来执行单击,而不是使用多线程来查看它是否有任何不同:-

def click_func(reg_to_click):
    while True:
        if auto_mouse == 'go':
            Settings.MoveMouseDelay = 0.1
            Settings.DelayBeforeMouseDown = 0.1
            Settings.ClickDelay = 0.1
            click(reg_to_click.getCenter())
            mouseMove(0,50)
            break
        else:
            print((time.asctime(time.localtime(time.time()))),"click func recd call - waiting 1s")
            wait(1)
脚本中的所有其他函数现在都调用此函数以完成任何单击操作。我仍在经历脚本逐渐变慢的过程。以下是最新的日志:-

[debug] MouseDown: extended delay: 1026
[debug] MouseDown: extended delay: 1176
[debug] MouseDown: extended delay: 1493
[debug] MouseDown: extended delay: 1584
[debug] MouseDown: extended delay: 1658
[debug] MouseDown: extended delay: 3077
[debug] MouseDown: extended delay: 3248
[debug] MouseDown: extended delay: 3394
[debug] MouseDown: extended delay: 5769
[debug] MouseUp: extended delay: 1083
[debug] MouseUp: extended delay: 1094
[debug] MouseUp: extended delay: 1159
[debug] MouseUp: extended delay: 1263
[debug] MouseUp: extended delay: 1394
[debug] MouseUp: extended delay: 2123
对于如何解决这个问题,如有任何建议,我们将不胜感激


谢谢

OSX上可能存在类似问题的一些bug。如果你在这里没有得到任何有用的结果,我建议你在Sikuli Launchpad上问这个问题。