how to automate a mouse click in python -


i know how write program click on button on website page have not created.

i keen noob python can program extent in lb need know native python commands getting to/opening web page , locating buttons on page , automatically left clicking them.

in python 2 or 3 version please

use webbrowser.open() open website:

>>> import webbrowser >>> webbrowser.open('www.google.com') #opens www.google.com true >>>  

then use following code click: (this works on python2.6 on osx)

import time quartz.coregraphics import cgeventcreatemouseevent quartz.coregraphics import cgeventpost quartz.coregraphics import kcgeventmousemoved quartz.coregraphics import kcgeventleftmousedown quartz.coregraphics import kcgeventleftmousedown quartz.coregraphics import kcgeventleftmouseup quartz.coregraphics import kcgmousebuttonleft quartz.coregraphics import kcghideventtap def mouseevent(type, posx, posy):         theevent = cgeventcreatemouseevent(none, type, (posx,posy), kcgmousebuttonleft)         cgeventpost(kcghideventtap, theevent)  def mousemove(posx,posy):         mouseevent(kcgeventmousemoved, posx,posy);  def mouseclick(posx,posy):         #mouseevent(kcgeventmousemoved, posx,posy); #uncomment line if want force mouse move click location first (i found not necesary).         mouseevent(kcgeventleftmousedown, posx,posy);         mouseevent(kcgeventleftmouseup, posx,posy);  mouseclick(100, 100) #clicks on coordinate (100, 100) 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -