Jump to content
Sign in to follow this  
t0ddie

problem with timing

Recommended Posts

t0ddie

this works pretty good, and its accurately 60 seconds.

$x = 60

for $z = 1 to 60

sleep (500)

splashtexton ("OPPONENT HAS RESIGNED!","waiting 60 seconds..... " & $x,250,30,700,350)

mousemove(400,400,0)

$x = $x - 1

sleep (500)

mousemove(300,300,0)

Next

but i want to log the time i stay idle, and the script is in a do until loop doing other things besides just sleeping,

pretty much, this is what i have going on in the do until loop

$min = 10

$sec = 0

$time = 0

Do

$sec = $sec + 1

If $sec = 10 Then

$time = ""

EndIf

If $sec = 60 Then

$sec = 0

$time = 0

$min = $min + 1

EndIf

splashtexton ("STUBBORN OPPONENT!","idle time exceeded" & @CR & "moving mouse to avoid timeout" & @CR & _

"waiting for opponent to resign....." & @CR & @CR & "IDLE TIME " & $min & ":" & $time & $sec & @CR & @CR & _

"HIGH ROLLER is running!" & @CR & "press ESC to exit at any time.",250,170,700,350)

mousemove(400,400,0)

sleep(950)

mousemove(300,300,0)

$away = pixelgetcolor (193,505)

Until $away = 15695363

anyways, it looks like a second to the human eye..

you can see i changed the sleep in this example from 1000 to 950.

thats because when i run this script at 1000, it seems to be 3 seconds off according to my computer clock here.

but i cant get the time exactly right. is there a way i can have a seperate function running.. keeping track of the time.. at the same time my script is running without making a second script? because the commands in the do until loop are taking up some time, and making the counter not accurate, and it seems silly to try to find some sleep time that will work, like 932.637647659

thanks in advance for the suggestions.

T0ddie

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
t0ddie

hmmm, im expecting exactly 3000 milliseconds.

from the help file

$begin = TimerInit()

sleep(3000)

$dif = TimerDiff($begin)

msgbox(0,"Time Difference",$dif)

my result

2991.21871634523

is this a bug?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
t0ddie

thanks jon

well, since thats not going to work,... how about this.

is there someway to get the internal time of the clock on your computer.....

then do your thing....

then get the time again.... and figure out the difference?

seems reliable....

suggestions?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
Jos

I was more thinking using it like this:

$begin = TimerInit()
For $x = 1 To 5
   While TimerDiff($begin) < $x * 3000
      Sleep(1)
   Wend
   MsgBox(0, "Time Difference", TimerDiff($begin),1)
Next

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
t0ddie

noted jdb

but, is there a way to get the time on your computer? like when you create a file... in properties... it tells you the time it was created.

can i "check" the time on my computer in a certain place in the script, and check it again later?

heck, can the computer time even be obtained with autoit?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
Jos

noted jdb

but, is there a way to get the time on your computer? like when you create a file... in properties... it tells you the time it was created.

can i "check" the time on my computer in a certain place in the script, and check it again later?

heck, can the computer time even be obtained with autoit?

<{POST_SNAPBACK}>

:idiot: ofcource

ever seen these macro's: @SEC @MIN @HOUR ???????


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SlimShady

noted jdb

but, is there a way to get the time on your computer? like when you create a file... in properties... it tells you the time it was created.

can i "check" the time on my computer in a certain place in the script, and check it again later?

heck, can the computer time even be obtained with autoit?

<{POST_SNAPBACK}>

http://www.autoitscript.com/autoit3/docs/m...TimeAndDate.htm

Share this post


Link to post
Share on other sites
t0ddie

sweet.

msgbox(0,"test", @hour & " " & @min & " " & @sec)

thanks. you rule


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
t0ddie

well, this seems to be working pretty good so far.

$hour_now = @HOUR

$min_now = @MIN

$sec_now = @SEC

Do

$hour_after = @HOUR

$min_after = @MIN

$sec_after = @SEC

$hour = ""

if $min_after - $min_now > 59 then

$hour = $hour_after - $hour_now & ":"

endif

if $sec_after - $sec_now < 10 then

$sec = "0" & $sec

endif

$min = $min_after + 10 - $min_now

$sec = $sec_after - $sec_now

splashtexton ("STUBBORN OPPONENT!","idle time exceeded" & @CR & "moving mouse to avoid timeout" & @CR & _

"waiting for opponent to resign....." & @CR & @CR & "IDLE TIME:" & @CR & $hour & $min & ":" & $sec & @CR & @CR & _

"HIGH ROLLER is running!" & @CR & "press ESC to exit at any time.",250,190,700,350)

sleep(100)

$away = pixelgetcolor (193,505) ; coordinates of lower left corner of large orange resignation/away box.

Until $away = 15695363

it starts you off at 10 minutes.

the problem is, while its counting, depending on what second your computer clock is on... it will do something like this.

10:51

10:52

10:53

10:54

10:55

11:-4

11:-3

11:-2

11:-1

heres where i am so far

as you can see, its not the way i intended to display the info. but it seems to be working for the most part.

im trying to make it so that $hours doesnt even display until its been an hour.

and im also trying to make the seconds display like this

01 02 03 04 05 06 07 08 09 instead of 1 2 3 4 5 6 7 8 9

i could rack my brain for a few hours, but i thought i would ask for a quick fix here

please, guide me. besides i need to take a break. i have been working on this script in its entirety for olmost 2 weeks lol

thanks for your time and your brain

Todd

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
t0ddie

???

$hour_now = @HOUR

$min_now = @MIN

$sec_now = @SEC

Do

$hour_after = @HOUR

$min_after = @MIN

$sec_after = @SEC

$hour = ""

if $min_after - $min_now > 59 then

$hour = $hour_after - $hour_now & ":"

endif

if $sec_after - $sec_now < 10 then

$sec = "0" & $sec

endif

$min = $min_after + 10 - $min_now

$sec = $sec_after - $sec_now

StringFormat("%02i:%02i:%02i", $hour, $min, $sec)

splashtexton ("STUBBORN OPPONENT!","idle time exceeded" & @CR & "moving mouse to avoid timeout" & @CR & _

"waiting for opponent to resign....." & @CR & @CR & "IDLE TIME:" & @CR & $hour & $min & ":" & $sec & @CR & @CR & _

"HIGH ROLLER is running!" & @CR & "press ESC to exit at any time.",250,190,700,350)

sleep(100)

$away = pixelgetcolor (193,505) ; coordinates of lower left corner of large orange resignation/away box.

Until $away = 15695363

i dont see what that did...


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
Jos

???

-snip-

i dont see what that did...

<{POST_SNAPBACK}>

you need to put it into your splashtexton ... :idiot:

something like:

SplashTextOn("STUBBORN OPPONENT!", "idle time exceeded" & @CR & "moving mouse to avoid timeout" & @CR & _
         "waiting for opponent to resign....." & @CR & @CR & "IDLE TIME:" & StringFormat("%02i:%02i:%02i", $hour, $min, $sec) & @CR & @CR & _
         "HIGH ROLLER is running!" & @CR & "press ESC to exit at any time.", 250, 190, 700, 350)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
kanumi

It suggest calculation with the number of seconds.

$last_passed_sec = -1

$day_start = @MDAY
$hour_start = @HOUR
$min_start = @MIN
$sec_start = @SEC
$start_secs = ( (@HOUR * 60) + @MIN) * 60 + @SEC

HotKeySet("{ESC}", "Terminate")

Do 
 ;calculate the seconds passed by
 ;calculating here is only valid up to 24 hours!
   If @MDAY <> $day_start Then
      $passed_secs = 24 * 60 * 60
   Else
      $passed_secs = 0
   EndIf
   $passed_secs = $passed_secs - $start_secs + ( (@HOUR * 60) + @MIN) * 60 + @SEC
   
   
   $hour_passed = Int($passed_secs / 3600)
   $passed_secs = Mod($passed_secs, 3600)
   $min_passed = Int($passed_secs / 60)
   $sec_passed = Mod($passed_secs, 60)
   
 ;just to avoid unnecessary updates - flickering
   If $last_passed_sec <> $passed_secs Then
      $last_passed_sec = $passed_secs 
      
      $my_timestr = StringFormat("%02i:%02i:%02i", $hour_passed, $min_passed, $sec_passed)
      
      SplashTextOn("STUBBORN OPPONENT!", "idle time exceeded" & @CR & "moving mouse to avoid timeout" & @CR & _
            "waiting for opponent to resign....." & @CR & @CR & "IDLE TIME:" & @CR & $my_timestr & @CR & @CR & _
            "HIGH ROLLER is running!" & @CR & "press ESC to exit at any time.", 250, 190, 700, 350)
   EndIf
   
   Sleep(100)
   
   $away = PixelGetColor(193, 505); coordinates of lower left corner of large orange resignation/away box.
Until $away = 15695363

Exit 0


Func Terminate()
   Exit 0
EndFunc ;==>Terminate
Edited by kanumi

Share this post


Link to post
Share on other sites
t0ddie

ty kanumi

how would i make it start out at 10 minutes?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
t0ddie

ANYONE?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
DirtyBanditos

ANYONE?

<{POST_SNAPBACK}>

:D Hi adde to your script this and idit it for the sleep time. :idiot:

Idit it for your setting`s i hope it help. :lol:

Ps: and make a reaped or loop to restart i all 10 minutes.

Sleep(90000)
Run(@WindowsDir & "\Media\tada.wav", 1)
;or you like this
Sleep(90000)
Run(@ScriptDir & "\Media\tada.wav", 1)

;or you like this  :D 
$begin = TimerInit()
For $x = 1 To 5
  While TimerDiff($begin) < $x * 3000
     Sleep(1)
  Wend
  MsgBox(0, "Time Difference", TimerDiff($begin),1)
Next
Edited by DirtyBanditos

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.