sydomain

思绪来的快,去的也快,偶尔在这里停留。

python获取当前的X,Y以及宽度和高度坐标(自动循环获取)

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


Powered By sydomain

Copyright Your WebSite.Some Rights Reserved.