Jump to content

[Solved] Loop while ping


hcI
 Share

Recommended Posts

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

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
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

On 02/01/2018 at 3:24 AM, JLogan3o13 said:

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

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 02/01/2018 at 1: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

 

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

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

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

×
×
  • Create New...