Jump to content
Sign in to follow this  
ashcraft

Can't get my timer to reset

Recommended Posts

ashcraft

I have been fiddling with the timer feature.

But, the thing won't reset on its own XD I am sure that i'm doing something wrong  o:) 

$start = TimerInit()




While TimerDiff($start) < 60000
   MouseMove (164, 470)
   Sleep(3000)
   MouseMove (1300, 168)
   Sleep(3000)
   


WEnd
   if TimerDiff($start) > 70000 Then
 $start = 0
 $start = TimerInit()
   EndIf
   

Thanks!

Edited by ashcraft

Share this post


Link to post
Share on other sites
BrewManNH

The only way that would reset the timer would be if the line directly after Wend took 10 seconds to activate, which isn't going to happen. Even if it did, it's not going to do anything because the script ends after that.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Valuater

Maybe...

 Re-done below
 

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
ashcraft

Maybe...

 
$start = TimerInit()
While TimerDiff($start) < 60000
 MouseMove(164, 470)
 Sleep(3000)
 MouseMove(1300, 168)
 Sleep(3000)
 If TimerDiff($start) > 70000 Then
  $start = 0
  $start = TimerInit()
 EndIf
WEnd
 

8)

I have tried this before, it works to an extent. Such as the script has to be sleeping.

Where it sleeps for 3 seconds, if I set 70000 to 61000, it works.

as so:

$start = TimerInit()
While TimerDiff($start) < 60000
 MouseMove(164, 470)
 Sleep(3000)
 MouseMove(1300, 168)
 Sleep(3000)
 If TimerDiff($start) > 61000 Then
  $start = 0
  $start = TimerInit()
 EndIf
WEnd

This won't work since I want it to wait for a time before the script runs again.

Any other ideas?

 

Thanks!

Edited by ashcraft

Share this post


Link to post
Share on other sites
Valuater

Here is what I would do if you want to wait 1 minute

HotKeySet("{ESC}", "Exiter")
Global $start = TimerInit()
Global $count = 0
While 1
 $count += 1
 ToolTip($count & " Times", 50, 50, "COUNT")

 MouseMove(164, 470)
 Sleep(3000)
 MouseMove(1300, 168)
 Sleep(3000)
 Sleep(1000 * 60) ; sleep 1 minute
WEnd
Func Exiter()
 Exit
EndFunc   ;==>Exiter

 

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
ashcraft

Here is what I would do if you want to wait 1 minute

HotKeySet("{ESC}", "Exiter")
Global $start = TimerInit()
Global $count = 0
While 1
 $count += 1
 ToolTip($count & " Times", 50, 50, "COUNT")

 MouseMove(164, 470)
 Sleep(3000)
 MouseMove(1300, 168)
 Sleep(3000)
 Sleep(1000 * 60) ; sleep 1 minute
WEnd
Func Exiter()
 Exit
EndFunc   ;==>Exiter

8)

Since I haven't used some of these functions before, will you be able to tell me how to change the variables to please other projects?

I was gonna set the $start timer to last an hour, and then have a 30 minute rest.

I guess I can set the sleep to 180000, but I only want it to sleep after that one hour :3

This has been tough for me XD

Share this post


Link to post
Share on other sites
ashcraft

any ideas?

I am really having the hardest time with this script, I am probably making it harder than it needs to be. I just want:

start timer

While timer is under one minute do this

 

after timer is greater than one minute, stop this timer

create a new timer

wait under new timer is greater than 30 seconds

kill new timer

reset old timer and go back through the while statement

Rinse and repeat.

------------------

Global $Paused, $Runner
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "ShowMe")
;;;;;;;;;;;;;;;;;;;;;




$start = TimerInit()
While TimerDiff($start) < 60000
 MouseMove(164, 470)
 Sleep(3000)
 MouseMove(1300, 168)
 Sleep(3000)
WEnd
I got this so far to see (this is just so that I can tell its working ;)
 
I tried to use timers.au3 but I cant understand it, it seems to be able to kill timers and set em. But again, I couldn't get it to work.
Edited by ashcraft

Share this post


Link to post
Share on other sites
kylomas

ashcraft,

This is what I got from your post above...

  start timer  - lets call this timer#1
  
  While timer is under one minute do this  - You want to go into a tight loop for 1 minute.   Assuming this is timer#1
  
  after timer is greater than one minute, stop this timer  - Which timer?  How is it set/incremented?
  
  create a new timer  - Lets call this timer#2
  
  wait under new timer is greater than 30 seconds  - Is this timer increasing?
  
  kill new timer  - Timer#2?
  
  reset old timer and go back through the while statement  - Timer#1?
  
  Rinse and repeat.  - Repeat what?

 

 

 

And how does this fit in?

I was gonna set the $start timer to last an hour, and then have a 30 minute rest.

 

You might want to take another try at defining what you are trying to do and what the problem is.

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
ashcraft

I am sorry. I didn't mean to confuse anyone.
Basically, I just want a timer to reset.

Here is my script:
 

$start = TimerInit()
While TimerDiff($start) < 60000
 MouseMove(164, 470)
 Sleep(3000)
 MouseMove(1300, 168)
 Sleep(3000)
WEnd

I want this to be able to reset after a set time. Lets say, 30 seconds. 
So what I want it to do is go through the while statement, then, I want it to wait 30 seconds before going through it again.

 

Edited by ashcraft

Share this post


Link to post
Share on other sites
BrewManNH

Does this give you any ideas?

$Timer = TimerInit()
While 1
    If TimerDiff($Timer) < 60000 ; if under a minute do the first part
        ; do this
    Else ; after a minute, sleep for 30 seconds, then reset the timer
        Sleep(30000)
        $Timer = TimerInit()        
    EndIf
WEnd

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×