Best Python code snippet using fMBT_python
driver.py
Source:driver.py
...34def MouseInput(flags, x, y, data):35 return MOUSEINPUT(x, y, data, flags, 0, None)36def KeybdInput(code, flags):37 return KEYBDINPUT(code, code, flags, 0, None)38def HardwareInput(message, parameter):39 return HARDWAREINPUT(message & 0xFFFFFFFF, parameter & 0xFFFF, parameter >> 16 & 0xFFFF)40def Input(structure):41 global INPUT_MOUSE, INPUT_KEYBOARD, INPUT_HARDWARE42 if isinstance(structure, MOUSEINPUT):43 return INPUT(INPUT_MOUSE, _INPUTunion(mi=structure))44 if isinstance(structure, KEYBDINPUT):45 return INPUT(INPUT_KEYBOARD, _INPUTunion(ki=structure))46 if isinstance(structure, HARDWAREINPUT):47 return INPUT(INPUT_HARDWARE, _INPUTunion(hi=structure))48 raise TypeError('Cannot create INPUT structure!')49def Mouse(flags, x=0, y=0, data=0):50 return Input(MouseInput(flags, x, y, data))51def Keyboard(code, flags=0):52 return Input(KeybdInput(code, flags))53def Hardware(message, parameter=0):54 return Input(HardwareInput(message, parameter))55def SendInput(*inputs):56 nInputs = len(inputs)57 LPINPUT = INPUT * nInputs58 pInputs = LPINPUT(*inputs)59 cbSize = ctypes.c_int(ctypes.sizeof(INPUT))...
structs.py
Source:structs.py
1from ctypes import *2# The field 'dwExtraInfo' isn't properly defined in any of these structs3class MOUSEINPUT(Structure):4 _fields_ = [('dx', c_int),5 ('dy', c_int),6 ('mouseData', c_uint),7 ('dwFlags', c_uint),8 ('time', c_uint),9 ('dwExtraInfo', c_uint)]10class KEYBDINPUT(Structure):11 _fields_ = [('wVk', c_ushort),12 ('wScan', c_uint),13 ('dwFlags', c_uint),14 ('time', c_uint),15 ('dwExtraInfo', c_uint)]16class HARDWAREINPUT(Structure):17 _fields_ = [('uMsg', c_uint),18 ('wParamL', c_ushort),19 ('wParamH', c_ushort)]20class DEVICEINPUT(Union):21 _fields_ = [('mi', MOUSEINPUT),22 ('ki', KEYBDINPUT),23 ('hi', HARDWAREINPUT)]24class INPUT(Structure):25 _fields_ = [('type', c_int),26 ('i', DEVICEINPUT)]27 _anonymous_ = ('i')28 29 MOUSE = 030 KEYBOARD = 131 HARDWARE = 232if __name__ == '__main__':33 print 'struct INPUT: (size=', sizeof(INPUT), ')'34 for field in dir(INPUT):35 if not str(field).startswith('_'):36 print '\t', str(field), '\t', getattr(INPUT, str(field))37 print38 39 print 'struct MOUSEINPUT: (size=', sizeof(MOUSEINPUT), ')'40 for field in dir(MOUSEINPUT):41 if not str(field).startswith('_'):42 print '\t', str(field), '\t', getattr(MOUSEINPUT, str(field))43 print44 45 print 'struct KEYBDINPUT: (size=', sizeof(KEYBDINPUT), ')'46 for field in dir(KEYBDINPUT):47 if not str(field).startswith('_'):48 print '\t', str(field), '\t', getattr(KEYBDINPUT, str(field))49 print50 51 print 'struct HARDWAREINPUT: (size=', sizeof(HARDWAREINPUT), ')'52 for field in dir(HARDWAREINPUT):53 if not str(field).startswith('_'):54 print '\t', str(field), '\t', getattr(HARDWAREINPUT, str(field))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!