MasterMind Posted January 31, 2010 Share Posted January 31, 2010 Hello Dears,,, I'm new in this forum and I've started to use this fantastic script AutoIt to create my executables. Today and when I was learning about the creation of the timer, I copied the example in the help file for the command: _Timer_SetTimer I run the program and everything worked successfully until I minimized the program and then restore it back. I saw that the progress bar, which was located in the second part of the status bar, has been moved to the top left of the status bar (child window) I tried to know the issue, but unfortunately I couldn't find a solution and I was obliged to reset the position of the embedded progress bar after restoring the windows. Please let's us know what's the problem here knowing that the progress bar is automatically fittable inside the second part. Thanks,,, Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 31, 2010 Moderators Share Posted January 31, 2010 MasterMind,Welcome to the AutoIt forum. I would love to try and help, but could you please post your code because my crystal ball is a bit cloudy this evening! When you post your code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button.M23 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 Link to comment Share on other sites More sharing options...
MasterMind Posted January 31, 2010 Author Share Posted January 31, 2010 (edited) Ok, here below is the code owned by the AutoIt help file for the command _Timer_SetTimer expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <Timers.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> Opt("MustDeclareVars", 1) Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1 _Example_CallBack() Func _Example_CallBack() Local $hGUI, $iTimerProgress, $btn_change, $iWait = 10, $btn_state Local $aParts[3] = [75, 330, -1] $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") $btn_state = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25) $btn_change = GUICtrlCreateButton("Change", 215, 270, 90, 25) GUICtrlSetState($btn_change, $GUI_DISABLE) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts) _GUICtrlStatusBar_SetText($hStatusBar, "Timers") _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH) GUICtrlSetColor($progress, 0xff0000) _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) GUISetState() _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btn_state If GUICtrlRead($btn_state) = "Start Progress Bar" Then $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer If @error Or $iTimerProgress = 0 Then ContinueLoop GUICtrlSetData($btn_state, "Stop Progress Bar") GUICtrlSetState($btn_change, $GUI_ENABLE) Else GUICtrlSetState($btn_change, $GUI_DISABLE) _Timer_KillTimer($hGUI, $iTimerProgress) GUICtrlSetData($btn_state, "Start Progress Bar") EndIf Case $btn_change If $iWait = 10 Then $iWait = 250 Else $iWait = 10 EndIf MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds") $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval EndSwitch WEnd ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) GUIDelete() EndFunc ;==>_Example_CallBack ; call back function Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) EndFunc ;==>_UpdateStatusBarClock ; call back function Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime $percent += 5 * $direction GUICtrlSetData($progress, $percent) If $percent = 100 Or $percent = 0 Then $direction *= -1 If $percent = 100 Then GUICtrlSetColor($progress, 0xff0000) ElseIf $percent = 0 Then GUICtrlSetColor($progress, 0x0000ff) EndIf EndFunc ;==>_UpdateProgressBar ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Try it as it is, and minimize and then restore back the window. Let me know what will happen for the progress bar. Edited January 31, 2010 by MasterMind Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 31, 2010 Moderators Share Posted January 31, 2010 MasterMind,Apologies, I had not understood that it was the pure example code you were testing - put it down to age! Looks like you have found an obscure bug in the StatusBar UDF - congratulations. Whenever I have used a multipart statusbar everything has gone back into its proper place after being minimised.That means you have to go and post a bug report - do you know how?M23 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 Link to comment Share on other sites More sharing options...
MasterMind Posted January 31, 2010 Author Share Posted January 31, 2010 MasterMind,Apologies, I had not understood that it was the pure example code you were testing - put it down to age! Looks like you have found an obscure bug in the StatusBar UDF - congratulations. Whenever I have used a multipart statusbar everything has gone back into its proper place after being minimised.That means you have to go and post a bug report - do you know how?M23Melba,Don't apologize my dear !! . It happens ..I wouldn't want to say first it's a bug, but as we saw it together, then it's announced. And since I'm new to this forum, I'd like to help me to post this bug as I don't know how to do it.Thank you Link to comment Share on other sites More sharing options...
Bowmore Posted January 31, 2010 Share Posted January 31, 2010 You need to re-embed the progress bar when the gui is restored. I've modified your script to include this in the message loop expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <Timers.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> Opt("MustDeclareVars", 1) Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1 _Example_CallBack() Func _Example_CallBack() Local $hGUI, $iTimerProgress, $btn_change, $iWait = 10, $btn_state Local $aParts[3] = [75, 330, -1] $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") $btn_state = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25) $btn_change = GUICtrlCreateButton("Change", 215, 270, 90, 25) GUICtrlSetState($btn_change, $GUI_DISABLE) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts) _GUICtrlStatusBar_SetText($hStatusBar, "Timers") _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH) GUICtrlSetColor($progress, 0xff0000) _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) GUISetState() _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer While 1 Switch GUIGetMsg() Case $GUI_EVENT_RESTORE _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) Case $GUI_EVENT_CLOSE ExitLoop Case $btn_state If GUICtrlRead($btn_state) = "Start Progress Bar" Then $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer If @error Or $iTimerProgress = 0 Then ContinueLoop GUICtrlSetData($btn_state, "Stop Progress Bar") GUICtrlSetState($btn_change, $GUI_ENABLE) Else GUICtrlSetState($btn_change, $GUI_DISABLE) _Timer_KillTimer($hGUI, $iTimerProgress) GUICtrlSetData($btn_state, "Start Progress Bar") EndIf Case $btn_change If $iWait = 10 Then $iWait = 250 Else $iWait = 10 EndIf MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds") $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval EndSwitch WEnd ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) GUIDelete() EndFunc ;==>_Example_CallBack ; call back function Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) EndFunc ;==>_UpdateStatusBarClock ; call back function Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime $percent += 5 * $direction GUICtrlSetData($progress, $percent) If $percent = 100 Or $percent = 0 Then $direction *= -1 If $percent = 100 Then GUICtrlSetColor($progress, 0xff0000) ElseIf $percent = 0 Then GUICtrlSetColor($progress, 0x0000ff) EndIf EndFunc ;==>_UpdateProgressBar ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 31, 2010 Moderators Share Posted January 31, 2010 (edited) MasterMind,The problem is already reported here and it appears you have to re-embed the progress bar when you maximise again.M23Edit: Bowmore, thanks for your intervention. Where were you a few minutes ago! Edited January 31, 2010 by Melba23 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 Link to comment Share on other sites More sharing options...
MasterMind Posted January 31, 2010 Author Share Posted January 31, 2010 Guys !!Thanks for both of you and I know actually how to resolve it without re-embedding the control but by setting the position of the control, the width and height if those are not defined from the beginning for the control.What I meant is: since we are creating a control (and here the progress bar), then to avoid the issue, it's better to set the left, top, height and width for the control before embedding it inside the status bar since the latter is actually a child window.I'm trying to build a function that "Maintain" the position, width and height for the control and this function will be called directly by the _GUICtrlStatusBar_EmbedControl function. In that case, we will avoid the problem.Have you notice if you've used the size grip that also you have the same problem ?It's not only the minimize/restore issue. Also, if the type of the main window is of $WS_OVERLAPPEDWINDOW then also you will face the same issue.We need to find a better solution Link to comment Share on other sites More sharing options...
Bowmore Posted January 31, 2010 Share Posted January 31, 2010 (edited) A better solution - re-embed on receipt of WM_PAINT message expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <Timers.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> Opt("MustDeclareVars", 1) Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1 _Example_CallBack() Func _Example_CallBack() Local $hGUI, $iTimerProgress, $btn_change, $iWait = 10, $btn_state Local $aParts[3] = [75, 330, -1] $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") $btn_state = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25) $btn_change = GUICtrlCreateButton("Change", 215, 270, 90, 25) GUICtrlSetState($btn_change, $GUI_DISABLE) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts) _GUICtrlStatusBar_SetText($hStatusBar, "Timers") _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH) GUICtrlSetColor($progress, 0xff0000) _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) GUISetState() GUIRegisterMsg($WM_PAINT, "_WM_PAINT") _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btn_state If GUICtrlRead($btn_state) = "Start Progress Bar" Then $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer If @error Or $iTimerProgress = 0 Then ContinueLoop GUICtrlSetData($btn_state, "Stop Progress Bar") GUICtrlSetState($btn_change, $GUI_ENABLE) Else GUICtrlSetState($btn_change, $GUI_DISABLE) _Timer_KillTimer($hGUI, $iTimerProgress) GUICtrlSetData($btn_state, "Start Progress Bar") EndIf Case $btn_change If $iWait = 10 Then $iWait = 250 Else $iWait = 10 EndIf MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds") $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval EndSwitch WEnd ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) GUIDelete() EndFunc ;==>_Example_CallBack ; call back function Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2) EndFunc ;==>_UpdateStatusBarClock ; call back function Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDTimer, $dwTime $percent += 5 * $direction GUICtrlSetData($progress, $percent) If $percent = 100 Or $percent = 0 Then $direction *= -1 If $percent = 100 Then GUICtrlSetColor($progress, 0xff0000) ElseIf $percent = 0 Then GUICtrlSetColor($progress, 0x0000ff) EndIf EndFunc ;==>_UpdateProgressBar ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func _WM_PAINT($hWnd, $Msg) _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress)) Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT Edited January 31, 2010 by Bowmore Marcelos and jimmy123j 2 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
W2lkm2n Posted January 15, 2013 Share Posted January 15, 2013 Two years later, this helped me not pulling my hair out after two days of trouble with this ! Thanks ! Link to comment Share on other sites More sharing options...
guinness Posted January 15, 2013 Share Posted January 15, 2013 It's fantastic you searched the Forum, but refrain from bumping old topics if there is no necessity. Which generally there isn't. 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...
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