Rogue5099 Posted April 9, 2011 Share Posted April 9, 2011 Trying to run a function every 5 mins. If @MIN = "00" Or @MIN = "05" Or @MIN = "10" Or @MIN = "15" Or @MIN = "20" Then.... Got to be an easier way! My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
iamtheky Posted April 9, 2011 Share Posted April 9, 2011 5 minutes from the last time the function ran might be better accomplished with timerinit and timerdiff. Because in your current example if your function takes 4 minutes to run, it would only wait a minute then run again. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Rogue5099 Posted April 9, 2011 Author Share Posted April 9, 2011 (edited) That's a good idea. The function only takes 5 secs MAX to run. I want it to run on the MIN though not loose any seconds over time. If StringInStr(@MIN, "5", 0, 2, 1) = 2 Or StringInStr(@MIN, "0", 0, 2, 1) = 2 Then Above works only on 5 mins not on the min ending in 0 Edited April 9, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Rogue5099 Posted April 9, 2011 Author Share Posted April 9, 2011 Found it: If Mod(@MIN, 5) = 0 Then psbeau 1 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
darkjohn20 Posted April 9, 2011 Share Posted April 9, 2011 (edited) $iMinutes = 5 $hTimer = TimerInit() While 1 If TimerDiff($hTimer) > ($iMinutes * 60000) Then ConsoleWrite("5 minutes have passed!" & @CRLF) $hTimer = TimerInit() EndIf WEnd Edited April 9, 2011 by darkjohn20 Link to comment Share on other sites More sharing options...
guinness Posted April 9, 2011 Share Posted April 9, 2011 Why not use AdlibRegister? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
wakillon Posted April 9, 2011 Share Posted April 9, 2011 Another way #Include <Date.au3> Global $_Timer = _NowCalc ( ) Global $_Interval = 5 While 1 $_NowCalc = _NowCalc ( ) If _DateDiff ( "n", $_Timer, $_NowCalc ) >= $_Interval Then ; 5 min ConsoleWrite ( "->---- " & $_Interval & " Minutes elapsed : " & $_NowCalc & @Crlf ) $_Timer = $_NowCalc EndIf Sleep ( 10 ) WEnd AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
sahsanu Posted April 9, 2011 Share Posted April 9, 2011 Found it: If Mod(@MIN, 5) = 0 Then If you want to run at 00, 05, 10, 15... then this script will do: Global $switch = 0 While 1 IF Mod(@MIN,5) = 0 Then If $switch = 0 Then ConsoleWrite("It is time to run: " & @MIN & @CRLF) ;Here goes your stuff $switch = 1 EndIf Else $switch = 0 EndIf Sleep(250) WEnd Link to comment Share on other sites More sharing options...
Rogue5099 Posted April 10, 2011 Author Share Posted April 10, 2011 Why not use AdlibRegister?I am sending an email and I need it on the 5's not any other time to check for errors in system.If I use AdlibRegister then it goes from whenever the script is started. My projects: Inventory / Mp3 Inventory, Computer Stats 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