Glyph Posted November 30, 2008 Share Posted November 30, 2008 (edited) $TimerStart = TimerInit() While 1 sleep(10) $timerdif = TimerDiff($TimerStart) $sec=int($timerdif/1000) if $sec > 60 then;do not go over. $min=int($timerdif/60000) $hour=int($timerdif/3600000) $day=int($timerdif/86400000) $realtime=$day&":"&$hour&":"&$min&":"&$sec What i'm trying to do is make it so the second does not go over 60 seconds... It's like: 1 minute : 65 seocnds.. which is not possible lol.. How would I stop this from happening? If $sec > 60 then $sec=$sec - 60 ? But then, i'll run into the same problem after 2 minutes.. Is there any way to do this quickly? I was thinking another variable to keep track how many loops we have gone? 60 = 1 120 = 2 etc.. Any way to mathematically convert this into one function? Edited November 30, 2008 by Glyph tolle indicium Link to comment Share on other sites More sharing options...
monoceres Posted November 30, 2008 Share Posted November 30, 2008 Something like "If Mod($sec,60)=0 Then ;..." ? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
November Posted November 30, 2008 Share Posted November 30, 2008 (edited) Hi there, I made this now and i don't know if its suitable for you #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "out") $hour = 0 $min = 0 $sec = 0 $gui = GUICreate("Time", 200, 100) $label = GUICtrlCreateLabel("Time - ", 20, 20, 130, 30) GUISetState() while 1 for $sec = 0 to 60 If $sec = 60 Then $sec = 0 $min = $min + 1 EndIf If $min = 60 Then $min = 0 $hour = $hour + 1 EndIf If $hour = 24 Then $hour = 0 EndIf GUICtrlSetData($label, "Time - " & $hour & ":" & $min & ":" & $sec) Sleep(50) Next WEnd func out() Exit EndFunc Set sleep to 1000 to get 1 sec Cheers Edited November 30, 2008 by November Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Glyph Posted November 30, 2008 Author Share Posted November 30, 2008 (edited) I'm trying to do all these commadns without manually typing them out into code: if $sec = 60000 then $min = 1 if $sec = 120000 then $min = 2 if $sec = 180000 then $min = 3 etc.. The main goal is to create an uptime timer like this: 0:1:1:52 (0 days:1 hour:1 minute: 52 seconds) The program will go over 60 seconds AND incriment the minute, which it should not be doing. I have no idea how to stop it from going over 60. expandcollapse popup;<== Includes #include<GUIConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <ListboxConstants.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> #include <INet.au3> #include <EditConstants.au3> #include <StaticConstants.au3> ;==> Includes ;<== Variables $VersionMajor = "5" $VersionMinor = "0" $BuildDate = "11/29/08" Global $UserCount = "0" Global $Port = "63336" Global $Day, $hour, $min, $sec, $realtime ;==> Variables ;<== GUI $MainGUI=GUICreate("Server v" & $VersionMajor & "." & $VersionMinor & " | Glyph |"&$BuildDate, 650, 290,@DesktopWidth/4,@DesktopHeight/4,$WS_OVERLAPPEDWINDOW); Should we XSkin? $Tab = GUICtrlCreateTab(0, 0, 650, 350, BitOR($TCS_BUTTONS, $TCS_HOTTRACK, $TCS_FLATBUTTONS, $WS_EX_TRANSPARENT)) ;<== Main $MainTabItem = GUICtrlCreateTabItem("Main"); Main Tab Item GUICtrlSetState ($MainTabItem,$GUI_FOCUS) ;User info box $UserInfoList = GUICtrlCreateList("No User Selected", 5, 30, 130, 100) ;User view box $UserListView = GUICtrlCreateListView("", 140, 30, 505, 200) GuiCtrlSetResizing($UserListView,bitor($GUI_DOCKLEFT,$GUI_DOCKTOP,$GUI_DOCKBORDERS)) _GUICtrlListView_SetExtendedListViewStyle($UserListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) _GUICtrlListView_InsertColumn($UserListView, 0, "Serial No.", 75) _GUICtrlListView_InsertColumn($UserListView, 1, "@UserName", 100) _GUICtrlListView_InsertColumn($UserListView, 2, "@OSVersion", 130) _GUICtrlListView_InsertColumn($UserListView, 3, "@OSArch", 100) _GUICtrlListView_InsertColumn($UserListView, 4, "Latency", 50) _GUICtrlListView_InsertColumn($UserListView, 5, "Uptime", 50) ;Server Statistics GUICtrlCreateGroup("Local Statistics", 5, 130, 130, 100) $WANIPLabel=GUICtrlCreateLabel("WAN: "&_GetIP(),10,145,130,20) $PortLabel=GUICtrlCreateLabel("Port: "&$Port,10,160,130,20) $UptimeLabel=GUICtrlCreateLabel("Uptime: 0:0:0:0" ,10,175,130,20) ;Log button $EventButton=GUICtrlCreateButton("Event Viewer",5,231,130,19) ;Options Button $OptionButton=GUICtrlCreateButton("Option Panel",5,250,130,19) ;how many users are online? $UsersOnline=GUICtrlCreateLabel("Online: "&$UserCount,5,269,130,19,$SS_CENTER ) ;Editbox Credits $CredEdit = GUICtrlCreateEdit("Shouts: noone yet"& _ "", 140, 235, 505, 50,$ES_MULTILINE) GuiCtrlSetResizing($CredEdit, bitor($GUI_DOCKBottom,$GUI_DOCKleft,$GUI_DOCKHeight)); set the resize method for the edit... ;Needs to be fixed, the width does not align with the userlist width. ;==> Main ;<== Assembly $AssemblyTabItem = GUICtrlCreateTabItem("Assembly"); Assembly Tab Item ;==> Assembly ;==> GUI ;Set the resize method for dockall controls in a single loop. $max = "$UserInfoList, $StatEdit, $EventButton, $OptionButton"; the string to split (all the variables we wanna set resize methods to) $split=StringSplit($max,","); split it for $i = 0 to $split[0]; loop unti lwe are out of variables. GuiCtrlSetResizing(execute($split[$i]),$GUI_DOCKALL); set the resize through the variable in a literal string with the execute command. Next ;Loop for main gui, etc.. GUISetState(@SW_SHOW) $TimerStart = TimerInit() While 1 sleep(10) $timerdif = TimerDiff($TimerStart) $mil=$timerdif $sec=int($mil/1000) $min=int($sec/60) $hour=int($min/60) $day=int($hour/24) $realtime=$day&":"&$hour&":"&$min&":"&$sec GUICtrlSetData($UptimeLabel,"Uptime: "&$realtime) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Edited November 30, 2008 by Glyph tolle indicium Link to comment Share on other sites More sharing options...
November Posted November 30, 2008 Share Posted November 30, 2008 So... Its not what i made in the code? Or you are trying to do like you are is not going to be very easy to declare, let's say how many sec are in 1 day, 21 hours and 48 secs if $sec = 60000 then $min = 1 if $sec = 120000 then $min = 2 if $sec = 180000 then $min = 3 As far as see, it's going to be hard to declare all possible results. Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Glyph Posted November 30, 2008 Author Share Posted November 30, 2008 Something like "If Mod($sec,60)=0 Then ;..." ?Well, almost.Sorry for not explaining things very clearly, i'm not the best at this.I edited my last post and included the code im using it with. tolle indicium Link to comment Share on other sites More sharing options...
monoceres Posted November 30, 2008 Share Posted November 30, 2008 Well, almost. Sorry for not explaining things very clearly, i'm not the best at this. I edited my last post and included the code im using it with. I think this will do for ya $time=Random(10^8,10^9,1) $arr=GetTimeArray($time) ConsoleWrite($time&" ms is "&$arr[0]&" days, "&$arr[1]&" hours, "&$arr[2]&" minutes, "&$arr[3]&" seconds and "&$arr[4]&" ms."&@CRLF) ; Author: monoceres Func GetTimeArray($ms) Local $RetArr[5] Local $days,$hours,$minutes,$seconds $days=Floor($ms/(24*3600*1000)) $ms=Mod($ms,24*3600*1000) $hours=Floor($ms/(3600*1000)) $ms=Mod($ms,3600*1000) $minutes=Floor($ms/(60*1000)) $ms=Mod($ms,60*1000) $seconds=Floor($ms/1000) $ms=Mod($ms,1000) $RetArr[0]=$days $RetArr[1]=$hours $RetArr[2]=$minutes $RetArr[3]=$seconds $RetArr[4]=$ms Return $RetArr EndFunc Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Glyph Posted November 30, 2008 Author Share Posted November 30, 2008 @ monoceres That's exactly what I was looking for. I have much to learn yet, i've never used mod and floor commands... Thank's for helping! tolle indicium 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