Answered by:
Timer/Clicker

Question
-
Ok, so how do you create clicker? Like click("keyboard,"k""); or something
And how do I create a timer: click("keyboard,"k"");
settimer(5000);
new onendtimer();
click("keyboard,"j"");
I don't have the slightest idea how so you see I'm using TS-like functions in my example.
Sunday, September 12, 2010 12:15 PM
Answers
-
Hello YuriKahn,
Example 1:
Create a Button1 (Start), a Button2 (Stop) and a Timer1. Then use this code:
Option Strict On Public Class Form1 Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Int32, ByVal bScan As Int32, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) Private Const KEYEVENTF_KEYUP As Integer = &H2 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Interval = 5000 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick keybd_event(Keys.K, 0, 0, 0) keybd_event(Keys.K, 0, KEYEVENTF_KEYUP, 0) End Sub End Class
To start the program click Button1. This program will send key "K" every 5 seconds. You can stop the program by clicking the Button2.
Example 2:
Create a Button1 (Start), a Button2 (Stop) and a Timer1. Then use this code:
Option Strict On Public Class Form1 Dim x As Integer = 0 Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Int32, ByVal bScan As Int32, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) Private Const KEYEVENTF_KEYUP As Integer = &H2 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Interval = 1000 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick x += 1 If x <= 5 Then keybd_event(Keys.K, 0, 0, 0) keybd_event(Keys.K, 0, KEYEVENTF_KEYUP, 0) Else keybd_event(Keys.J, 0, 0, 0) keybd_event(Keys.J, 0, KEYEVENTF_KEYUP, 0) End If End Sub End Class
To start the program click Button1. This program will send every second the key "K" (5 times) and after that will send every second the key "J". You can stop the program by clicking the Button2.
HrBill32- Proposed as answer by jammyatjammy Tuesday, September 14, 2010 9:32 PM
- Marked as answer by Chao KuoModerator Monday, September 20, 2010 6:25 AM
Tuesday, September 14, 2010 12:06 AM
All replies
-
Hey YuriKahn and welcome on this forum.
You can find a timer control on the left side of the IDE in the controls Window, if you select it there and double click or if you drag it to the form, you will have a timer on you forum (It's placed in an rectangle square on the bottom of your screen(underneath your form)) then double click on that timer and you get an TIMER.TICK event that fires every tick of the timer. With the interval function of the timer you can choose how fast the timer ticks.
Oh and you can start the timer with this code:
Timer1.enabled = true
Gr. Ryan.
The nerd way of life: Instead of learning for your exams, you should hack into the school's computer and get your answers, that's by far the best way to spend your time!:P- Edited by me.Ryan Tuesday, September 14, 2010 5:00 PM Not so nice thing
Sunday, September 12, 2010 6:10 PM -
Hello YuriKahn,
Example 1:
Create a Button1 (Start), a Button2 (Stop) and a Timer1. Then use this code:
Option Strict On Public Class Form1 Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Int32, ByVal bScan As Int32, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) Private Const KEYEVENTF_KEYUP As Integer = &H2 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Interval = 5000 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick keybd_event(Keys.K, 0, 0, 0) keybd_event(Keys.K, 0, KEYEVENTF_KEYUP, 0) End Sub End Class
To start the program click Button1. This program will send key "K" every 5 seconds. You can stop the program by clicking the Button2.
Example 2:
Create a Button1 (Start), a Button2 (Stop) and a Timer1. Then use this code:
Option Strict On Public Class Form1 Dim x As Integer = 0 Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Int32, ByVal bScan As Int32, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32) Private Const KEYEVENTF_KEYUP As Integer = &H2 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Interval = 1000 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick x += 1 If x <= 5 Then keybd_event(Keys.K, 0, 0, 0) keybd_event(Keys.K, 0, KEYEVENTF_KEYUP, 0) Else keybd_event(Keys.J, 0, 0, 0) keybd_event(Keys.J, 0, KEYEVENTF_KEYUP, 0) End If End Sub End Class
To start the program click Button1. This program will send every second the key "K" (5 times) and after that will send every second the key "J". You can stop the program by clicking the Button2.
HrBill32- Proposed as answer by jammyatjammy Tuesday, September 14, 2010 9:32 PM
- Marked as answer by Chao KuoModerator Monday, September 20, 2010 6:25 AM
Tuesday, September 14, 2010 12:06 AM