Jump to content

GUI Slider Help


CalBoy
 Share

Recommended Posts

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 :blink:.

;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 by CalBoy
Link to comment
Share on other sites

  • Moderators

CalBoy,

Welcome to the AutoIt forum. :blink:

Firs tthing - it is a Progress bar (as the GUICtrlCreateProgress suggests :P ), 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:

#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 >= 100

All clear? Please ask if not. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

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! :P

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. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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! :blink:

Thanks for all your help man

CalBoy

Link to comment
Share on other sites

  • Moderators

CalBoy,

do you know of a way to get the callbacks from wimgapi.dll or gimagex_com.dll

No, 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 completion

Take a look at this topic where I showed another member how to do just that. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...