Microsoft Visual Basic(whats wrong with this??)

Posts 1–15 of 21 · Page 1 of 2
Microsoft Visual Basic(whats wrong with this??)
Code:
    Private Sub Hotkey_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hotkey.Tick
        Dim Hotkey As Boolean
        Hotkey = GetAsyncKeyState(Keys.F)
        If Hotkey = True Then
            SendKeys.Send(3)
            SendKeys.Send(0)
        End If
    End Sub
End Class
everytime i do this i get the error PInvokeStackImbalance.
Anyone know what I did wrong??
Use this instead:

SendKeys.Send("3")
SendKeys.Send("0")

/Moved to VB
Quote Originally Posted by Zoom View Post
Use this instead:

SendKeys.Send("3")
SendKeys.Send("0")

/Moved to VB
Didnt work, its something to do with
Hotkey = GetAsyncKeyState(Keys.F)
What is your timer interval at? Set it to 1.

Try defining the hotkey as global. Sometimes it helps.


EDIT: You did start the timer didn't you?
Quote Originally Posted by Shark23 View Post
What is your timer interval at? Set it to 1.

Try defining the hotkey as global. Sometimes it helps.


EDIT: You did start the timer didn't you?
Yeah, It set at 1, dunno whats wrong and it is started.
Change your GetAsyncKeyState declaration to this

[php]
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vkey As Long) As UShort
[/php]

And your code to this (not much changed, but for the sake of a control, here:

[php]
Private Sub Hotkey_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hotkey.Tick

Dim Hotkey As Boolean = GetAsyncKeyState(Keys.F)

If Hotkey = True Then

SendKeys.Send("3")
SendKeys.Send("0")

End If

End Sub
[/php]

Let me know if that helps.
Are you trying to make it work in-game? If so then it won't work.
Quote Originally Posted by Shark23 View Post
Are you trying to make it work in-game? If so then it won't work.
See the first post, he's getting an error. Not that it's just not sending.
If you still get the error, please take a printscreen and post it here.
J-deezy, didnt work agian here is the ss:
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vkey As int16) As int32
Quote Originally Posted by Blubb1337 View Post
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vkey As int16) As int32
Woah Ty, it worked!
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer

Dim Hotkey As Boolean
Hotkey = GetAsyncKeyState(Keys.3)
Pleasure, it is x64 bit related :]

My code will work on both, x64/x32.
Now, how do it get it to work ingame :I
Posts 1–15 of 21 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?