使用pyautogui,取得滑鼠座標及顏色,可使用座標做自動化點撃滑鼠和移動使用,顏色為增加準確度。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import os import time import pyautogui
try: #跳出視窗。 pyautogui.alert(text='顯示滑鼠座標', title='滑鼠', button='OK')
while True: #查看滑鼠目前位置座標。 x,y = pyautogui.position() #獲取當前滑鼠的位置 print('X座標:{} Y座標:{}'.format(x,y)) #查看滑鼠目前座標顏色。 RGB = pyautogui.screenshot().getpixel((x,y)) print('RGB顏色:{}'.format(RGB)) time.sleep(0.5) except Exception as e: print(f'An Error occurred:',e)
|
沒有留言:
張貼留言