Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,458 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,861 people online right now. Registration is fast and FREE... Join Now!




Count Down Timer

 
Reply to this topicStart new topic

Count Down Timer, Need Timer that counts 10 to 0

koolazngy94
29 Jul, 2008 - 10:53 AM
Post #1

New D.I.C Head
*

Joined: 29 Jul, 2008
Posts: 22

Hi, Im making an Auto-Clicker. What I have so far is a Button, timer, and a Text. It works but what I want to add another textbox so in that text box, i put the number 10 then i click the button and it will countdown the timer then when it reaches 0, it will stop clicking. Sorry, bad english any help?

Source:
CODE
Private Sub Command1_Click()
    If Command1.Caption = "Start" Then
        Timer1.Enabled = True
        Command1.Caption = "Stop"
        Text1.Enabled = False
    Else
        Timer1.Enabled = False
        Command1.Caption = "Start"
        Text1.Enabled = True
    End If
End Sub




Private Sub Form_Load()

End Sub

Private Sub Label4_Click()

End Sub

Private Sub Text1_Change()
If Val(Text1.Text) < 0.0001 Then
        Text1.Text = ""
    End If
    Timer1.Interval = Val(Text1.Text) * 1000
End Sub

Private Sub Timer1_Timer()
  LeftClick
End Sub


Private Sub txtSec_Change()

End Sub


Moncular
CODE
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Public Const MOUSEEVENTF_LEFTDOWN = &H2
    Public Const MOUSEEVENTF_LEFTUP = &H4
    Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Public Const MOUSEEVENTF_MIDDLEUP = &H40
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8
    Public Const MOUSEEVENTF_RIGHTUP = &H10
    Public Const MOUSEEVENTF_MOVE = &H1
Public Type POINTAPI
    X As Long
    Y As Long
    End Type
Public Function GetX() As Long
    Dim n As POINTAPI
    GetCursorPos n
    GetX = n.X
End Function
Public Function GetY() As Long
    Dim n As POINTAPI
    GetCursorPos n
    GetY = n.Y
End Function
Public Sub LeftClick()
    LeftDown
    LeftUp
End Sub
Public Sub LeftDown()
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
End Sub
Public Sub LeftUp()
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Public Sub MiddleClick()
    MiddleDown
    MiddleUp
End Sub
Public Sub MiddleDown()
    mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
End Sub
Public Sub MiddleUp()
    mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
End Sub
Public Sub RightClick()
    RightDown
    RightUp
End Sub
Public Sub RightDown()
    mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
End Sub
Public Sub RightUp()
    mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub
Public Sub MoveMouse(xMove As Long, yMove As Long)
    mouse_event MOUSEEVENTF_MOVE, xMove, yMove, 0, 0
End Sub
Public Sub SetMousePos(xPos As Long, yPos As Long)
    SetCursorPos xPos, yPos
End Sub

User is offlineProfile CardPM
+Quote Post

Zhalix
RE: Count Down Timer
29 Jul, 2008 - 11:19 AM
Post #2

D.I.C Head
**

Joined: 7 May, 2008
Posts: 218



Thanked: 9 times
My Contributions
Well, are you going to use another timer to countdown, or use the same timer for counting as the one that's doing the clicking?

Make an integer variable at the top of your code. Then, when the person clicks the "Start" button, set the integer's value to whatever is in the textbox, and then start the timer. In the timer, have it minus one from the number every time it ticks. When it reaches zero, have it stop/start or whatever this is for.
User is offlineProfile CardPM
+Quote Post

koolazngy94
RE: Count Down Timer
29 Jul, 2008 - 12:51 PM
Post #3

New D.I.C Head
*

Joined: 29 Jul, 2008
Posts: 22

well idk but here the img
IPB Image


U see the number of clicks? That wat im trying to do. When they click start it will start clicking and will start the timer.

---EDIT---
either get the countdown or the hotkey. If you know how to add the hotkey please tell me or give me the code. I need F2 to start and F1 to stop.

This post has been edited by koolazngy94: 29 Jul, 2008 - 12:56 PM
User is offlineProfile CardPM
+Quote Post

koolazngy94
RE: Count Down Timer
29 Jul, 2008 - 01:11 PM
Post #4

New D.I.C Head
*

Joined: 29 Jul, 2008
Posts: 22

QUOTE(koolazngy94 @ 29 Jul, 2008 - 01:51 PM) *

well idk but here the img
IPB Image


U see the number of clicks? That wat im trying to do. When they click start it will start clicking and will start the timer.

---EDIT---
either get the countdown or the hotkey. If you know how to add the hotkey please tell me or give me the code. I need F2 to start and F1 to stop.


---EDIT---
nvm got the F1 to stop and F2 to start but one problem.. How do I click F2 outside of the program n it will start?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:50PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month