Friday 15 June 2012

python - Using pyHook to get mouse coordinates to play back later -


I have a code to get using pyHook to mouse clicks and then win32api reached a click function I'm writing part. Basically I'm trying to record a format of clicks to use the mouse which will be recorded and played later.

This is my current code:

  import win32api, win32con, time, win32ui, pyHook, pythoncom click def during #define win32api (x, y): Win32api.SetCursorPos ((X, Y)) win32api.mouse_event (win32con.MOUSEEVENTF_LEFTDOWN, X, Y, 0,0) win32api. pythoncom mouse_event (win32con.MOUSEEVENTF_LEFTUP, x, y, 0,0) def onclick (event): Click () to print event.Position return true HM = pyHook.HookManager () hm.SubscribeMouseAllButtonsDown (click) HmkHookMouse () .PumpMessages () Hm.UnhookMouse ()   

I'm sure some stupid simple

Also here is the debug run: < pre> traceback (most recent call last): file "C: \ Python 27 \ BB \ site-packages \ pyHook \ HookManager.py: Post", line 325, MouseSwitch return function (event) typos Click () Astw 2 arguments (given 1) in

hm. Subscribe toMillownloaddown (click) - & gt; hm.SubscribeMouseAllButtonsDown (onclick)

Removed click () onclick calls. Win32api.SetCursorPos ((X, Y)) win32api.mouse_event (win32con.mouSEEVENTF_LEFTDOWN, X): Win32api, win32con, time, win32ui, pyHook, pythoncom def (default) , Y, 0,0) win32api Mouse_event (win32con.MOUSEEVENTF_LEFTUP, X, Y, 0,0) DEF onclick (event): print event.Position return true hm = pyHook.HookManager (hm.SubscribeMouseAllButtonsDown (onclick) hm.HookMouse () pythoncom.PumpMessages () HM .UnhookMouse ()

No comments:

Post a Comment