import pyautogui import time def search_position(): time.sleep(1) x1, y1 = pyautogui.position() print("您当前位置坐标为:", "x:" + str(x1), "y:" + str(y1)) # 获取宽度和高度 time.sleep(1) x2, y2 = pyautogui.position() width = abs(x2 - x1) height = abs(y2 - y1) print("宽度:", width) print("高度:", height) if __name__ == "__main__": print("请将鼠标移动到您想要确定宽度和高度的区域的左上角,并记录下该位置的坐标。") input("按 Enter 键继续...") while True: search_position() pass