Kiti Posted July 2, 2008 Share Posted July 2, 2008 (edited) This is my script: expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts Global $timer, $Secs, $Mins, $Hour, $Time $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Warn after:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Timer() GUISetState(@SW_HIDE) $h = GUICtrlRead($Input1) $m = GUICtrlRead($Input2) $s = GUICtrlRead($Input3) Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) If $lasth <> $iHours Or $lastm <> $iMins Or $lasts <> $iSecs Then ToolTip("Au trecut " & $iMins & " minute si " & $iSecs & " secunde", 0, 0) If $iHours = Int($h) And $iMins = Int($m) And $iSecs = Int($s) Then MsgBox(64, "", "Time's over!") GUISetState(@SW_SHOW) ;HERE'S THE PROBLEM. I WANT EVERYTHING TO START OVER while 1 tooltip(""); THIS IS NOT OK, BUT AT LEAST THE TOOLTIP DOES NOT APPEAR ANYMORE AFTER THE TIME PASSES WEnd EndIf $lasth = $iHours $lastm = $iMins $lasts = $iSecs EndIf EndFunc ;==>GoToBathroom Func Button1Click() GUISetState(@SW_HIDE) $begin = Random(600000, 1500000, 1) $afksleep = $begin $start = TimerInit() While $afksleep > 0 $afksleep = TimerDiff($start) Timer() Sleep(1000) WEnd ToolTip("") EndFunc ;==>Button1Click Func Form1Close() Exit 0 EndFunc ;==>Form1Close I put let's say 5 seconds in the input, I press ok, the tooltip appears and it counts up to 5. But now, I want the tooltip to dissapear, and I'll be able to go through this process over and over again, so I'll be able to set a limit time again, but this doesn't happens. The tooltip dissapears because of the While loop (which is totally wrong), and the OK button doesn't work anymore. I think there should be some massive changes in the script, but I don't know how to make them, so it will work. Thank you! Edited July 2, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
goldenix Posted July 2, 2008 Share Posted July 2, 2008 (edited) You need global variable: to rurn it off & off: See the commented out lines I made changes to & uncomment them before running the code expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts ;~ Global $timer, $Secs, $Mins, $Hour, $Time , $Round_Finished = False $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Warn after:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) Func Timer() GUISetState(@SW_HIDE) $h = GUICtrlRead($Input1) $m = GUICtrlRead($Input2) $s = GUICtrlRead($Input3) Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) If $lasth <> $iHours Or $lastm <> $iMins Or $lasts <> $iSecs Then ToolTip("Au trecut " & $iMins & " minute si " & $iSecs & " secunde", 0, 0) If $iHours = Int($h) And $iMins = Int($m) And $iSecs = Int($s) Then tooltip("") MsgBox(64, "", "Time's over!") ;~ $Round_Finished = True GUISetState(@SW_SHOW) ;HERE'S THE PROBLEM. I WANT EVERYTHING TO START OVER EndIf $lasth = $iHours $lastm = $iMins $lasts = $iSecs EndIf EndFunc ;==>GoToBathroom Func Button1Click() GUISetState(@SW_HIDE) $begin = Random(600000, 1500000, 1) $afksleep = $begin $start = TimerInit() While $afksleep > 0 $afksleep = TimerDiff($start) Timer() ;~ If $Round_Finished = True Then ;~ $Round_Finished = False ;~ Return ;~ EndIf Sleep(1000) WEnd EndFunc ;==>Button1Click Func Form1Close() Exit 0 EndFunc ;==>Form1Close While 1 Sleep(100) WEnd Edited July 2, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
Kiti Posted July 2, 2008 Author Share Posted July 2, 2008 (edited) Thank you a lot! It works flawlessly ! Now I've replaced the tooltip with this: ToolTip("It passed " & $iMins & " minutes and " & $iSecs & " seconds."& @CRLF & "There are "& $m-$iMins & " minutes and " & $s-$iSecs & " seconds remaining"& @CRLF & "from the total of " & $m & " minutes and " & $s & " seconds.", 0, 0)oÝ÷ ا¶§ºfÞ®ìyÊ'vËajÚZ²ÇÈ+y«^®ØZØ^ézº±ç(Û,zÖò¶®±êÈëgz÷¬yÊ'vÊ'¶¬yÊ'vX§xÝý±©ÞjÌ©®åzf§tý[(÷¢·©È~ËZµéÐÄv+R¢[Þu«¢+Ø$%%ÀÌØí̱ÐìÀÌØí¥MÌQ¡¸($$%Q½½±Q¥À ÅÕ½Ðí%ÐÁÍÍÅÕ½ÐìµÀìÀÌØí¥5¥¹ÌµÀìÅÕ½Ðìµ¥¹ÕÑ̹ÅÕ½ÐìµÀìÀÌØí¥M̵ÀìÅÕ½Ðìͽ¹Ì¸ÅÕ½ÐìµÀì I1µÀìÅÕ½ÐíQ¡ÉÉÅÕ½ÐìµÀìÀÌØí´´ÀÌØí¥5¥¹Ì´ÄµÀìÅÕ½Ðìµ¥¹ÕÑ̹ÅÕ½ÐìµÀìØÀ´ÀÌØíÌ´ÀÌØí¥M̵ÀìÅÕ½Ðìͽ¹Ìɵ¥¹¥¹ÅÕ½ÐìµÀì I1µÀìÅÕ½Ðíɽ´Ñ¡Ñ½Ñ°½ÅÕ½ÐìµÀìÀÌØí´µÀìÅÕ½Ðìµ¥¹ÕÑ̹ÅÕ½ÐìµÀìÀÌØí̵ÀìÅÕ½Ðìͽ¹Ì¸ÅÕ½Ðì°À°À¤($%±Í($$%Q½½±Q¥À ÅÕ½Ðí%ÐÁÍÍÅÕ½ÐìµÀìÀÌØí¥5¥¹ÌµÀìÅÕ½Ðìµ¥¹ÕÑ̹ÅÕ½ÐìµÀìÀÌØí¥M̵ÀìÅÕ½Ðìͽ¹Ì¸ÅÕ½ÐìµÀì I1µÀìÅÕ½ÐíQ¡ÉÉÅÕ½ÐìµÀìÀÌØí´´ÀÌØí¥5¥¹ÌµÀìÅÕ½Ðìµ¥¹ÕÑ̹ÅÕ½ÐìµÀìÀÌØíÌ´ÀÌØí¥M̵ÀìÅÕ½Ðìͽ¹Ìɵ¥¹¥¹ÅÕ½ÐìµÀì I1µÀìÅÕ½Ðíɽ´Ñ¡Ñ½Ñ°½ÅÕ½ÐìµÀìÀÌØí´µÀìÅÕ½Ðìµ¥¹ÕÑ̹ÅÕ½ÐìµÀìÀÌØí̵ÀìÅÕ½Ðìͽ¹Ì¸ÅÕ½Ðì°À°À¤($%¹% Now I'll do the same thing for minutes, hours and days Edited July 2, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
Kiti Posted July 2, 2008 Author Share Posted July 2, 2008 Here's my script, after some work on it: expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts Global $timer, $Secs, $Mins, $Hour, $Time, $Round_Finished = False $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("0", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("0", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("0", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Avertizare peste:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func GoToBathroom() GUISetState(@SW_HIDE) $h = GUICtrlRead($Input1) $m = GUICtrlRead($Input2) $s = GUICtrlRead($Input3) Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) $pos = MouseGetPos() If $lasth <> $iHours Or $lastm <> $iMins Or $lasts <> $iSecs Then If $pos[0] = @DesktopWidth - 1 And $pos[1] = 0 Then $HourString = $iHours & " ore " $MinutesString = $iMins & " minute " $SecondsString = $iSecs & " secunde." $RemainingSeconds = $s - $iSecs $RemainingMinutes = $m - $iMins $RemainingHours = $h - $iHours $hString = $h & " ore " $mString = $m & " minute " $sString = $s & " si secunde." $RemainingHoursString = $RemainingHours & " ore " $RemainingMinutesString = $RemainingMinutes & " minute " $RemainingSecondsString = $RemainingSeconds & " si secunde ramase" Select Case $m <= $iMins And $h > 0 $RemainingSeconds = 60 - $s - $iSecs $RemainingMinutes = 59 - $m - $iMins $RemainingHours = $h - $iHours - 1 $RemainingSecondsString = $RemainingSeconds & " secunde ramase" $RemainingMinutesString = $RemainingMinutes & " minute si " $RemainingHoursString = $RemainingHours & " ore " Case $s < $iSecs $RemainingSeconds = 60 - $s - $iSecs $RemainingMinutes = $m - $iMins - 1 $RemainingSecondsString = $RemainingSeconds & " secunde ramase" $RemainingMinutesString = $RemainingMinutes & " minute si " EndSelect If $iHours = 0 Then $HourString = "" EndIf If $iMins = 0 Then $MinutesString = "" EndIf If $iSecs = 0 Then $SecondsString = "" EndIf If $RemainingHours = 0 Then $RemainingHoursString = "" EndIf If $RemainingMinutes = 0 Then $RemainingMinutesString = "" EndIf If $RemainingSeconds = 0 Then $RemainingSecondsString = "" EndIf If $h = 0 Then $hString = "" EndIf If $m = 0 Then $mString = "" EndIf If $s = 0 Then $sString = "" EndIf ToolTip("Au trecut " & $HourString & $MinutesString & $SecondsString & @CRLF & "Mai sunt " & $RemainingHoursString & $RemainingMinutesString & $RemainingSecondsString & @CRLF & "din totalul de " & $hString & $mString & $sString, 0, 0) If $iHours = Int($h) And $iMins = Int($m) And $iSecs = Int($s) Then MsgBox(64, "Gata!", "Constructia s-a terminat!") $Round_Finished = True GUISetState(@SW_SHOW) ToolTip("") EndIf Else ToolTip("") EndIf $lasth = $iHours $lastm = $iMins $lasts = $iSecs EndIf EndFunc ;==>GoToBathroom Func Button1Click() GUISetState(@SW_HIDE) $begin = Random(600000, 1500000, 1) $afksleep = $begin $start = TimerInit() While $afksleep > 0 $afksleep = TimerDiff($start) GoToBathroom() If $Round_Finished = True Then $Round_Finished = False Return EndIf Sleep(1000) WEnd ToolTip("") EndFunc ;==>Button1Click Func Form1Close() Exit 0 EndFunc ;==>Form1Close But it's not stable. If I put only minutes, it's ok. But if I put minutes AND seconds, when it counts down, instead of going to 59 it goes to 55/53 and sometimes the time the time on the first line passes from 2 to 2 seconds. Can you spot the problem? Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 2, 2008 Share Posted July 2, 2008 Your Sleep() is too long!! Think about it, if you sleep for 1 sec and then run some code that take some time then there will obviously be more than 1 sec between every run!! If you want it to run only once every second I would advice you to use AdlibEnable() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Kiti Posted July 2, 2008 Author Share Posted July 2, 2008 Your Sleep() is too long!! Think about it, if you sleep for 1 sec and then run some code that take some time then there will obviously be more than 1 sec between every run!!If you want it to run only once every second I would advice you to use AdlibEnable()Brilliant ! Thank you! Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
Kiti Posted July 2, 2008 Author Share Posted July 2, 2008 (edited) It's even worse now. It goes to 51 instead of 59. But is it correct to use adlib with the parameter 1000 if the loop is already executed from 1000 to 1000ms ? expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts Global $timer, $Secs, $Mins, $Hour, $Time, $Round_Finished = False $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("0", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("0", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("0", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Avertizare peste:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func myAdlib() GUISetState(@SW_HIDE) $h = GUICtrlRead($Input1) $m = GUICtrlRead($Input2) $s = GUICtrlRead($Input3) Local $iHours, $iMins, $iSecs _TicksToTime($afksleep, $iHours, $iMins, $iSecs) $pos = MouseGetPos() If $lasth <> $iHours Or $lastm <> $iMins Or $lasts <> $iSecs Then If $pos[0] = @DesktopWidth - 1 And $pos[1] = 0 Then $HourString = $iHours & " ore " $MinutesString = $iMins & " minute " $SecondsString = $iSecs & " secunde." $RemainingSeconds = $s - $iSecs $RemainingMinutes = $m - $iMins $RemainingHours = $h - $iHours $hString = $h & " ore " $mString = $m & " minute " $sString = $s & " si secunde." $RemainingHoursString = $RemainingHours & " ore " $RemainingMinutesString = $RemainingMinutes & " minute " $RemainingSecondsString = $RemainingSeconds & " si secunde ramase" If $m <= $iMins And $h > 0 Then $RemainingSeconds = 60 - $s - $iSecs $RemainingMinutes = 59 - $m - $iMins $RemainingHours = $h - $iHours - 1 $RemainingSecondsString = $RemainingSeconds & " secunde ramase" $RemainingMinutesString = $RemainingMinutes & " minute si " $RemainingHoursString = $RemainingHours & " ore " EndIf If $s < $iSecs Then $RemainingSeconds = 60 - $s - $iSecs $RemainingMinutes = $m - $iMins - 1 $RemainingSecondsString = $RemainingSeconds & " secunde ramase" $RemainingMinutesString = $RemainingMinutes & " minute si " EndIf If $iHours = 0 Then $HourString = "" EndIf If $iMins = 0 Then $MinutesString = "" EndIf If $iSecs = 0 Then $SecondsString = "" EndIf If $RemainingHours = 0 Then $RemainingHoursString = "" EndIf If $RemainingMinutes = 0 Then $RemainingMinutesString = "" EndIf If $RemainingSeconds = 0 Then $RemainingSecondsString = "" EndIf If $h = 0 Then $hString = "" EndIf If $m = 0 Then $mString = "" EndIf If $s = 0 Then $sString = "" EndIf ToolTip("Au trecut " & $HourString & $MinutesString & $SecondsString & @CRLF & "Mai sunt " & $RemainingHoursString & $RemainingMinutesString & $RemainingSecondsString & @CRLF & "din totalul de " & $hString & $mString & $sString, 0, 0) If $iHours = Int($h) And $iMins = Int($m) And $iSecs = Int($s) Then MsgBox(64, "Gata!", "Constructia s-a terminat!") $Round_Finished = True GUISetState(@SW_SHOW) ToolTip("") EndIf Else ToolTip("") EndIf $lasth = $iHours $lastm = $iMins $lasts = $iSecs EndIf EndFunc ;==>myAdlib Func Button1Click() GUISetState(@SW_HIDE) $begin = Random(600000, 1500000, 1) $afksleep = $begin $start = TimerInit() While $afksleep > 0 $afksleep = TimerDiff($start) GoToBathroom() If $Round_Finished = True Then $Round_Finished = False Return EndIf Sleep(1000) WEnd ToolTip("") EndFunc ;==>Button1Click Func Form1Close() Exit 0 EndFunc ;==>Form1CloseoÝ÷ ØGb´a¢è!´(ºWl¢[Þ¶©®åzkaÌÉ»×hzÉ÷öÜ(®G¢¶«jëh×6#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts Global $timer, $Secs, $Mins, $Hour, $Time, $Round_Finished = False $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("0", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("0", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("0", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Avertizare peste:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Button1Click() $h = @HOUR $m = @MIN $s = @SEC $ih = GUICtrlRead($Input1) $im = GUICtrlRead($Input2) $is = GUICtrlRead($Input3) While 1 $seconds = @SEC - $s $minutes = @MIN - $m $remainingseconds = $is - $seconds $remainingminutes = $im - $minutes #cs If @SEC < $s Then $seconds = 60 - @SEC - $s $minutes = @MIN - $m + 1 EndIf #ce If $is < $seconds Then $remainingseconds = 60 - $is - $seconds $remainingminutes = $im - $minutes - 1 EndIf ToolTip("Time passed: " & @HOUR - $h & ":" & $minutes & ":" & $seconds & @CRLF & "Time remaining: " & $remainingminutes & ":" & $remainingseconds , 0, 0) Sleep(1000) WEnd EndFunc ;==>Button1Click Func Form1Close() Exit 0 EndFunc ;==>Form1Close Edited July 2, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 2, 2008 Share Posted July 2, 2008 (edited) Your code looks a bit messy to me and I am not sure what's everything is for but I rewrote it a bit as I would have liked it, hopefully you can change it to suit your needs. expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $afksleep, $lasth, $lastm, $lasts Global $timer, $Secs, $Mins, $Hour, $Time, $Round_Finished = False $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("0", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("0", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("0", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Avertizare peste:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Button1Click() GUISetState(@SW_HIDE, $Form1) $ih = GUICtrlRead($Input1) $im = GUICtrlRead($Input2) $is = GUICtrlRead($Input3) $TimeRead = ($ih*60*60+$im*60+$is)*1000 $Timer = TimerInit() $TimeDiff = TimerDiff($Timer) While $TimeDiff < $TimeRead $TimeDiff = Int(TimerDiff($Timer)) $TimeRemaining = $TimeRead - $TimeDiff ToolTip("Seconds passed: " & Int($TimeDiff/1000) & @CRLF & "Seconds remaining: " & Int($TimeRemaining/1000), 0, 0) Sleep(250) ;time decreased WEnd ToolTip("") GUISetState(@SW_SHOW, $Form1) EndFunc ;==>Button1Click Func Form1Close() Exit 0 EndFunc ;==>Form1Close Edited July 2, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Kiti Posted July 2, 2008 Author Share Posted July 2, 2008 I've found modified an example found in another topic. The _StrAddSub Function is a real gold mine. It works with atomic precision!! SmOke_N , you're the man !!!expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <Date.au3> #include <date.au3> Global $bBreak $Form1 = GUICreate("Form1", 258, 119, 305, 210) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Input1 = GUICtrlCreateInput("0", 8, 48, 33, 21) $Input2 = GUICtrlCreateInput("0", 72, 48, 33, 21) $Input3 = GUICtrlCreateInput("0", 160, 48, 33, 21) $Label1 = GUICtrlCreateLabel("Avertizare peste:", 72, 16, 123, 24) GUICtrlSetFont($Label1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ok", 88, 88, 75, 25, 0) GUICtrlSetOnEvent($Button1, "Button1Click") $Label2 = GUICtrlCreateLabel("Ore", 48, 52, 21, 21) $Label3 = GUICtrlCreateLabel("Minute", 112, 52, 36, 21) $Label4 = GUICtrlCreateLabel("Secunde", 200, 52, 47, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Button1Click() GUISetState(@SW_HIDE) $h = GUICtrlRead($Input1) $m = GUICtrlRead($Input2) $s = GUICtrlRead($Input3) Local $StartTime = @HOUR & ":" & @MIN & ":" & @SEC If $bBreak Then Return $bBreak = Not $bBreak Local $sEndTime = $h & ":" & $m & ":" & $s Local $sTimeBack = _StrAddSub(@HOUR & ":" & @MIN & ":" & @SEC, $sEndTime) Local $sSubTimeDiff, $sHMS While $bBreak $sHMS = @HOUR & ":" & @MIN & ":" & @SEC $RunFor = _StrAddSub($sHMS, $StartTime, 0) $sSubTimeDiff = _StrAddSub($sTimeBack, $sHMS, 0) $pos = MouseGetPos() If $pos[0] = @DesktopWidth - 1 And $pos[1] = 0 Then ToolTip("Time remaining: " & $sSubTimeDiff & @CRLF & _ "Time that passed:" & $RunFor & @CRLF & _ "Time started: " & $StartTime & @CRLF & _ "Time end: " & $sTimeBack & @CRLF & _ "Duration: " & $sEndTime, 0, 0) Else ToolTip("") EndIf If $sHMS = $sTimeBack Then MsgBox(64, "", "Time's over!") GUISetState(@SW_SHOW) ExitLoop EndIf Sleep(1000) WEnd ToolTip("") $bBreak = False Return EndFunc ;==>Button1Click Func _StrAddSub($sTime1, $sTime2, $iAdd = 1, $sDelim = ':'); $iAdd = 1 Add, $iAdd = 0 Subtract Local $aSplit1 = StringSplit($sTime1, $sDelim), $iSubTotal = 0 Local $aSplit2 = StringSplit($sTime2, $sDelim) If $aSplit1[0] <> 3 Or $aSplit2[0] <> 3 Then Return SetError(0, 0, 0) Local $iTotal1 = ((Int($aSplit1[1]) * 3600) + (Int($aSplit1[2]) * 60) + (Int($aSplit1[3]))) Local $iTotal2 = ((Int($aSplit2[1]) * 3600) + (Int($aSplit2[2]) * 60) + (Int($aSplit2[3]))) If $iAdd Then $iSubTotal = $iTotal1 + $iTotal2 ElseIf $iTotal1 >= $iTotal2 Then $iSubTotal = $iTotal1 - $iTotal2 Else $iSubTotal = $iTotal2 - $iTotal1 EndIf Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Return StringFormat('%02d', $iHour) & $sDelim & StringFormat('%02d', $iMin) & $sDelim & StringFormat('%02d', $iSec) EndFunc ;==>_StrAddSub Func _ExitScript() Exit 1 EndFunc ;==>_ExitScript Func Form1Close() Exit 0 EndFunc ;==>Form1Close Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
GEOSoft Posted July 2, 2008 Share Posted July 2, 2008 Thats a very good function all right. I would have done it just slightly different though, to allow for regionalization. ; Func _StrAddSub($sTime1, $sTime2, $iAdd = 1, $sDelim = -1); $iAdd = 1 Add, $iAdd = 0 Subtract If $sDelim = -1 Then $sDelim = RegRead("HKCU\Control Panel\International", "sTime") Local $aSplit1 = StringSplit($sTime1, $sDelim), $iSubTotal = 0 Local $aSplit2 = StringSplit($sTime2, $sDelim) If $aSplit1[0] <> 3 Or $aSplit2[0] <> 3 Then Return SetError(0, 0, 0) Local $iTotal1 = ((Int($aSplit1[1]) * 3600) + (Int($aSplit1[2]) * 60) + (Int($aSplit1[3]))) Local $iTotal2 = ((Int($aSplit2[1]) * 3600) + (Int($aSplit2[2]) * 60) + (Int($aSplit2[3]))) If $iAdd Then $iSubTotal = $iTotal1 + $iTotal2 ElseIf $iTotal1 >= $iTotal2 Then $iSubTotal = $iTotal1 - $iTotal2 Else $iSubTotal = $iTotal2 - $iTotal1 EndIf Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Return StringFormat('%02d', $iHour) & $sDelim & StringFormat('%02d', $iMin) & $sDelim & StringFormat('%02d', $iSec) EndFunc ;==>_StrAddSub ; George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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