HelpHotkeys

Posts 1–8 of 8 · Page 1 of 1
Hotkeys
Hey, i have a program with hotkeys, pretty basic global hotkeys(As in they work whether your application is focused or not, but i'd like to make it so the users can change their hotkeys to anything, or a ComboBox with a list of ones. Anyone know the simplest way of doing this while keeping them global, Thnx.

EDIT: i use GetAsyncKeyState, is there anywayi can use a textbox to define the keys, and i declared user32 as Short not as Integer, due to Windows7 Compatibility, but i tried

key = GetAsyncKeyState(CShort(TextBox5.Text))

That didn't work.
First of all, you need to use a keyboard hook.
If you need the source I'd be glad to PM it to you.
Second of all you can get the Key-Pressed when you click the textbox from the keyboard hook.

So when the click event is raised you enable the keyboard hook and it will return into that text box
That way it will return the raw code. (You can also make Show names or a Fixed name for them by using if statements.)
I'm confused. I want the hotkeys to work whether my application has focus or not.
Code:
Dim HKey as String = "F5"
Dim kV as new Keysconverter
Code:
If GetAsyncKeyState(kV.ConvertFromString(HKey)) Then
'tehe
End If
Yes it will work without focus, and you can choose to handle the keys or not aswell.
I just think it would be easier with a Keyboard hook class instead of having to do every key seperate.
Blubb, If i change the F5 part to Comx.Text then will it work?
Quote Originally Posted by dudezone2 View Post
Blubb, If i change the F5 part to Comx.Text then will it work?
Try it out?!
easiest way would be to use a comx, not a textbox. Change the "DropDownStyle" property to "DropDownList" so that users cant modify the items and then do this on Form_Load:

Code:
Me.ComboBox1.Items.AddRange(Enum.GetNames(GetType(Keys)))
Then to convert the selected item to something you can use with GetAsyncKeyState:
Code:
Dim selectedKey As Keys = CType(Enum.Parse(GetType(Keys), Me.Combobox1.SelectedItem.ToString()), Keys)
Dim asyncValue As Short = CType(selectedKey, Short)
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us