Jump to content
max23ed

Progress bar fills multiple times

Recommended Posts

This is the code but i'm getting it to work for one progress bar fill. How can i check if the progress bar completely finished filled x amount of times.

While _SendMessage($hWnd_Progress,$PBM_GETPOS,0,0) < 100
Sleep(500)
WEnd

 The progress bar is from a setup which for some reason needs to fill multiple times. I need to pause the script until the progress bar is done.

Any ideas. Thanks

Share this post


Link to post
Share on other sites

Maybe something like this?

$prev = 0
$value = 0
$cycle = 1
$cycle_max = 3

While $value < 100
    $value = _SendMessage($hWnd_Progress,$PBM_GETPOS,0,0) 
    If $value < $prev Then
        $prev = 0
        ; $value = 0
        $cycle += 1
    EndIf
    If $value <> $prev Then $prev = $value
    If $cycle = $cycle_max Then ... ; pause?
    Sleep(500)
WEnd

 

Edited by Zedna

Share this post


Link to post
Share on other sites

Thanks for the reply Zenda,

This is complicated for me 

i'm checking all the controls on the setup window 

this is the function 

Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
local $found = 0
If Not IsHWnd($hCallersWindow) Then
 ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF)
Return False
 EndIf
If $bOnlyVisible = Default Then $bOnlyVisible = False
If $sStringIncludes = Default Then $sStringIncludes = ""
If $sClass = Default Then $sClass = ""
$sClassList = WinGetClassList($hCallersWindow)
$aClassList = StringSplit($sClassList, @CRLF, 2)
_ArraySort($aClassList)
_ArrayDelete($aClassList, 0)
$iCurrentClass = ""
$iCurrentCount = 1
$iTotalCounter = 1
 If StringLen($sClass)>0 Then
For $i = UBound($aClassList)-1 To 0 Step - 1
If $aClassList[$i]<>$sClass Then
 _ArrayDelete($aClassList,$i)
 EndIf
Next
EndIf
 For $i = 0 To UBound($aClassList) - 1
If $aClassList[$i] = $iCurrentClass Then
 $iCurrentCount += 1
 Else
$iCurrentClass = $aClassList[$i]
$iCurrentCount = 1
 EndIf
$hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
$text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
$aPos = ControlGetPos($hCallersWindow, "", $hControl)
 $sControlID = _WinAPI_GetDlgCtrlID($hControl)
 $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
If $bOnlyVisible And Not $bIsVisible Then
$iTotalCounter += 1
ContinueLoop
EndIf
$found = 0
$a = $iCurrentClass & $iCurrentCount
If StringInStr($a, "ComboBox") And $bIsVisible Then
$found = 1
Sleep(3000)
ExitLoop
else
If StringInStr($a, "Button") And $bIsVisible Then
$found = 1
Sleep(3000)
ExitLoop
else
if StringInStr($a,"msctls_progress321") And $bIsVisible Then
$found = 1
$progressIsnotVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
$hWnd_Progress = ControlGetHandle("[Active]","",$a)
 $prev = 0
$value = 0
$cycle = 1
$cycle_max = 3

While $value < 100
    $value = _SendMessage($hWnd_Progress,$PBM_GETPOS,0,0) < 100
    If $value < $prev Then
        $prev = 0
        ; $value = 0
        $cycle += 1
    EndIf
    If $value <> $prev Then $prev = $value
    If $cycle = $cycle_max Then  ; pause?
    Sleep(500)
    EndIf
WEnd
ExitLoop
Else
Sleep(1000)
EndIf
EndIf
EndIf
EndIf
EndIf

 If Not WinExists($hCallersWindow) Then ExitLoop
$iTotalCounter += 1
Next
If $found = 1 Then
$found = 0
Return true
EndIf
EndFunc

 Then before each mouseclick i do somthing like this to check if anything visible at all in the setup especially the progress bar 😠

do
 Sleep(500)
  until GetAllWindowsControls(WinGetHandle('[ACTIVE]')) = true
MouseClick("left",146,128,1)

Any help on how i can achieve this.  

Share this post


Link to post
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

×
×
  • Create New...