I'm trying to use pyhooks to detect mouse clicks anywhere on screen. The problem is that I can only get it to work with PumpMessages(). I'd like it operate inside of a while loop that I've constructed. Is there a way to accomplish this/why does it need pumpMessages?
def onclick(event):
print 'Mouse click!'
return True
hm = pyHook.HookManager()
hm.MouseLeftDown = onclick
hm.HookMouse()
pythoncom.PumpMessages()
hm.UnhookMouse()
The above is the only way I can get it to run.
I'm trying to accomplish something like this:
sTime = time.time()
def onclick(event):
global sTime
print 'Time between clicks equals: %i' % time.time() - stime
sTime = time.time()
return True
hm.MouseLeftDown = OnClick
while True:
hm.HookMouse()
EDIT: I am not a smart man. There is no need for a while loop in the scenario..
Sigh..