CalBoy Posted July 14, 2010 Share Posted July 14, 2010 (edited) I'm sorry if this is in the wrong forum but I need some help with a slider GUI. The script I'm using is based on another users script on these forums, I'm afraid I can't remember where I found it but thanks for it and all the credit goes to them. The GUI is part of a WinPE deployment and is at the end of the deployment phase where I use ImageX to apply the image. The slider is supposed to move along with the deployment as imagex deploys the image (obviously) and complete at the same time. At the current time however it freezes at times and does not update correctly :/ or finish. If anyone could look at the code and correct any errors I have made it would be greatly appreciated . expandcollapse popup;finds the boot letter $registry = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\","PEBootRamdiskSourceDrive") ;applies the wim $imagex = SHellExecute("imagex.exe","/apply " & $registry & "sources\install.wim 1 H:\",@ScriptDir) ;minimises the command window WinMinimizeAll() ;creates the slider GUIDelete() GUICreate("Slider Bar", 220, 100, (@DesktopWidth - 220) / 2, (@DesktopHeight - 100) / 2) $progress = GUICtrlCreateProgress(10, 10, 200, 20, $PBS_SMOOTH) GUISetState() $msg = GUIGetMsg() $button = GUICtrlCreateButton("Percentage", 80, 65, 65, 25) $labelprogress = GUICtrlCreateLabel(" Complete",70,40,100,15) GUICtrlSetLimit($progress,100,0) ;updates the slider as it goes Do $msg = GUIGetMsg() $Free = DriveSpaceFree("H:\") $total = DriveSpaceTotal("H:\") $taken = $total - $Free ;based on the total size of the wim which is 15802 $Percentage = Round($taken / (15802 / 100), 0) GUICtrlSetData($progress, $Percentage) GUICtrlSetData($labelprogress,$Percentage & "% Completed") Sleep(50) If $msg = $button Then MsgBox(64, "Percentage", $Percentage & "% Completed", 3) Else EndIF GUISetState() Until $percentage = 100 Sorry if I haven't explained it very well. Once again any help is greatly appreciated. CalBoy Edited July 14, 2010 by CalBoy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2010 Moderators Share Posted July 14, 2010 CalBoy,Welcome to the AutoIt forum. Firs tthing - it is a Progress bar (as the GUICtrlCreateProgress suggests ), not a Slider which is something the user moves with the mouse.Anyway, I have played with the script a bit and this now works fine for me - look for the <<<<<<<<<<<<<<<< lines:expandcollapse popup#include <ProgressConstants.au3> ; You need it, but I am sure you had it! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;finds the boot letter ;$registry = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\", "PEBootRamdiskSourceDrive") ;applies the wim ;$imagex = ShellExecute("imagex.exe", "/apply " & $registry & "sources\install.wim 1 H:\", @ScriptDir) ;minimises the command window ;WinMinimizeAll() ;creates the slider ;GUIDelete() ; Why? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICreate("Progress Bar", 220, 100, (@DesktopWidth - 220) / 2, (@DesktopHeight - 100) / 2) $progress = GUICtrlCreateProgress(10, 10, 200, 20, $PBS_SMOOTH) ;$msg = GUIGetMsg() ; Serves no purpose here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $button = GUICtrlCreateButton("Percentage", 80, 65, 65, 25) $labelprogress = GUICtrlCreateLabel(" Complete", 70, 40, 100, 15) ;GUICtrlSetLimit($progress, 100, 0) ; Default settings <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() ; Moved to here after all controls hve been created <<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;updates the progress as it goes $Free = 100 ; So I have something that changes <<<<<<<<<<<<<<<<<<<< Do ; Look for the button in this section $msg = GUIGetMsg() If $msg = $button Then MsgBox(64, "Percentage", $Percentage & "% Completed", 3) EndIf ; Update the progress in this section $Free -= 1 ; = DriveSpaceFree("H:\") ; Just for this demo <<<<<<<<<<<<<<<<<<<<< $total = 100 ; DriveSpaceTotal("H:\") ; Just for this demo <<<<<<<<<<<<<<<<<<<<< $taken = $total - $Free ;based on the total size of the wim which is 15802 $Percentage = $taken ; Round($taken / (15802 / 100), 0) ; Just for this demo <<<<<<<<<<<<<<<<<<<<< GUICtrlSetData($progress, $Percentage + 1) ; A little trick if you use Vista! <<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetData($progress, $Percentage) GUICtrlSetData($labelprogress, $Percentage & "% Completed") Sleep(50) ;GUISetState() ; Serves no purpose here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Until $Percentage >= 100All clear? Please ask if not. 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...
CalBoy Posted July 14, 2010 Author Share Posted July 14, 2010 You kind sir are awesome! Thanks for the fast reply, very much appreciated. I have no idea why I said slider, shouldn't post late at night I guess. I will test tomorrow afternoon as I do not have the WIM file at the moment. I use GUIDelete() right at the start of the script to delete a previous part of the GUI, not a very good way to do it but it does the trick. One question however, the little Vista trick that you wrote down. I don't exactly see what that would have to do with the way that the progress bar would update, if I were to be adding 1 onto the progress every time wouldn't the progress bar finish before the WIM had finished applying? Sorry if I am looking at it incorrectly. It would be greatly appreciated if you could explain a little bit more what you are trying to show me there. Otherwise once that part of the script is compiled and completed my entire custom Windows 7 deployment is completed with the end of the GUI and the boot WIM and is ready to start being used. Very happy. Thanks once again CalBoy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2010 Moderators Share Posted July 14, 2010 CalBoy,if I were to be adding 1 onto the progress every time wouldn't the progress bar finish before the WIM had finished applying?Note that I immediately set the correct value in the next line! Vista progress bars are strange beasts and for some reason lag quite a lot when you update them. So you often get the action completed while the progress bar is still showing some way to go. Someone else on the forum came up with the little trick of oversetting and then correctly setting the progress bar a while ago and now I use it all the time.It seems to have no detrimental effect on earlier OSs - as you are playing with Win7 could you please try both with and without the extra line to se if there is any difference there?Thanks in advance. 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...
CalBoy Posted July 15, 2010 Author Share Posted July 15, 2010 Interesting! Your little + 1 trick actually helped quite a bit even on Windows 7 I will make sure to use that in the future! I might have to include a quick sleep function though as I don't want the computer restarting before imagex is completely finished. While I have you (sorry to ask another question) do you know of a way to get the callbacks from wimgapi.dll or gimagex_com.dll? I would much rather image using one of those two and get the percentage through the callbacks, that way I could be 100% sure that the wim has finished applying, plus I wouldn't have a messy CMD window open. If not would there be a way for AutoIT to look at the current CMD window to get the % of completion? The thought just occurred to me today! Thanks for all your help man CalBoy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2010 Moderators Share Posted July 15, 2010 CalBoy, do you know of a way to get the callbacks from wimgapi.dll or gimagex_com.dllNo, but if you open a new topic you may find someone who does. a way for AutoIT to look at the current CMD window to get the % of completionTake a look at this topic where I showed another member how to do just that. 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...
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