Jump to content

Recommended Posts

Posted

hi all,

i have made a script to get information from a website. Between say 6am and 6pm the information is in one place but from 6pm till 6am the info is in another.

instead of running to scripts is there a way i can put both scripts into one and tell autoit to run the first half between time one and second half between time two??

cheers

shaggy

Posted

Look at the @Hour and @Min macros and using some if statements you should be able to do it easily enough.

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

Posted (edited)

I use this UDF in one or or two of my scripts -

 

;===============================================================================
; Function Name:   _Time_InRange()
; Description:     Determine if the current time is within a given Range
; Syntax:          _Time_InRange("Low time", "High time")
; Parameter(s):    $sTime - Low end of the range (Start time)
;                  $eTime - High end of the range (End time)
; Requirement(s):
; Return Value(s): 1 if current time is within the range otherwise 0
; Author(s):   George (GEOSoft) Gedye
; Modification(s): Replaced _NowTime(4) With Formatted @Hour & @Min
; Note(s):    This only uses Hours and Minutes
; Example(s):   MsgBox(0, "Time is good", _Time_InRange("08:00", "23:59"))
;===============================================================================

Func _Time_InRange($sTime, $eTime)
  Local $vRange = 0, $cTime
  $cTime = Number(@Hour & @Min)
  If $cTime >= Number(StringFormat("%04d",StringRegExpReplace($sTime, "\D", ""))) AND _
     $cTime <= Number(StringFormat("%04d",StringRegExpReplace($eTime, "\D", ""))) Then $vRange = 1
  Return $vRange
EndFunc   ;<==> _Time_InRange()
BTW, if you use this, include the commented section up above the actual function!

another edit: This is summarily how I use this code, maybe it'll help..

Local $sStartTime = "0002", $sEndTime = "2358"
While 1
 If _Time_InRange($sStartTime, $sEndTime) Then
  ;
  ;
 EndIf
WEnd
This is how my code (in the If loop) runs until shortly before and shorty after midnight. Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

  • 2 weeks later...
Posted

I use this UDF in one or or two of my scripts -

 

;===============================================================================
; Function Name:   _Time_InRange()
; Description:     Determine if the current time is within a given Range
; Syntax:          _Time_InRange("Low time", "High time")
; Parameter(s):    $sTime - Low end of the range (Start time)
;                  $eTime - High end of the range (End time)
; Requirement(s):
; Return Value(s): 1 if current time is within the range otherwise 0
; Author(s):   George (GEOSoft) Gedye
; Modification(s): Replaced _NowTime(4) With Formatted @Hour & @Min
; Note(s):    This only uses Hours and Minutes
; Example(s):   MsgBox(0, "Time is good", _Time_InRange("08:00", "23:59"))
;===============================================================================

Func _Time_InRange($sTime, $eTime)
  Local $vRange = 0, $cTime
  $cTime = Number(@Hour & @Min)
  If $cTime >= Number(StringFormat("%04d",StringRegExpReplace($sTime, "\D", ""))) AND _
     $cTime <= Number(StringFormat("%04d",StringRegExpReplace($eTime, "\D", ""))) Then $vRange = 1
  Return $vRange
EndFunc   ;<==> _Time_InRange()
BTW, if you use this, include the commented section up above the actual function!

another edit: This is summarily how I use this code, maybe it'll help..

Local $sStartTime = "0002", $sEndTime = "2358"
While 1
 If _Time_InRange($sStartTime, $sEndTime) Then
  ;
  ;
 EndIf
WEnd
This is how my code (in the If loop) runs until shortly before and shorty after midnight.

 

so how would i set it to. run first 1/2 of script every 1hr between 5 am and 6pm then 2nd 1/2 6pm till 5am at only 7pm ?

Posted (edited)

I personally do it like this

While 1
   $time = @HOUR & @MIN
   If $time > 500 and $time < 1800 Then   ; if between 5:00 am and 6:00 pm
      If Mod($time, 100) = 0 Then   ; run every hour
            $place = "place1"
            ; (run func with param $place)
      EndIf
   Else
      If $time = 1900 Then    ; run at 7:00 pm
            $place = "place2"
            ; (run func with param $place)
      EndIf
   EndIf
   Sleep(1000)
Wend

or like this

AdlibRegister("_check", 3600*1000)   ; run every hour

Func _check()
 Local $place
 If @HOUR > 5 and @HOUR < 18 Then   ; if between 5:00 am and 6:00 pm
     $place = "place1"
 ElseIf @HOUR = 19 Then  ; if 7:00 pm 
     $place = "place2"
 Else
     Return
 EndIf
 ; run other func with param $place
EndFunc
Edited by mikell

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...