Teamplayer and pyhook interact weirdly

I use teamplayer , which allows you to connect more mice to your computer for simultaneous use. I also use pyHook to capture mouse events with the following code:

import pyHook
import pythoncom

def onclick(event):
  # called when mouse events are received
  print 'MessageName:',event.MessageName
  print 'Message:',event.Message
  print 'Time:',event.Time
  print 'WindowName:',event.WindowName
  print 'Position:',event.Position
  print '---'
  return True

hm = pyHook.HookManager()
hm.MouseLeftDown = onclick
hm.MouseLeftUp = onclick
hm.HookMouse()
pythoncom.PumpMessages()

The code works fine without teamplayer - it accurately and accurately defines the mouse button. If I run the command player while the program is running, it continues to work well, this time accurately detecting clicks from both mice.

However, if I run the program after starting Teamplayer, then each mouseclick will become double:

MessageName: mouse left down
Message: 513
Time: 7231317
WindowName: None
Position: (673, 367)
---
MessageName: mouse left down
Message: 513
Time: 7231317
WindowName: None
Position: (673, 367)
---
MessageName: mouse left up
Message: 514
Time: 7231379
WindowName: None
Position: (673, 367)
---
MessageName: mouse left up
Message: 514
Time: 7231379
WindowName: None
Position: (673, 367)

That would be normal - I could detect clicks with the same timestamp and ignore the second. However, when I click on another mouse, the picture is strange:

MessageName: mouse left down
Message: 513
Time: 7305916
WindowName: C:\Python25\python.exe
Position: (569, 306)
---
MessageName: mouse left down
Message: 513
Time: 7305916
WindowName: C:\Python25\python.exe
Position: (722, 365)
---
MessageName: mouse left up
Message: 514
Time: 7309598
WindowName: C:\Python25\python.exe
Position: (722, 365)
---
MessageName: mouse left up
Message: 514
Time: 7309598
WindowName: C:\Python25\python.exe
Position: (722, 365)

, up! , , ( " ", teamplayer , ! )

, , , ?

+3
1

:

  • . , , ...
  • pyhook ; , . , HookManager MouseSwitch . , , , , pyhook
  • , API SetWindowsHookEx - , ; teamplayer - . teamplayer; - .
+1

Source: https://habr.com/ru/post/1757051/


All Articles