CemalSenturk Posted January 16, 2015 Share Posted January 16, 2015 (edited) expandcollapse popup#include <IE.au3> Global $goIE = 0 Global $gsURL = "http://www.car.gr/classifieds/tractors/edit/5934677/#details" Global $gsPassword = "---" _Login($goIE, $gsPassword, $gsURL) If @error Then Exit @error + _IEQuit($goIE) - 1 EndIf ; submit the form _mySubmitSavePage($goIE) Func _mySubmitSavePage(ByRef $oObj) Exit @error + _IEQuit($goIE) - 1 If Not IsObj($oObj) Then Return SetError(1, 0, 0) EndIf Local $aoForm = _IEJS_GetObjByClassArray($oObj, "form-horizontal", "form") If Not IsArray($aoForm) Then Return SetError(2, 0, 0) EndIf Local $oForm = $aoForm[0] ; get the form from the array _IEFormSubmit($oForm) If @error Then Return SetError(3, 0, 0) EndIf ; wait for rendering to start Sleep(2000) ; wait for page to load _IELoadWait($oObj) If @error Then Return SetError(4, 0, 0) EndIf Return 1 EndFunc Func _Login(ByRef $oObj, $sPassword, $sURL) If Not IsObj($oObj) Then $oObj = _IECreate($sURL) If Not IsObj($oObj) Then Return SetError(1, 0, 0) EndIf _IELoadWait($oObj) EndIf Local $aoForm = _IEJS_GetObjByClassArray($oObj, "form-horizontal", "form") If Not IsArray($aoForm) Then Return SetError(2, 0, 0) EndIf Local $oForm = $aoForm[0] ; get the form from the array Local $oPass = _IEGetObjByName($oForm, "password", 0); first instance only If Not IsObj($oPass) Then Return SetError(3, 0, 0) EndIf _IEFormElementSetValue($oPass, $gsPassword) ; login _IEFormSubmit($oForm) If @error Then Return SetError(4, 0, 0) EndIf ; wait for rendering to start Sleep(2000) ; wait for page to load _IELoadWait($oObj) If @error Then Return SetError(5, 0, 0) EndIf Return 1 EndFunc Func _IEJS_GetObjByClassArray(ByRef $oObj, $sClass, $sTag = Default, $iIndex = -1) ; returns an array of objects If Not IsObj($oObj) Then Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf $iIndex = (IsKeyword($iIndex) Or $iIndex < 0) ? -1 : $iIndex $sTag = (IsKeyword($sTag) Or Not StringLen($sTag)) ? "" : $sTag Local $oTags = (StringLen($sTag)) ? _IETagNameGetCollection($oObj, $sTag, $iIndex) : _ _IETagNameAllGetCollection($oObj, $iIndex) Local $iExtended = @extended If Not IsObj($oTags) Then Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Local $aRet[$iExtended], $iCount If $iIndex = -1 Then For $oTag In $oTags If String($oTag.classname) = $sClass Then $aRet[$iCount] = $oTag $iCount += 1 EndIf Next Else $aRet[$iCount] = $oTags.index($iIndex) If Not IsObj($aRet[$iCount]) Then Return SetError($_IESTATUS_InvalidValue, 3, 0) EndIf $iCount += 1 EndIf If Not $iCount Then Return SetError($_IESTATUS_NoMatch, 4, 0) EndIf ReDim $aRet[$iCount] Return SetError($_IESTATUS_Success, 1, $aRet) EndFunc _IEQuit($goIE) Here is my (actualy not mine is SmOke_N's code) skalistir.au3 code. When I click this au3 script just logins to the page and nothing. But If I re-open it then finds the button and click it. All of the commands I use is inside run.au3 (here): ConsoleWrite(@ScriptDir & @CRLF) _RunAU3("skalistir.au3") _RunAU3("skalistir.au3") _RunAU3("spastrakuc.au3") _RunAU3("spastrakuc.au3") _RunAU3("spastrabuy.au3") _RunAU3("spastrabuy.au3") _RunAU3("spastraele.au3") _RunAU3("spastraele.au3") Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0) ConsoleWrite(FileExists($sFilePath) & @TAB & '"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"' & @CRLF) $iReturn = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag) Sleep(3500) Return $iReturn EndFunc But after the job finished 4 of the Internet Explorer page stands and I want to close them automatically. Any Ideas how to ? Edited January 16, 2015 by CemalSenturk Link to comment Share on other sites More sharing options...
JohnOne Posted January 16, 2015 Share Posted January 16, 2015 WinClose AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
CemalSenturk Posted January 16, 2015 Author Share Posted January 16, 2015 I know you are professionals and you are hating members like me but I don't know how to exactly use that. Can you please help me to where to put that code? Thanks a lot Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 16, 2015 Moderators Share Posted January 16, 2015 (edited) Look in the help file under WinClose. There are examples there for a reason. Edited January 16, 2015 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
CemalSenturk Posted January 16, 2015 Author Share Posted January 16, 2015 (edited) Yes I see but I can't figure out where to put that code Edited January 16, 2015 by CemalSenturk Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 16, 2015 Moderators Share Posted January 16, 2015 You put it at the point in your script where you want to close the windows. Only you know where you want that to happen. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 16, 2015 Moderators Share Posted January 16, 2015 (edited) Wow, that code is nearly 100% me! lmao... Put _IEQuit($goIE) after _mySubmitSavePage($goIE) Edit: And change this: ConsoleWrite(@ScriptDir & @CRLF) _RunAU3("skalistir.au3") _RunAU3("skalistir.au3") _RunAU3("spastrakuc.au3") _RunAU3("spastrakuc.au3") _RunAU3("spastrabuy.au3") _RunAU3("spastrabuy.au3") _RunAU3("spastraele.au3") _RunAU3("spastraele.au3") Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0) ConsoleWrite(FileExists($sFilePath) & @TAB & '"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"' & @CRLF) $iReturn = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag) Sleep(3500) Return $iReturn EndFunc To this: ProcessWaitClose(_RunAU3("skalistir.au3")) ProcessWaitClose(_RunAU3("skalistir.au3")) ProcessWaitClose(_RunAU3("spastrakuc.au3")) ProcessWaitClose(_RunAU3("spastrakuc.au3")) ProcessWaitClose(_RunAU3("spastrabuy.au3")) ProcessWaitClose(_RunAU3("spastrabuy.au3")) ProcessWaitClose(_RunAU3("spastraele.au3")) ProcessWaitClose(_RunAU3("spastraele.au3")) Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0) Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag) EndFunc Edited January 16, 2015 by SmOke_N CemalSenturk 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
CemalSenturk Posted January 16, 2015 Author Share Posted January 16, 2015 Oh man you are genious! Thank you but here is a problem. _Login($goIE, $gsPassword, $gsURL) If @error Then Exit @error + _IEQuit($goIE) - 1 EndIf ; submit the form _mySubmitSavePage($goIE) _IEQuit($goIE) Func _mySubmitSavePage(ByRef $oObj) Here is the code I put it at 14th line but as I said when I first run the code skalistir.au3. After the line 13rd script pauses. At second try, creates a new page but do not asks for password or username, directly finds the button and clicks on it. This is why I use two _RunAU3 instead of one Can we fix it? I tried your last code and stuck at first line of run.au3 script Can't create a new page and waits for proccess to close. My idea is Run all of them wıth 3.5 sec delay and after it force to close iexplore.exe. Is it possible ? How? Thanks.. Link to comment Share on other sites More sharing options...
Moderators Solution SmOke_N Posted January 16, 2015 Moderators Solution Share Posted January 16, 2015 Turn your cache off (or Clear cache upon exit within your Internet Explorer -> Tools -> Internet Options -> Advanced Tab -> Security: Empty Temporary Internet Files folder when browser is closed -> Click OK). Your setup is a hot mess. I would just use one script to do it all. expandcollapse popup#include <IE.au3> Global $goIE = 0 Global $gaURLs[4] $gaURLs[0] = "http://www.car.gr/classifieds/tractors/edit/5934677/#details" $gaURLs[1] = "URL2" ; <--- Put your other URLs in these spots $gaURLs[2] = "URL3" $gaURLs[3] = "URL4" Global $gsPassword = "---" For $i = 0 To UBound($gaURLs) - 1 _Login($goIE, $gsPassword, $gaURLs[$i]) If @error Then Exit @error + _IEQuit($goIE) - 1 EndIf ; submit the form _mySubmitSavePage($goIE) Next _IEQuit($goIE) Func _mySubmitSavePage(ByRef $oObj) If Not IsObj($oObj) Then Return SetError(1, 0, 0) EndIf Local $aoForm = _IEJS_GetObjByClassArray($oObj, "form-horizontal", "form") If Not IsArray($aoForm) Then Return SetError(2, 0, 0) EndIf Local $oForm = $aoForm[0] ; get the form from the array _IEFormSubmit($oForm) If @error Then Return SetError(3, 0, 0) EndIf ; wait for rendering to start Sleep(2000) ; wait for page to load _IELoadWait($oObj) If @error Then Return SetError(4, 0, 0) EndIf Return 1 EndFunc Func _Login(ByRef $oObj, $sPassword, $sURL) If Not IsObj($oObj) Then $oObj = _IECreate() If Not IsObj($oObj) Then Return SetError(1, 0, 0) EndIf _IELoadWait($oObj) EndIf _IENavigate($oObj, $sURL) _IELoadWait($oObj) Local $aoForm = _IEJS_GetObjByClassArray($oObj, "form-horizontal", "form") If Not IsArray($aoForm) Then Return SetError(2, 0, 0) EndIf Local $oForm = $aoForm[0] ; get the form from the array Local $oPass = _IEGetObjByName($oForm, "password", 0); first instance only If Not IsObj($oPass) Then Return SetError(3, 0, 0) EndIf _IEFormElementSetValue($oPass, $gsPassword) ; login _IEFormSubmit($oForm) If @error Then Return SetError(4, 0, 0) EndIf ; wait for rendering to start Sleep(2000) ; wait for page to load _IELoadWait($oObj) If @error Then Return SetError(5, 0, 0) EndIf Return 1 EndFunc Func _IEJS_GetObjByClassArray(ByRef $oObj, $sClass, $sTag = Default, $iIndex = -1) ; returns an array of objects If Not IsObj($oObj) Then Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf $iIndex = (IsKeyword($iIndex) Or $iIndex < 0) ? -1 : $iIndex $sTag = (IsKeyword($sTag) Or Not StringLen($sTag)) ? "" : $sTag Local $oTags = (StringLen($sTag)) ? _IETagNameGetCollection($oObj, $sTag, $iIndex) : _ _IETagNameAllGetCollection($oObj, $iIndex) Local $iExtended = @extended If Not IsObj($oTags) Then Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Local $aRet[$iExtended], $iCount If $iIndex = -1 Then For $oTag In $oTags If String($oTag.classname) = $sClass Then $aRet[$iCount] = $oTag $iCount += 1 EndIf Next Else $aRet[$iCount] = $oTags.index($iIndex) If Not IsObj($aRet[$iCount]) Then Return SetError($_IESTATUS_InvalidValue, 3, 0) EndIf $iCount += 1 EndIf If Not $iCount Then Return SetError($_IESTATUS_NoMatch, 4, 0) EndIf ReDim $aRet[$iCount] Return SetError($_IESTATUS_Success, 1, $aRet) EndFunc . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
CemalSenturk Posted January 17, 2015 Author Share Posted January 17, 2015 I turned my cache off but nothing changed. I will use your old code. Closing 4 browsers won't kill me Thank you again. 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