windows 7 - How to detect mouse click in python 3.6.1 -
so making program (just fun) plays sound when click mouse, problem don't know how detect mouse clicks... there many questions answers topic reason doesent work me. eithere because suggest pygame or tkinter wich uses box user need click in box activate sound, suggest outdated modules, suggest modules reason impossible using internet , or pip install or script don't work. date way (wich doesent require user click in box pygame etc) detect mouse clicks? (btw, use windows 7)
the way detect mouse events outside program install windows hook using setwindowshookex. pyhook module encapsulates nitty-gritty details.
import pyhook import pythoncom def onclick(event): print event.position return true hm = pyhook.hookmanager() hm.subscribemouseallbuttonsdown(onclick) hm.hookmouse() pythoncom.pumpmessages() hm.unhookmouse()
pyhook might tricky use in pure python script, because requires active message pump
Comments
Post a Comment