shaggy89 Posted May 20, 2014 Share Posted May 20, 2014 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 Link to comment Share on other sites More sharing options...
BrewManNH Posted May 20, 2014 Share Posted May 20, 2014 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 GudeHow 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 More sharing options...
shaggy89 Posted May 20, 2014 Author Share Posted May 20, 2014 ok that's the start i was looking for. cheers Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 20, 2014 Share Posted May 20, 2014 (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 WEndThis is how my code (in the If loop) runs until shortly before and shorty after midnight. Edited May 20, 2014 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
shaggy89 Posted May 31, 2014 Author Share Posted May 31, 2014 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 ? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 31, 2014 Share Posted May 31, 2014 Make your script into either two separate scripts or two functions. If you go the two function route, make two versions of the _Time_InRange UDF. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
mikell Posted May 31, 2014 Share Posted May 31, 2014 (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 May 31, 2014 by mikell Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now