Home  |  Programs  |  Tips & Tricks  |  Subs & Functions  |  Links  |  Laz's Liberty Basic Site


Simulate a key press

'SIMULATE A KEYPRESS
'FOR LB3.x
'BY ~laz

'A complete list of Virtual-Key Codes can be found in Alyce Watson's LB Workshop.
'SUB USAGE:
'CALL PressKey value
'value must be a number between 1 and 254 decimal
'representing a hexdecimal value for the virtual key code
'or a virtual key code example: _VK_H = 72


DIM Key(5)
Key(1) = 72 'H
Key(2) = 69 'E
Key(3) = 76 'L
Key(4) = 76 'L
Key(5) = 79 'O


for x = 1 to 5
call PressKey Key(x)
next x

wait

sub PressKey vKey
'simulate pressing the key down
calldll #user32, "keybd_event", _
vKey as long, _ 'the key to press
null as long, _ 'not used
0 as long, _ '0 = key down
ret as void

'simulate releasing the key
calldll #user32, "keybd_event", _
vKey as long, _
null as long, _
2 as long, _ '2 = key up
ret as void
end sub

Hosted by www.Geocities.ws

1