dannydy Posted February 7, 2012 Share Posted February 7, 2012 (edited) Hi guys,This is kind of strange, When i convert $EndTicks to _TicksToTime($EndTicks, $Hour, $Min, $Sec), then any mins/secs from 00 to 08 after added up with 1mins be truncated to 1number(e.g 1mins after 20:00:00 is 20:1:0), i have no idea?????Please see the attachment for screen captureexpandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Timers.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <GuiListView.au3> #include <Date.au3> Global $hStatusBar, $LWSelectedICurrent = -1,$Sec, $Min, $Hour, $Time Local $StartTicks = _TimeToTicks(@HOUR, @MIN, @SEC) ;MsgBox(0,"",$StartTicks) ; calculate 1 minutes later Local $EndTicks = ($StartTicks + 1 * 60 * 1000) ;MsgBox(0,"",$EndTicks) _TicksToTime($EndTicks, $Hour, $Min, $Sec) ;MsgBox(262144, '', 'If No selection has been made,the Program Will terminate at :' & $Hour & ":" & $Min & ":" & $Sec) Local $hGUI, $iTimerProgress Local $aParts[3] = [100,250,-1] dim $Selection,$statuselect Example() Func Example() Local $listview, $button,$Cancel, $item1, $item2, $item3,$item4, $msg $hGUI = GUICreate("Test Summary Generation", 300, 250, 600, 500, -1, $WS_EX_ACCEPTFILES) ;ToolTip("If No selection has been made,the Program Will terminate at : " & StringFormat("%02d:%02d:%02d", $Hour, $Min, $Sec), 600, 720) ToolTip("If No selection has been made,the Program Will terminate at : " & $Hour & ":" & $Min & ":" & $Sec, 600, 720) GUISetBkColor(0x00E0FFFF) ; will change background color $listview = GUICtrlCreateListView("Test Summary Update ", 50,10, 200, 150);,$LVS_SORTDESCENDING) $button = GUICtrlCreateButton("OK", 75, 170, 70, 20) $Cancel = GUICtrlCreateButton("Cancel", 150, 170, 70, 20) $item1 = GUICtrlCreateListViewItem("item1", $listview) $item2 = GUICtrlCreateListViewItem("item2", $listview) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts) _GUICtrlStatusBar_SetText($hStatusBar,"Current Date : " & StringFormat("%02d-%02d-%02d", @MDAY, @MON, @YEAR), 1) _GUICtrlStatusBar_SetText($hStatusBar,@TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) _GUICtrlStatusBar_SetText($hStatusBar,"No Selection") _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") GUICtrlSetData($item1, "Exchange Online") GUICtrlSetData($item2, "OCS Wave 14") GUISetState() Do $LWSelectedI = _GUICtrlListView_GetSelectedIndices($listview, true) If $LWSelectedI[0] <> 0 Then If $LWSelectedI[1] <> $LWSelectedICurrent Then _GUICtrlStatusBar_SetText($hStatusBar,_GUICtrlListView_GetItemTextString($listview ,$LWSelectedI[1])) $LWSelectedICurrent = $LWSelectedI[1] EndIf EndIf $msg = GUIGetMsg() Select Case $msg = $button ;MsgBox(0, "Selection Made", GUICtrlRead(GUICtrlRead($listview))) $Selection= guictrlread($listview) if $selection = 6 or $selection=7 Then local $answer=MsgBox(1, "Selection Made", _GUICtrlListView_GetItemTextString($listview ,$LWSelectedICurrent) & @LF & "Note* You can Press {ECS} key to terminate program when generating the summary*") if $answer = 1 Then ExitLoop EndIf if $answer = 2 Then $rreturn = 00123 endif EndIf if $selection = 0 Then msgbox (16,"Please Select","No Selection") Elseif $rreturn = 00123 then else ExitLoop endif Case $msg = $listview MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2) Case $msg = $GUI_EVENT_CLOSE Or $msg = $Cancel ;ExitLoop _Exit() EndSelect Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) $livetime = _TimeToTicks(@HOUR, @MIN, @SEC) ;$EndTicks = $Hour & ":" & $Min & ":" & $Sec ;MsgBox(0,"",$livetime) ;MsgBox(0,"",$EndTicks) if $livetime = $EndTicks Then MsgBox(0,"Program Self-Termination","No Selection has been Made",10) _Exit() EndIf EndFunc ;==>_UpdateStatusBarClock Func _Exit() Exit EndFunc ;==>_Exit exit Edited February 7, 2012 by dannydy Link to comment Share on other sites More sharing options...
BrewManNH Posted February 7, 2012 Share Posted February 7, 2012 You used StringFormat in your status bar text message, but didn't in your tooltip message. 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...
dannydy Posted February 7, 2012 Author Share Posted February 7, 2012 (edited) Yeah, StringFormat is the workaround...but earlier i converted the $EndTicks to HH:MM:SS, and then compare with the $livetimer( converted to HH:MM:SS as well). If current mins/secs starts from 00 to 08, then the condition will fail. Because $EndTicks is display as HH:M:S. Edited February 7, 2012 by dannydy Link to comment Share on other sites More sharing options...
BrewManNH Posted February 7, 2012 Share Posted February 7, 2012 Yeah, StringFormat is the workaround...but earlier i converted the $EndTicks to HH:MM:SSWhere?, and then compare with the $livetimer( converted to HH:MM:SS as well). If current mins/secs starts from 00 to 08, then the condition will fail. Because $EndTicks is display as HH:M:S. _TimeToTicks doesn't work that way, it's converting the hours/minutes/seconds to ticks not the other way around.Here's what the variables contain when you use _TimeToTicks:$EndTicks = 36462000$livetime = 36403000Use StringFormat to display it correctly, and _TimeToTicks if you want to have the 2 variables compared using ticks but you should probably be using If $livetime >= $EndTicks Then rather than a straight comparison just to be on the safe side. 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...
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