Sign in to follow this  
Followers 0
AlmarM

Timer ?

14 posts in this topic

Can someone help me with a timer that counts the time when u pressed for example the start button ??

And it will stop when you press for example the last button ??


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



Can someone help me with a timer that counts the time when u pressed for example the start button ??

And it will stop when you press for example the last button ??

Searching in the help file for time related functions might help. For instance, _NowCalc() and _DateDiff() can be used to record the time at time of button presses in variables and calculate difference between them.

With functions like TimerInit() and TimerDiff() you can even do it with stopwatch accuracy.

Good luck! If you get stuck anywhere, be sure to post example code that shows what's the matter.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

can be used to record the time at time of button presses in

I mean the Start button is a GuiCtrlCreateButton()


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

And I dont get the _NowCalc() and the other stuff... Its a little too hard for me :)

Can you give me a hand please :) ??


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Aha... I tested it (the script from the help file) and Im getting some ideas... But how can I activate the "Timer" when I pressed GuiCtrlCreateButton("Start") and stop it with again the GuiCtrlCreateButton("End") ??

(I know GuiCtrlCreateButton("Start/Stop") needs more as only Start or Stop)


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

And whats wrong with:

#include <GuiConstants.au3>

GuiCreate("Test", 400, 400)
$Start_Button = GuiCtrlCreateButton("Start", 100, 100, 50, 50)
$Stop_Button = GuiCtrlCreateButton("Stop", 250, 250, 50, 50) 

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
    Exit

Case $msg = $Start_Button
    $begin = TimerInit()

Case $msg = $Stop_Button
    $dif = TimerDiff($begin)
    MsgBox(0, "Your Time:", "Your Time Is:" & $dif)
EndSelect
WEnd

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

I now got:

#include <GuiConstants.au3>

GuiCreate("Test", 400, 400)
GuiSetState(@SW_SHOW)
$Start_Button = GuiCtrlCreateButton("Start", 100, 100, 50, 50)
$Stop_Button = GuiCtrlCreateButton("Stop", 250, 250, 50, 50) 

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
    Exit

Case $msg = $Start_Button
    $begin = TimerInit()

Case $msg = $Stop_Button
    $dif = TimerDiff($begin)
    MsgBox(0, "Your Time: ", "Your Time Is:" & $dif)
EndSelect
WEnd

But is that the exact time ?? (I mean just press Start wait a few sec and press Stop)

And ^^ How can I get only seconds not for example 423.45426246245


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

$z = round(123.5, -1)  ;returns 120

But what I need to do at 123.5 ??

EDIT:And how I use the Round() ??

Mayby:

$dif = TimerDiff($begin, $round) ??

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

But is that the exact time ?? (I mean just press Start wait a few sec and press Stop)

This question hasn't been answered yet. When you press start, the timer starts. When you press stop, the difference is calculated in miliseconds (so Round($dif)/1000 should give you the number of seconds). So this calculates the time between start and stop. If that isn't what you needed, please elaborate.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Can u help me ?? I dont know how the $VarOfRound works :S

I have this:

#include <GuiConstants.au3>

DIM $begin, $dif

$round = Round(123.5, -1)

GuiCreate("Test", 400, 400)
GuiSetState(@SW_SHOW)
$Start_Button = GuiCtrlCreateButton("Start", 10, 10, 50, 50)
GuiCtrlSetState($Start_Button, $GUI_ENABLE)
$Stop_Button = GuiCtrlCreateButton("Stop", 340, 340, 50, 50) 
GuiCtrlSetState($Stop_Button, $GUI_DISABLE) 
$Button_1 = GuiCtrlCreateButton("Click", 70, 10, 50, 50) 
GuiCtrlSetState($Button_1, $GUI_DISABLE) 
$Button_2 = GuiCtrlCreateButton("Click", 130, 10, 50, 50) 
GuiCtrlSetState($Button_2, $GUI_DISABLE) 
$Button_3 = GuiCtrlCreateButton("Click", 190, 10, 50, 50) 
GuiCtrlSetState($Button_3, $GUI_DISABLE) 
$Button_4 = GuiCtrlCreateButton("Click", 250, 10, 50, 50) 
GuiCtrlSetState($Button_4, $GUI_DISABLE) 

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
    Exit

Case $msg = $Start_Button
    $begin = TimerInit()
    GuiCtrlSetState($Button_1, $GUI_ENABLE)
    GuiCtrlSetState($Start_Button, $GUI_DISABLE) 
    
Case $msg = $Button_1
    GuiCtrlSetState($Button_2, $GUI_ENABLE)
    GuiCtrlSetState($Button_1, $GUI_DISABLE)
    
Case $msg = $Button_2
    GuiCtrlSetState($Button_3, $GUI_ENABLE) 
    GuiCtrlSetState($Button_2, $GUI_DISABLE)
    
Case $msg = $Button_3
    GuiCtrlSetState($Button_4, $GUI_ENABLE)
    GuiCtrlSetState($Button_3, $GUI_DISABLE)

Case $msg = $Button_4
    GuiCtrlSetState($Stop_Button, $GUI_ENABLE)
    GuiCtrlSetState($Button_4, $GUI_DISABLE)

Case $msg = $Stop_Button
    $dif = TimerDiff($begin)
    MsgBox(0, "Your Time:", "Your Time Is:" & $dif)
EndSelect
WEnd

Can u make my script that the time will be good ??

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

#include <GuiConstants.au3>

GUICreate("Test", 400, 400)
$Start_Button = GUICtrlCreateButton("Start", 100, 100, 50, 50)
$Stop_Button = GUICtrlCreateButton("Stop", 250, 250, 50, 50)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Start_Button
            $begin = TimerInit()
        Case $msg = $Stop_Button
            $dif = Round(TimerDiff($begin) / 1000, 0)
            MsgBox(0, "Your Time: ", "Your Time Is: " & $dif & " seconds.    ", 4)
    EndSelect
WEnd

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>

GUICreate("Test", 400, 400)
$Start_Button = GUICtrlCreateButton("Start", 100, 100, 50, 50)
$Stop_Button = GUICtrlCreateButton("Stop", 250, 250, 50, 50)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Start_Button
            $begin = TimerInit()
        Case $msg = $Stop_Button
            $dif = Round(TimerDiff($begin) / 1000, 0)
            MsgBox(0, "Your Time: ", "Your Time Is: " & $dif & " seconds.    ", 4)
    EndSelect
WEnd

8)

Dude Your Great !!!!!! TY !!

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0