youtuber Posted October 12, 2017 Share Posted October 12, 2017 Hi, progress is not working while receiving data What should I do to progress step by step in the Progress? expandcollapse popup#include <String.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $sList = "https://www.autoitscript.com/forum/topic/34658-are-my-autoit-exes-really-infected/" & @crlf & _ "https://www.autoitscript.com/forum/topic/148023-amending-the-faq-in-the-help-file/" $Form1 = GUICreate("Form1", 314, 424, 327, 136) $Edit1 = GUICtrlCreateEdit("", 16, 40, 281, 313) GUICtrlSetData($Edit1, $sList) $CheckData = GUICtrlCreateButton("Check Data", 16, 376, 107, 25) GUICtrlSetState($CheckData,$GUI_FOCUS) $Progress1 = GUICtrlCreateProgress(152, 376, 142, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $CheckData GUICtrlSetData($progress1, "") Local $aEditread = StringSplit(GUICtrlRead($Edit1), @CRLF, 1) Local $aData, $string ,$progress For $i = 1 To $aEditread[0] $string = Connections($aEditread[$i]) $progress = 100 / $string GUICtrlSetData($progress1, $progress * $i) If @error Then ExitLoop EndIf $string = StringRegExpReplace($string, '(?s)[\n\r\t\v]', '') $string = StringStripWS($string, 7) $aData = _StringBetween($string, 'lightboxedImages">', '</div>') For $j = 0 To UBound($aData) - 1 ConsoleWrite($aData[$j] & @CRLF) Next Next EndSwitch WEnd Func Connections($address) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $address, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0") $oHTTP.SetRequestHeader("Accept", "*/*") $oHTTP.SetRequestHeader("Accept-Language", "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3") $oHTTP.Send() If @error Then ConsoleWrite("Error connection") $oHTTP = 0 Return SetError(1) EndIf If $oHTTP.Status = 200 Then Local $sReceived = $oHTTP.ResponseText $oHTTP = Null Return $sReceived EndIf $oHTTP = Null Return -1 EndFunc Link to comment Share on other sites More sharing options...
youtuber Posted October 13, 2017 Author Share Posted October 13, 2017 I think it's actually I am not sure Case $CheckData GUICtrlSetData($progress1, "") Local $aEditread = StringSplit(GUICtrlRead($Edit1), @CRLF, 1) Local $aData, $string ,$progress For $i = 1 To $aEditread[0] $string = Connections($aEditread[$i]) $progress = $i / $string GUICtrlSetData($progress1, $progress * $i) If @error Then ExitLoop EndIf $string = StringRegExpReplace($string, '(?s)[\n\r\t\v]', '') $string = StringStripWS($string, 7) $aData = _StringBetween($string, 'lightboxedImages">', '</div>') For $j = 0 To UBound($aData) - 1 ConsoleWrite($aData[$j] & @CRLF) Next Next GUICtrlSetData($progress1, 100) EndSwitch Link to comment Share on other sites More sharing options...
kylomas Posted October 13, 2017 Share Posted October 13, 2017 youtuber, If you are trying to determine the progress of entries read from the edit control then try this... expandcollapse popup#include <String.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <array.au3> $sList = "https://www.autoitscript.com/forum/topic/34658-are-my-autoit-exes-really-infected/" & @crlf & _ "https://www.autoitscript.com/forum/topic/148023-amending-the-faq-in-the-help-file/" $Form1 = GUICreate("Form1", 314, 424, 327, 136) $Edit1 = GUICtrlCreateEdit("", 16, 40, 281, 313) GUICtrlSetData($Edit1, $sList) $CheckData = GUICtrlCreateButton("Check Data", 16, 376, 107, 25) GUICtrlSetState($CheckData,$GUI_FOCUS) $Progress1 = GUICtrlCreateProgress(152, 376, 142, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $CheckData GUICtrlSetData($progress1, "") Local $aEditread = StringSplit(GUICtrlRead($Edit1), @CRLF, 1) Local $aData, $string ,$progress For $i = 1 To $aEditread[0] $string = Connections($aEditread[$i]) $progress = ($i / $aEditread[0]) * 100 ; (partial / total) * 100 GUICtrlSetData($progress1, $progress) If @error Then ExitLoop EndIf $string = StringRegExpReplace($string, '(?s)[\n\r\t\v]', '') $string = StringStripWS($string, 7) $aData = _StringBetween($string, 'lightboxedImages">', '</div>') For $j = 0 To UBound($aData) - 1 ConsoleWrite($aData[$j] & @CRLF) Next Next EndSwitch WEnd Func Connections($address) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $address, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0") $oHTTP.SetRequestHeader("Accept", "*/*") $oHTTP.SetRequestHeader("Accept-Language", "tr-TR,tr;q=0.8,en-US;q=0.5,en;q=0.3") $oHTTP.Send() If @error Then ConsoleWrite("Error connection") $oHTTP = 0 Return SetError(1) EndIf If $oHTTP.Status = 200 Then Local $sReceived = $oHTTP.ResponseText $oHTTP = Null Return $sReceived EndIf $oHTTP = Null Return -1 EndFunc kylomas youtuber 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ripdad Posted October 13, 2017 Share Posted October 13, 2017 youtuber, You have to move @error statement for Connections(). Otherwise, it's not very useful where it is. Like this... For $i = 1 To $aEditread[0] $string = Connections($aEditread[$i]) If @error Then ExitLoop EndIf youtuber 1 "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward 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