Saturday, January 16, 2010

Vb.net using control key instead of ascii code.?

this is the line that registers a hotkey based on the key in a text box.





RegisterHotKey(Me.Handle, 6, ControlKey Or AltKey Or ShiftKey, Asc(txtApp3Key.Text.ToUpper))





I want to replace (txtApp3Key.Text.ToUpper) with the control key. The control key does not have an ascii value so i am not sure how to do this.Vb.net using control key instead of ascii code.?
I'm a vb.net novice, but maybe you want to use the Control.Modifierkeys property? It's a boolean value that shows whether the key is being pressed or not.





Used as a variable, it is something like:


Dim ControlPressed As Boolean = (Control.ModifierKeys And Keys.Control) %26lt;%26gt; 0Vb.net using control key instead of ascii code.?
I don't believe you can register just the Control key as a hot key. The RegisterHotKey function creates a hot key which raises an event that your program can then process. You can stipulate that the Control key (or the Alt key or the Shift key, or any combination of them) be pressed along with the specified ASCII key, but not by itself.





If you need to detect when just the Control key is pressed, use the My.Computer.Keyboard. CtrlKeyDown property (see source link below).

No comments:

Post a Comment