nisharg nargund
commited on
Commit
·
a2d1d1c
1
Parent(s):
e26001e
Delete keyinput.py
Browse files- keyinput.py +0 -51
keyinput.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
import ctypes
|
| 2 |
-
|
| 3 |
-
keys = {
|
| 4 |
-
"w":0x11,
|
| 5 |
-
"a":0x1E,
|
| 6 |
-
"s":0x1F,
|
| 7 |
-
"d":0x20,
|
| 8 |
-
}
|
| 9 |
-
PUL = ctypes.POINTER(ctypes.c_ulong)
|
| 10 |
-
class KeyBdInput(ctypes.Structure):
|
| 11 |
-
_fields_ = [("wVk", ctypes.c_ushort),
|
| 12 |
-
("wScan", ctypes.c_ushort),
|
| 13 |
-
("dwFlags", ctypes.c_ulong),
|
| 14 |
-
("time", ctypes.c_ulong),
|
| 15 |
-
("dwExtraInfo", PUL)]
|
| 16 |
-
|
| 17 |
-
class HardwareInput(ctypes.Structure):
|
| 18 |
-
_fields_ = [("uMsg", ctypes.c_ulong),
|
| 19 |
-
("wParamL", ctypes.c_short),
|
| 20 |
-
("wParamH", ctypes.c_ushort)]
|
| 21 |
-
|
| 22 |
-
class MouseInput(ctypes.Structure):
|
| 23 |
-
_fields_ = [("dx", ctypes.c_long),
|
| 24 |
-
("dy", ctypes.c_long),
|
| 25 |
-
("mouseData", ctypes.c_ulong),
|
| 26 |
-
("dwFlags", ctypes.c_ulong),
|
| 27 |
-
("time",ctypes.c_ulong),
|
| 28 |
-
("dwExtraInfo", PUL)]
|
| 29 |
-
|
| 30 |
-
class Input_I(ctypes.Union):
|
| 31 |
-
_fields_ = [("ki", KeyBdInput),
|
| 32 |
-
("mi", MouseInput),
|
| 33 |
-
("hi", HardwareInput)]
|
| 34 |
-
|
| 35 |
-
class Input(ctypes.Structure):
|
| 36 |
-
_fields_ = [("type", ctypes.c_ulong),
|
| 37 |
-
("ii", Input_I)]
|
| 38 |
-
|
| 39 |
-
def press_key(key):
|
| 40 |
-
extra = ctypes.c_ulong(0)
|
| 41 |
-
ii_ = Input_I()
|
| 42 |
-
ii_.ki = KeyBdInput( 0, keys[key], 0x0008, 0, ctypes.pointer(extra) )
|
| 43 |
-
x = Input( ctypes.c_ulong(1), ii_ )
|
| 44 |
-
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
|
| 45 |
-
|
| 46 |
-
def release_key(key):
|
| 47 |
-
extra = ctypes.c_ulong(0)
|
| 48 |
-
ii_ = Input_I()
|
| 49 |
-
ii_.ki = KeyBdInput( 0, keys[key], 0x0008 | 0x0002, 0, ctypes.pointer(extra) )
|
| 50 |
-
x = Input( ctypes.c_ulong(1), ii_ )
|
| 51 |
-
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|