https://github.com/flipeador/python-interception-driver
Python 3 port of Interception Driver
https://github.com/flipeador/python-interception-driver
interception-driver python python3 windows
Last synced: 4 months ago
JSON representation
Python 3 port of Interception Driver
- Host: GitHub
- URL: https://github.com/flipeador/python-interception-driver
- Owner: flipeador
- Created: 2021-07-05T15:19:27.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-30T01:49:26.000Z (about 4 years ago)
- Last Synced: 2025-03-25T13:38:17.500Z (about 1 year ago)
- Topics: interception-driver, python, python3, windows
- Language: Python
- Homepage:
- Size: 37.1 KB
- Stars: 18
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python-Interception-Driver
http://www.oblita.com/interception
### Example:
```py
#from interception import Interception, MouseFilter, KeyFilter, MouseFlags,\
# MouseState, KeyState, MapVk, Vk, map_virtual_key
RUNNING = True
TIMEOUT = 2500 # ms
interception = Interception()
interception.set_mouse_filter(MouseFilter.ButtonAll)
interception.set_keyboard_filter(KeyFilter.All)
while RUNNING:
device = interception.wait_receive(TIMEOUT)
if device:
print(f'{device.get_hardware_id()}:')
# Mouse
if device.is_mouse:
print('MouseStroke(flags={1},state={2},rolling={0.rolling},x={0.x},y={0.y},info={0.info})'
.format(device.stroke, MouseFlags(device.stroke.flags).name, MouseState(device.stroke.state).name))
# Keyboard
elif device.is_keyboard:
vk = map_virtual_key(device.stroke.code, MapVk.ScToVk)
print('KeyStroke(sc={0.code:03X},vk={2:03X},state={1},info={0.info})'
.format(device.stroke, KeyState(device.stroke.state).name, vk))
# escape = terminate
if vk == Vk.Escape:
RUNNING = False
# switch x and y
elif vk == Vk.X:
device.stroke.code = map_virtual_key(Vk.Y, MapVk.VkToSc)
elif vk == Vk.Y:
device.stroke.code = map_virtual_key(Vk.X, MapVk.VkToSc)
device.send()
print('-'*100)
```