Nov 22, 2009

Programatically Holding Down Keys

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > C# .NET

Programatically Holding Down Keys

turbopowerdmaxsteel
I am working on some new interactivity effects for Pika Bot. These will allow Pika Bot to Hold Down/Release Keys. I know it has to be done using the Windows API but am at a loss when trying to figure out the SendInput function and its usage. Can anybody help me out on getting this done using C# or VB .NET?

Comment/Reply (w/o sign-up)

faulty.lee
I don't think SendInput will work. It's for sending keystrokes. I've look into
WM_KEYDOWN - http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx
and keybd_event of user32.dll - http://www.devx.com/vb2themax/Tip/19094

The 2nd example is for VB6, i believe it's not too hard to convert to vb.net. From there converting to c# is a lot easier.

WM_KEYDOWN will require you to use SendMessage or PostMessage API to send the key, read the MSDN doc for the details.

If you need to know p/invoke for any particular API, goto http://www.pinvoke.net/

They have the declaration for vb.net and c# there.


If the above don't works and you need a much lower level of sending keys, you might want to look into SetWindowsHookEx and WH_KEYBOARD_LL. These are for hooking up low level key press like alt+ctrl+del where you can never receive such event from the system in your normal app. From there, you can know how the message system works, and how to emulate ones

Let me know if you need more help, I can free sometime to try out some code later

Good Luck

 

 

 


Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Programatically Holding Keys


    Looking for programatically, holding, keys

See Also,

*SIMILAR VIDEOS*
Searching Video's for programatically, holding, keys
advertisement



Programatically Holding Down Keys

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com