|
-
September 2nd, 2009, 11:07 AM
#1
Problem with hotkey binds
Hello out there :-)
I am making a macro program, which should write a text when i click on a specify key on keyboard. I use F keys from F1 to F10 and my program works fine...
The only problem i get is that the F1 key call the Help-box and F2 call the Find-box e.g. but i wanted to know, if its possible on a easy way that would disable them, and only react on send text i wan't without calling these...
I use GetAsyncKeystate Function with Boolean.
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
and my F1 key (Timer Tick) look like this:
Code:
Private Sub bindf1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bindf1.Tick
Dim bindf1 As Boolean
bindf1 = GetAsyncKeyState(Keys.F1)
If bindf1 = True Then
SendKeys.Send(F1_txt.Text)
SendKeys.Send("{Enter}")
End If
End Sub
It works great, but the only problem is it calls the HELP-box which i don't want...
Thank you :-)
-
September 3rd, 2009, 01:12 AM
#2
Re: Problem with hotkey binds
I sat with a similar situation quite recently. There is no way to disable the built in functionality of a certain Key like F1 in a program, so however you manage to press the key, it will always do what it was intended to do.
Or, so I thought 
Two APIs will be needed : UnregisterHotKey and RegisterHotKey. Once you have registered a certain Hotkey and override the WM_HOTKEY message; there you go! 
There is a component I use with success in cases like this, and you can find it here :
http://www.codeproject.com/KB/vb/mcl...px?msg=1808073
http://www.vbforums.com/showthread.php?t=249194
Just a note : If there is absolutely no other keys that you can actually use for this purpose, then doing this is fine, you'll just have to remember that the F keys have specific functions people are accustomed to - I'd actually say that you should rather choose different keys...
I hope my advice was helpful
-
September 3rd, 2009, 01:41 AM
#3
Re: Problem with hotkey binds
You know that's always going to bring a question down the line (a few months?) about Ctrl-Alt-Del...
Look up GINA (which controls special keys)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|