1

在 pyglet 和 autopygui 之间发生冲突,当一个运行时我不能使用另一个。我在网上找到了一些东西,但没有人发布解决问题的方法。

ctypes.ArgumentError: argument 1: <class 'TypeError'>: expected LP_POINT instance instead of pointer to POINT

https://github.com/asweigart/pyautogui/issues/26 https://code.google.com/archive/p/pyglet/issues/559

这已与问题 510 一起修复。e46762382a3

据说可以在那个链接中解决,但我仍然遇到问题。

https://bitbucket.org/pyglet/pyglet/issues/95/pyglet-error-with-lp_point-pyautogui

4

1 回答 1

1

我们遇到了同样的问题,这似乎是在 autopygui 使鼠标单击时出现的。

如果您可以导入额外的库,这里有一个可能的解决方法:您可以使用 autopygui 在屏幕上定位图像,并使用另一个库来使鼠标“单击”。例如:

import ctypes
import pyautogui

def click_mouse_at(pos):
    pos_x, pos_y = int(pos[0]), int(pos[1])
    ctypes.windll.user32.SetCursorPos(pos_x, pos_y)
    ctypes.windll.user32.mouse_event(2, 0, 0, 0,0) 
    ctypes.windll.user32.mouse_event(4, 0, 0, 0,0)
    
def get_centre(a_box):
    ''' return centre of an image '''
    return a_box[0]+a_box[2]/2, a_box[1]+a_box[3]/2

an_img_file_path = ..path to your image file..
click_mouse_at(get_centre(pyautogui.locateOnScreen(an_img_file_path)))

在 Windows10 上测试,似乎可以工作

于 2020-10-07T15:08:45.723 回答