Jump to content

I cant get my timer to reset


Recommended Posts

Hihi guys several hours messing and i still cat figure out why timer wont reset in my func.

Func shold loop untill timer difference and then it shold do other things including to reset timer as well.

Timer otself works good. after 30seconds it goes to next func. it just dosnt reset timer. 

Func _Start()
While 1
    If TimerDiff($hTimer) > 30 * 1000 Then ; Wait for 10 secs
   $hTimer = 0
    $hTimer = TimerInit()
        Sleep(100)
        _Image()
         Sleep(100)
        _actTimer()
         Sleep(100)
     Else
MouseClick("Left", $aPos6[0], $aPos6[1], 1)
MouseClick("Left", $aPos4[0], $aPos4[1], 1)

MouseClick("Left", $aPos5[0], $aPos5[1], 1)

MouseClick("Left", $aPos7[0], $aPos7[1], 150,0)
Sleep(100)
    EndIf
    WEnd
 EndFunc

 

Link to comment
Share on other sites

I'm surprised it doesn't give you an error message as $hTimer hasn't been declared yet before you're trying to check whether 10 seconds has passed. Other than that, the code should reset the $hTimer handle after 30 seconds has passed.I can only guess that there's something else in your code that isn't here that is causing it.

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

Link to comment
Share on other sites

11 minutes ago, Jos said:

Post something runnable that actually shows the issue please.

Jos

here it is

#include <Timers.au3>
#NoTrayIcon
HotKeySet("{f1}", "Terminate")
HotKeySet("{f2}", "_start")
  Local $hTimer = TimerInit()



  Func _Start()
While 1
    If TimerDiff($hTimer) > 30 * 1000 Then ; Wait for 10 secs
   $hTimer = 0
    $hTimer = TimerInit()
        Sleep(100)
        _Image()
         Sleep(100)
        _actTimer()
         Sleep(100)
     Else
MouseClick("Left", $aPos6[0], $aPos6[1], 1)
MouseClick("Left", $aPos4[0], $aPos4[1], 1)

MouseClick("Left", $aPos5[0], $aPos5[1], 1)

MouseClick("Left", $aPos7[0], $aPos7[1], 150,0)
Sleep(100)
    EndIf
    WEnd
 EndFunc



   Func _Image()
    _WriteToEditBox("Image")
    Sleep(2000)
    send("{w down}")
    Sleep(2000)
    send("{w up}")
    Sleep(2200)
Send("{d down}") ; Holds the d key down
Sleep (15000)
Send("{d up}") ; Releases the d key
Sleep(1000)
Send("{a down}") ; Holds the A key down
Sleep (15000)
Send("{a up}") ; Releases the A key
    Sleep(1000)
    send("{w down}")
    Sleep(2000)
    send("{w up}")
    Sleep(1000)


    _actTimer()
 EndFunc

 Func _actTimer()
    Sleep(200)
;~  Reserved for future
  _Start()
EndFunc

 

Edited by dersiniar
Link to comment
Share on other sites

Func _actTimer()
     Sleep(200)
;~  Reserved for future
     Func _Start()
     EndFunc   ;==>_Start

Is this your actual code? You're redeclaring the function _Start inside another function without closing the first function. That won't run as written. If you're actually going back to the function start within this function by calling it instead of recreating it, then that is part of your problem, it's very recursive.

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

Link to comment
Share on other sites

  • Developers

Try again and this time check before posting. ;)

Jos

Edit: I see we have a similar kind of history about this type of incoherent postings:

Quote

ah whaeva, i ask help cos i cant undesratand my own. i get poinbtles blablabla so its waste of time. i got help allready from elitepvprs. there i asked same as here, and got helped. here you just talking. not actuly helpüing, so its not help forum

remember? 
Hope you try a little harder this time or else this thread will have the same faith. 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

2 minutes ago, BrewManNH said:
Func _actTimer()
     Sleep(200)
;~  Reserved for future
     Func _Start()
     EndFunc   ;==>_Start

Is this your actual code? You're redeclaring the function _Start inside another function without closing the first function. That won't run as written. If you're actually going back to the function start within this function by calling it instead of recreating it, then that is part of your problem, it's very recursive.

sry, it was typo. not regreating it, juts go back to start from there

Link to comment
Share on other sites

  • Developers
3 minutes ago, Jos said:

Edit: I see we have a similar kind of history about this type of incoherent postings:

Quote

ah whaeva, i ask help cos i cant undesratand my own. i get poinbtles blablabla so its waste of time. i got help allready from elitepvprs. there i asked same as here, and got helped. here you just talking. not actuly helpüing, so its not help forum

remember? 
Hope you try a little harder this time or else this thread will have the same faith. 

Just so you see this and there are many errors in the script. Post something that really works and shows the issue or just don't post at all!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Just now, dersiniar said:

it, juts go back to start from there

Don't do that, just use the Return keyword to let it complete the  _actTimer function and go back to the running function. Otherwise if it runs too long you're going to get a stack error because of the recursion.

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

Link to comment
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
 Share

×
×
  • Create New...