| View previous topic :: View next topic |
| Author |
Message |
Rur3k Expert Cheater
Reputation: 0
Joined: 19 Aug 2008 Posts: 235 Location: HaHaVille Maryland
|
Posted: Tue Oct 21, 2008 8:04 pm Post subject: [QUESTION]VB2008 express hotkeys |
|
|
So in Vb2008 how would you set it so when you press (F12) it enabled a timer... like so?
| Code: | Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetKeyPress(A) Then
Spammer.Enabled = True
End If
End Sub |
One of my timers is named Spammer.
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Oct 21, 2008 8:06 pm Post subject: |
|
|
Register/UnregisterHotkey
or
GetAsyncKeyState assuming you want a global hotkey.
Otherwise, just override WndProc and respond to the WM_KEYDOWN message.
|
|
| Back to top |
|
 |
Rur3k Expert Cheater
Reputation: 0
Joined: 19 Aug 2008 Posts: 235 Location: HaHaVille Maryland
|
Posted: Tue Oct 21, 2008 8:09 pm Post subject: |
|
|
| slovach wrote: | Register/UnregisterHotkey
or
GetAsyncKeyState assuming you want a global hotkey.
Otherwise, just override WndProc and respond to the WM_KEYDOWN message. |
huh? could you fix my code...?
_________________
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Tue Oct 21, 2008 9:06 pm Post subject: |
|
|
| Code: | Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetASyncKeyState(VK_A) Then
Spammer.Enabled = True
End If
End Sub |
_________________
|
|
| Back to top |
|
 |
Rur3k Expert Cheater
Reputation: 0
Joined: 19 Aug 2008 Posts: 235 Location: HaHaVille Maryland
|
Posted: Tue Oct 21, 2008 9:44 pm Post subject: |
|
|
| Snootae wrote: | | Code: | Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetASyncKeyState(VK_A) Then
Spammer.Enabled = True
End If
End Sub |
|
thanks! but it says GetASyncKeyState(VK_A) is undeclarable. And get build fail.
_________________
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Tue Oct 21, 2008 9:47 pm Post subject: |
|
|
| Code: | | Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer |
_________________
|
|
| Back to top |
|
 |
Rur3k Expert Cheater
Reputation: 0
Joined: 19 Aug 2008 Posts: 235 Location: HaHaVille Maryland
|
Posted: Tue Oct 21, 2008 10:01 pm Post subject: |
|
|
| Snootae wrote: | | Code: | | Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer |
|
I think it is this then... | Code: | Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetAsyncKeyState(vKey:=1) Then
Spammer.Enabled = True
End If
End Sub |
If I dont do(vKey:=1) it will auto fail my build success. ;(
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Oct 21, 2008 10:14 pm Post subject: |
|
|
Isn't := the pascal assignment operator?
You'll need to use: | Code: | | Imports System.Runtime.InteropServices | to make use of the Win32 API.
| Code: | <DllImport("user32.dll")> _
Public Shared Function GetAsyncKeyState(ByVal vKey As Int32) As Short
End Function |
Pinvoke signature. NOW you can call it.
You can use the Keys class to get the virtual keys, or define them yourself.
| Code: | | if GetAsyncKeyState(Keys.A) | Is already the equivalent of asking if it's true.
Look at MSDN and pinvoke.net. Take a good look at the name of it though. Guess what you're going to have to do?
Hint: call it over, and over to do your checks.
|
|
| Back to top |
|
 |
|