20180129週一之學習PYTHON筆記【PYTHON2寫個自動點擊學習功能】

pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('sy.png')))  #點擊該截圖一次python

--------------------------------------------------------------------ui

一,首先安裝PYTHON2.7.spa

二,安裝pyautoguo ,  PIL,Pillow,  Image,  matplotlib模塊。code

三,pip install Pillow圖片

  圖片的打開與顯示ip

from  PIL  import  Image
img = Image. open ( 'd:/dog.png' )
img.show()
另上一種方式,讓程序來繪製圖片。
from PIL import Image
import matplotlib.pyplot as plt
img = Image. open ( 'd:/dog.png' )
plt.figure( "dog" )
plt.imshow(img)
plt.show()
----------------------------
獲取PNG的座標
from PIL import Image
import pyautogui
img = Image. open ( 'c:/python272/qq1.png' )
img.show()              #以上兩句必須
pyautogui.locateOnScreen( 'qq1.png')         #確保桌面顯示有該圖片,將返回圖片座標
pyautogui.center((643, 745, 70, 29))            #獲取座標中心
pyautogui.click((643, 745, 70, 29))               #單擊座標中心
------------------------------------------------------------------

mu=pyautogui.locateOnScreen('qq1.png') string

print(mu)pip

(890, 438, 40, 74)io

-----------------------------------------------------------function

 pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('sy.png')))  #點擊該截圖一次研究成果
相關文章
相關標籤/搜索