[HELP]Whats wrong with this?

Posts 1–15 of 31 · Page 1 of 3
[HELP]Whats wrong with this?
Yes its me, Golden. the noob back with another question

Whats wrong with this code?
Code:
Public Class Form1
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If GetAsyncKeyState(Keys.F5) Then
            Timer1.Enabled = True
        ElseIf GetAsyncKeyState(Keys.F6) Then
            Timer1.Enabled = False
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If GetAsyncKeyState(Keys.F5) Then
            Timer1.Enabled = True
        ElseIf GetAsyncKeyState(Keys.F6) Then
            Timer1.Enabled = False
        End If
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        If Timer1.Enabled = True Then
            Label1.Text = "AFK BOT ENABLED, PRESS F6 TO DISABLE!"
            Label1.ForeColor = Color.Green
        ElseIf Timer1.Enabled = False Then
            Label1.Text = "AFK BOT DISABLED, PRESS F5 TO ENABLE!"
            Label1.ForeColor = Color.Red

        End If
    End Sub
End Class
Logic... as soon as you stop the timer you cant get it to work again... <.< and why the hell you have the key check on form load? no reason...

Your timer will only start when you press the key, which is being checked if pressed on the timer it self... So... you see whats the problem there? (and why a label click?)
Quote Originally Posted by 'Bruno View Post
Logic... as soon as you stop the timer you cant get it to work again... <.< and why the hell you have the key check on form load? no reason...

Your timer will only start when you press the key, which is being checked if pressed on the timer it self... So... you see whats the problem there? (and why a label click?)
As Brinuz said, logic is the main fault here, specifically:

[php]
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If GetAsyncKeyState(Keys.F5) Then
Timer1.Enabled = True
ElseIf GetAsyncKeyState(Keys.F6) Then
Timer1.Enabled = False
End If
End Sub
[/php]

Once you've pressed F6 this timer is no longer active and therefore any code contained within it is null and void.

Create a new timer specifically for hotkeys.

i.e

[php]
Private Sub Hotkeys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hotkeys.Tick
dim Start as boolean = GetAsyncKeyState(Keys.F5)
dim Stop as Boolean = GetAsyncKeyState(Keys.F6)


If Start Then
Timer1.Enabled = True
ElseIf Stop Then
Timer1.Enabled = False
End If

End Sub
[/php]

Something like that
Quote Originally Posted by 'Bruno View Post
Logic... as soon as you stop the timer you cant get it to work again... <.< and why the hell you have the key check on form load? no reason...

Your timer will only start when you press the key, which is being checked if pressed on the timer it self... So... you see whats the problem there? (and why a label click?)
haha i was going to help but you got this good job =p
also i lol! so hard when i seen the hotkey in the load event
the way i do my hotkeys is set the timer to 50 interval

edit:
Ok, Techial helped me out over teamviewer :P
Another noob question ( i havent used VB in a month... ) whats the word for space
Because
SendKeys.Send("{Space}") is wrong.?
Quote Originally Posted by Golden. View Post
Ok, Techial helped me out over teamviewer :P
Another noob question ( i havent used VB in a month... ) whats the word for space
Because
SendKeys.Send("{Space}") is wrong.?
Code:
SendKeys.Send(" ")
Lol no,That prints ' Space ' as text
I Want it to press spacebar xD
Quote Originally Posted by Golden. View Post
Lol no,That prints ' Space ' as text
I Want it to press spacebar xD
Facepalm. No it just creates a space ' ' (Actually pressing the space key, not printing space).
Ahh
But i want it to press Space key
i understand what you are saying
But this is an Afk bot, so by pressing space it will jump :3
Quote Originally Posted by Golden. View Post
Ahh
But i want it to press Space key
i understand what you are saying
But this is an Afk bot, so by pressing space it will jump :3
[php]
Public Declare Function keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) As Long

Const KEYEVENTF_KEYUP = &H2
[/php]

[php]

Public Sub PressKey (ByVal tehkey as Keys)

keybd_event(tehkey, 0, 0, 0)
keybd_event(tehkey, 0, KEYEVENTF_KEYUP, 0)

End Sub

[/php]

[php]
PressKey(Keys.Space)
[/php]

There you go, completely noob proof.
Kinda the same... :

[php]#Region "Press Key"

Declare Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

Private Sub pk(ByVal vk As Int32) 'press key
keybd_event(vk, 0&, 0&, 0&)
keybd_event(vk, 0&, KEYEVENTF_KEYUP, 0&)
End Sub

#End Region
[/php]

[php]pk(keys.f5)[/php]

http://www.mpgh.net/forum/33-visual-...ot-code-s.html
Quote Originally Posted by Blubb1337 View Post
Kinda the same... :

[php]#Region "Press Key"

Declare Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

Private Sub pk(ByVal vk As Int32) 'press key
keybd_event(vk, 0&, 0&, 0&)
keybd_event(vk, 0&, KEYEVENTF_KEYUP, 0&)
End Sub

#End Region
[/php]

[php]pk(keys.f5)[/php]

http://www.mpgh.net/forum/33-visual-...ot-code-s.html
Repeated post is repeated, nice one Kevin
J-Deezy Solved it.
Thanks man
~ Close please.
I am just pointing out that this has just been posted a day ago. With a little bit of researching(Search Function) he could have found it.

+ we have a sticky about that.

= Copy Cat11!111eleven!11one!!
Quote Originally Posted by Blubb1337 View Post
I am just pointing out that this has just been posted a day ago. With a little bit of researching(Search Function) he could have found it.

+ we have a sticky about that.

= Copy Cat11!111eleven!11one!!
/me = original + sexy

= C+P nub.

Posts 1–15 of 31 · Page 1 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us