python獲取滑鼠坐標
發布時間: 2022-08-21 12:50:12
A. python 獲取滑鼠在圖片上的坐標
下pygame mole,然後
importpygame
pygame.init()
screen=pygame.display.set_mode([100,100])##sizeofwindow
your_image=pygame.image.load("your_image_name.png")##imagemustbeinthesamefolder,elsepathmustbespecified
while1:
screen.blit(your_image,[0,0])##posofyourimageonthewindow
foreventinpygame.event.get():
ifevent.type==pygame.QUIT:
exit()
position=pygame.mouse.get_pos()##positionofmouseonwindow
printposition
pygame.display.set_caption(str(position))##makeitthetitleofthewindow
pygame.display.flip()
B. 如何用Python批量獲取經緯度坐標
python根據地址獲取經緯度方法一:
from geopy.geocoders import Nominatim
#使用geopy查詢
def geocodeN(address):
gps=Nominatim()
location=gps.geocode(address)
return location.longitude,location.latitude
使用Geopy包 : github.com/geopy/geopy (僅能精確到城鎮,具體街道無結果返回)
另外還有一種使用高德地圖或網路地圖API的方法,有興趣的朋友可以參考下。
參考鏈接:https://panxu.net/article/8382.html
C. python如何抓取滑鼠點擊事件,並返回點擊所在坐標(Xlib庫)
你好!
問題補充:拜託了
event里有x、y,是相對坐標,x_root,
y_root是屏幕上的坐標。
如果對你有幫助,望採納。
D. 如何用python模擬點擊onclick
安裝PyUserInput可以輕松實現模擬滑鼠點擊,安裝方法:
apt-get install python-pip
pip install pymouse
使用舉例:
from pymouse import PyMouse
m = PyMouse()
m.position() #獲取當前的滑鼠坐標
m.move(x,y)
m.click(x,y) #模擬點擊
m.press(x,y) #按下滑鼠
m.release(x,y) #釋放滑鼠
熱點內容