| View previous topic :: View next topic |
| Author |
Message |
haxor5354 Master Cheater
Reputation: 0
Joined: 11 Jan 2008 Posts: 306 Location: Toronto
|
Posted: Thu Jun 05, 2008 3:14 pm Post subject: [VB2008] how to use multiple hotkeys with code? |
|
|
| Code: | Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
Public Const WM_HOTKEY As Integer = &H312
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RegisterHotKey(Me.Handle.ToInt32, 0, 0, System.Windows.Forms.Keys.F11)'edit this for the hotkey you want
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
'code for if they press hotkey here
Else
End If
End If
MyBase.WndProc(m)
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
UnregisterHotKey(Me.Handle.ToInt32, 0)
End Sub |
I only can get 1 HotKey working, I tried lots of different thing but no luck =(
help plz? _________________
My Rig
MoBo: Asus P5QPL-AM
Cpu: Intel Core 2 Quad Q8200
Ram: Kingston 2x2GB DDR2 800
GFX: Asus ENGTS250 DK
HDD: 500GB WD Caviar Green
Mon: LG Flatron W2243T 1080p |
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Thu Jun 05, 2008 3:30 pm Post subject: |
|
|
Well, you add another RegisterHotkey after the one you have, and in you're messagehandler, add something like this:
| Code: |
If m.Msg = WM_HOTKEY Then
If m.wParam = KEY_IDENTIFIER_OF_KEY_1
'code for if they press hotkey1 here
Else If m.wParam = KEY_IDENTIFIER_OF_KEY_2
'code for if they press hotkey2 here
End If
End If
|
|
|
| Back to top |
|
 |
haxor5354 Master Cheater
Reputation: 0
Joined: 11 Jan 2008 Posts: 306 Location: Toronto
|
Posted: Thu Jun 05, 2008 3:35 pm Post subject: |
|
|
how to declare | Code: | | KEY_IDENTIFIER_OF_KEY_1 | and | Quote: | | KEY_IDENTIFIER_OF_KEY_2 |
_________________
My Rig
MoBo: Asus P5QPL-AM
Cpu: Intel Core 2 Quad Q8200
Ram: Kingston 2x2GB DDR2 800
GFX: Asus ENGTS250 DK
HDD: 500GB WD Caviar Green
Mon: LG Flatron W2243T 1080p |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Thu Jun 05, 2008 9:46 pm Post subject: |
|
|
Get a C# to VB.NET converter, and convert my static keyboard hook classes in the GP+ section, then add those to your project. _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Jun 06, 2008 12:15 am Post subject: |
|
|
| haxor5354 wrote: | how to declare | Code: | | KEY_IDENTIFIER_OF_KEY_1 | and | Quote: | | KEY_IDENTIFIER_OF_KEY_2 |
|
You don't, its the ID of the key. (ID parameter, RegisterHotKey...) |
|
| Back to top |
|
 |
|