guinness Posted August 21, 2016 Posted August 21, 2016 What does -3 mean? 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
AutoBert Posted August 21, 2016 Posted August 21, 2016 1 hour ago, guinness said: What does -3 mean? It's the magic number for $Gui_EVENT_CLOSE
wasd-w Posted August 21, 2016 Author Posted August 21, 2016 4 hours ago, AutoBert said: add #include <Date.au3> this is needed while using _TicksToTime and While 1 If GUIGetMsg()=-3 Then Exit WEnd is needed that GUI stays alive. After this changess it's a runable script with no issues: I know, how to set the timer ? For example 00:02:44?
SadBunny Posted August 21, 2016 Posted August 21, 2016 Just add the required amount of milliseconds to the return value of TimerDiff(). HotKeySet("{ESC}", "quitter") $timer = TimerInit() While True Sleep(100) ConsoleWrite(TimerDiff($timer) + 10000 & @CRLF) WEnd Func quitter() Exit EndFunc ;==>quitter Roses are FF0000, violets are 0000FF... All my base are belong to you.
wasd-w Posted August 21, 2016 Author Posted August 21, 2016 31 minutes ago, SadBunny said: EndFunc ;==>quitter 34 minutes ago, SadBunny said: Just add the required amount of milliseconds to the return value of TimerDiff(). HotKeySet("{ESC}", "quitter") $timer = TimerInit() While True Sleep(100) ConsoleWrite(TimerDiff($timer) + 10000 & @CRLF) WEnd Func quitter() Exit EndFunc ;==>quitter No, how to set the timer value of for example 2:33.(sorry for my English)
Gianni Posted August 21, 2016 Posted August 21, 2016 ... I think OP needs to set the starting time (instead of just starting from 00:00:00) You could set a time offset equal to your wanted start time and then add it to the actual calculated TimerDiff() maybe something like this?: #include <GUIConstants.au3> #include <WinAPI.au3> #include <Timers.au3> #include <Date.au3> Global $TimeLabel Global $timer Global $Secs Global $Mins Global $Hour Global $Time Global $iMyStartTime = _TimeToTicks(02, 33, 00) ; <--- set your wanted start time here (hh,mm,ss) $ParentWindow = GUICreate('MyGUI', 400, 400) $timer = TimerInit() AdlibRegister("Timer", 50) $TimeLabel = _WinAPI_CreateWindowEx(0, 'Static', '', BitOR($WS_CHILD, $WS_VISIBLE), 5, 228, 100, 14, $ParentWindow) GUISetState() Func Timer() _TicksToTime($iMyStartTime + Int(TimerDiff($timer)), $Hour, $Mins, $Secs) ; <--- add your start time offset to TimerDiff() $Time = StringFormat("Time: " & "%02i:%02i:%02i", $Hour, $Mins, $Secs) _WinAPI_SetWindowText($TimeLabel, $Time) EndFunc ;==>Timer Do Until GUIGetMsg() = -3 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Moderators Melba23 Posted August 21, 2016 Moderators Posted August 21, 2016 wasd-w, Perhaps this? expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <UpDownConstants.au3> Global $iReqMin = 99, $iLastSec = 99 $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("Min:", 10, 10, 50, 20) $cInputMin = GUICtrlCreateInput("0", 70, 10, 80, 20) GUICtrlCreateUpdown($cInputMin, $UDS_WRAP) GUICtrlSetLimit(-1, 10, 0) GUICtrlCreateLabel("Sec:", 10, 50, 50, 20) $cInputSec = GUICtrlCreateInput("0", 70, 50, 80, 20) GUICtrlCreateUpdown($cInputSec, $UDS_WRAP) GUICtrlSetLimit(-1, 59, 0) $cStartTimer = GUICtrlCreateButton("Start", 10, 200, 80, 30) $cStopTimer = GUICtrlCreateButton("Stop", 10, 250, 80, 30) GUICtrlSetState($cStopTimer, $GUI_DISABLE) $cLabelTimer = GUICtrlCreateLabel("00:00", 10, 300, 200, 50) GUICtrlSetFont($cLabelTimer, 18) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cStartTimer GUICtrlSetState($cStartTimer, $GUI_DISABLE) GUICtrlSetState($cStopTimer, $GUI_ENABLE) $iReqMin = GUICtrlRead($cInputMin) $iReqSec = GUICtrlRead($cInputSec) GUICtrlSetData($cLabelTimer, StringFormat("%02i", $iReqMin) & ":" & StringFormat("%02i", $iReqSec)) GUICtrlSetData($cInputMin, "0") GUICtrlSetData($cInputSec, "0") Case $cStopTimer GUICtrlSetState($cStartTimer, $GUI_ENABLE) GUICtrlSetState($cStopTimer, $GUI_DISABLE) $iReqMin = 99 $iLastSec = 99 GUICtrlSetData($cLabelTimer, "00:00") EndSwitch If $iReqMin <> 99 And @SEC <> $iLastSec Then $iReqSec -= 1 If $iReqSec = -1 Then $iReqMin -= 1 $iReqSec = 59 EndIf GUICtrlSetData($cLabelTimer, StringFormat("%02i", $iReqMin) & ":" & StringFormat("%02i", $iReqSec)) If $iReqMin + $iReqSec = 0 Then MsgBox($MB_SYSTEMMODAL, "Timer", "Ring, ring!") GUICtrlSetState($cStartTimer, $GUI_ENABLE) $iReqMin = 99 EndIf $iLastSec = @SEC EndIf WEnd M23 P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders what they wrote and it just pads the thread unnecessarily. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
wasd-w Posted August 21, 2016 Author Posted August 21, 2016 2 hours ago, Chimp said: ... I think OP needs to set the starting time (instead of just starting from 00:00:00) You could set a time offset equal to your wanted start time and then add it to the actual calculated TimerDiff() maybe something like this?: #include <GUIConstants.au3> #include <WinAPI.au3> #include <Timers.au3> #include <Date.au3> Global $TimeLabel Global $timer Global $Secs Global $Mins Global $Hour Global $Time Global $iMyStartTime = _TimeToTicks(02, 33, 00) ; <--- set your wanted start time here (hh,mm,ss) $ParentWindow = GUICreate('MyGUI', 400, 400) $timer = TimerInit() AdlibRegister("Timer", 50) $TimeLabel = _WinAPI_CreateWindowEx(0, 'Static', '', BitOR($WS_CHILD, $WS_VISIBLE), 5, 228, 100, 14, $ParentWindow) GUISetState() Func Timer() _TicksToTime($iMyStartTime + Int(TimerDiff($timer)), $Hour, $Mins, $Secs) ; <--- add your start time offset to TimerDiff() $Time = StringFormat("Time: " & "%02i:%02i:%02i", $Hour, $Mins, $Secs) _WinAPI_SetWindowText($TimeLabel, $Time) EndFunc ;==>Timer Do Until GUIGetMsg() = -3 Tnx)
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