Jump to content

Recommended Posts

Posted (edited)

Hello everyone !

While writing a sample of code to test ping to my internet box, I got stuck..

While the code is Pinging with let say.. 5000ms of timeout, I need to update a progress bar from 0 to 5000 ms at the same time but I don't know how could I do this..

Is there a way or something that could get around the pause of the ping like in InetGet -> InetGetInfo?

Edited by hcI
Posted (edited)

I see what you mean, while its pinging there's nothing you can do... you could use a marquee right before you call the ping, and end it afterwards. This is the marquee udf you can find in the forum. Paste in a new au3 and run:

#include <ProgressConstants.au3>
Local $GMarquee, $Progress_1, $LabelP

$GMarquee = GUICreate("Working", 240, 70, -1, @DesktopHeight / 4)
$Progress_1 = GUICtrlCreateProgress(10, 10, 220, 20, 0x0008)
$LabelP = GUICtrlCreateLabel('Working...', 10, 40, 100)
GUISetState(@SW_SHOW)
_ProgressMarquee_Start($Progress_1) ;Start
MsgBox(64, '', '')
_ProgressMarquee_Stop($Progress_1) ;Stop
GUIDelete($GMarquee)

;#include <ProgressConstants.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: _ProgressMarquee_Start
; Description ...: Start the marquee effect.
; Syntax ........: _ProgressMarquee_Start($iControlID)
; Parameters ....: $iControlID          - ControlID of a progressbar using the $PBS_MARQUEE style.
; Return values .: Success - True
;                  Failure - False
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _ProgressMarquee_Start($iControlID)
    Return GUICtrlSendMsg($iControlID, $PBM_SETMARQUEE, True, 50)
EndFunc   ;==>_ProgressMarquee_Start

; #FUNCTION# ====================================================================================================================
; Name ..........: _ProgressMarquee_Stop
; Description ...:  Stop the marquee effect.
; Syntax ........: _ProgressMarquee_Stop($iControlID[, $iReset = 0])
; Parameters ....: $iControlID          - ControlID of a progressbar using the $PBS_MARQUEE style.
;                  $fReset              - [optional] Reset the progressbar, True - Reset or False - Don't reset. Default is False.
; Return values .: Success - True
;                  Failure - False
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _ProgressMarquee_Stop($iControlID, $fReset = False)
    Local $fReturn = GUICtrlSendMsg($iControlID, $PBM_SETMARQUEE, False, 50)
    If $fReturn And $fReset Then
        GUICtrlSetStyle($iControlID, $PBS_MARQUEE)
    EndIf
    Return $fReturn
EndFunc   ;==>_ProgressMarquee_Stop

 

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
  On 1/2/2018 at 2:24 AM, JLogan3o13 said:

@hcI have you looked in the help file? ProgressSet perhaps?

Expand  

I know this function but it don't help me in this case because the Ping function pause the whole script while the ping is sent.. So I can't refresh the progress bar during this time, even with ProgressSet.

  On 1/2/2018 at 12:56 PM, careca said:

I see what you mean, while its pinging there's nothing you can do... you could use a marquee right before you call the ping, and end it afterwards. This is the marquee udf you can find in the forum. Paste in a new au3 and run:

#include <ProgressConstants.au3>
Local $GMarquee, $Progress_1, $LabelP

$GMarquee = GUICreate("Working", 240, 70, -1, @DesktopHeight / 4)
$Progress_1 = GUICtrlCreateProgress(10, 10, 220, 20, 0x0008)
$LabelP = GUICtrlCreateLabel('Working...', 10, 40, 100)
GUISetState(@SW_SHOW)
_ProgressMarquee_Start($Progress_1) ;Start
MsgBox(64, '', '')
_ProgressMarquee_Stop($Progress_1) ;Stop
GUIDelete($GMarquee)

;#include <ProgressConstants.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: _ProgressMarquee_Start
; Description ...: Start the marquee effect.
; Syntax ........: _ProgressMarquee_Start($iControlID)
; Parameters ....: $iControlID          - ControlID of a progressbar using the $PBS_MARQUEE style.
; Return values .: Success - True
;                  Failure - False
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _ProgressMarquee_Start($iControlID)
    Return GUICtrlSendMsg($iControlID, $PBM_SETMARQUEE, True, 50)
EndFunc   ;==>_ProgressMarquee_Start

; #FUNCTION# ====================================================================================================================
; Name ..........: _ProgressMarquee_Stop
; Description ...:  Stop the marquee effect.
; Syntax ........: _ProgressMarquee_Stop($iControlID[, $iReset = 0])
; Parameters ....: $iControlID          - ControlID of a progressbar using the $PBS_MARQUEE style.
;                  $fReset              - [optional] Reset the progressbar, True - Reset or False - Don't reset. Default is False.
; Return values .: Success - True
;                  Failure - False
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _ProgressMarquee_Stop($iControlID, $fReset = False)
    Local $fReturn = GUICtrlSendMsg($iControlID, $PBM_SETMARQUEE, False, 50)
    If $fReturn And $fReset Then
        GUICtrlSetStyle($iControlID, $PBS_MARQUEE)
    EndIf
    Return $fReturn
EndFunc   ;==>_ProgressMarquee_Stop

 

Expand  

It's exactly the function needed to solve my problem ! Thanks !

And I wish you a happy new year to you all !

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