Keyboard Button Press

BlitzPlus Forums/BlitzPlus Programming/Keyboard Button Press

Petron(Posted 2007) [#1]
I need a way to make keys virtually pressed. Such as this mouse simulator. http://www.blitzbasic.com/codearcs/codearcs.php?code=1943

I need to be able to have keys held down and pressed at the same time to use functions like Alt-Tab. I want to make it so that one button can do the work of two.

Thank You


b32(Posted 2007) [#2]
There is a command called 'keybd_event' or 'api_keybd_event' in the user32.decls
I suppose you could use that. To see an example of it's usage, check this post:
http://www.blitzbasic.com/Community/posts.php?topic=53344


Petron(Posted 2007) [#3]
That works, but the scan codes seem odd, is there any more explanation of where the scan codes go to make it press the key that you want.


b32(Posted 2007) [#4]
What do you mean exactly ? I think it is best to use the first parameter, the 'virtual key code'
You can find information about this command in the msdn:
http://msdn2.microsoft.com/en-us/library/ms646304.aspx
There is also a list of all the keycodes.

You might wanna be cautious when using this command. The first time I used it, I passed all 255 keycodes to it because I was frustrated it didn't do anything.. That was a bad idea .. all sorts of keys were pressed (including the DEL key) and Windows logged out.. Luckily nothing was deleted.


Petron(Posted 2007) [#5]
thanks