Jump to content
AlienStar

_IECreate($url) opens a blank page !!

Recommended Posts

AlienStar
Posted (edited)

hello everybody 

I make a script to auto publish posts on wordpress blog

firstly the script works fine but suddenly the function 

Local $oIE =_IECreate($url)

opened a blank web page instead of my url , and up to now the problem is found 

with this error :

--> IE.au3 T3.0-1 Error from function _IENavigate, $_IESTATUS_COMError (-2147352567)

please help me 

 

Edited by AlienStar

Share this post


Link to post
Share on other sites
Danp2

Looks like you are running an older version of Autoit. What version are you running? Can you try updating to the latest version?

Share this post


Link to post
Share on other sites
AlienStar

I use v3.3.12.0

Share this post


Link to post
Share on other sites
AlienStar

I've updated to the latest version then it sends me this error 

"C:\Program Files (x86)\AutoIt3\Include\IE.au3" (272) : ==> The requested action with this object has failed.:
$oObject.navigate($sUrl)
$oObject^ ERROR
->00:52:31 AutoIt3.exe ended.rc:1
+>00:52:31 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 6.098


 

Share this post


Link to post
Share on other sites
Danp2

Please show us your code or at least a reproducer script so that we can get a better understanding of why this is occurring.

Share this post


Link to post
Share on other sites
AlienStar
Posted (edited)

here is my full code 

#include <IE.au3>
#include <array.au3>
#Include <File.au3>
#include <MsgBoxConstants.au3>
local $files = _FileListToArrayRec(@ScriptDir, "*.txt", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT)

for $i = 1 to UBound($files)-1
    ;------------------------------------------------
    Local $content = FileRead($files[$i])
    ;------------------------------------------------
    Local $url = "https://engnajjar.wordpress.com/wp-admin/post-new.php?content="&_URIEncode($content)
    Local $oIE =_IECreate($url);,0,0)
    ;------------------------------------------------
    _IELoadWait($oIE)
    ;------------------------------------------------
    Local $title = _IEGetObjById($oIE, "title")
    ;$ttlcntnt content title
    Local $ttlcntnt = FileReadLine($files[$i], 1)
    if StringLen($ttlcntnt)=0 Then
        $ttlcntnt = FileReadLine($files[$i], 2)
    EndIf
    _IEFormElementSetValue($title, $ttlcntnt)
    ;------------------------------------------------
    TrayTip($i&"/"&(UBound($files) - 1),  $ttlcntnt ,0)
    ;------------------------------------------------
    $ip = (100/UBound($files))*$i
    ProgressSet($ip, "%" &Round($ip,0) & " | " &$i &"/"&UBound($files))
    ;------------------------------------------------
    Local $Category_ID = "in-category-2"
    Local $chkbx = _IEGetObjById($oIE, $Category_ID )
    _IEAction($chkbx, "click")
    ;------------------------------------------------
    Local $oSubmit = _IEGetObjById($oIE,"publish")
    Local $oTag = _IEGetObjById($oIE,"new-tag-post_tag")
    ;------------------------------------------------
    Local $Tags_arr[0]
    $ttlcntnt = StringSplit($ttlcntnt," ")
    for $t in $ttlcntnt
        _ArrayAdd($Tags_arr,$t)
    Next
    ;--------------
    Local $Tags = ""
    for $tg = UBound($Tags_arr)-1 to 1 step -1
        $Tags =$Tags&", "&$Tags_arr[$tg]
    next
    $Tags = StringTrimLeft($Tags ,1)
    ;--------------
    _IEFormElementSetValue($oTag, $Tags)
    ;------------------------------------------------
    _IEAction($oSubmit, "click")
    ;------------------------------------------------
    _IELoadWait($oIE)
    ;------------------------------------------------
    _IEQuit($oIE)
    ProcessClose("iexplore.exe")
next

ProgressSet(100, "Done", "Complete")
ProgressOff()


Func _URIEncode($sData)
    ; Prog@ndy
    Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"")
    Local $nChar
    $sData=""
    For $i = 1 To $aData[0]
        ; ConsoleWrite($aData[$i] & @CRLF)
        $nChar = Asc($aData[$i])
        Switch $nChar
            Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
                $sData &= $aData[$i]
            Case 32
                $sData &= "+"
            Case Else
                $sData &= "%" & Hex($nChar,2)
        EndSwitch
    Next
    Return $sData
EndFunc

 

Edited by AlienStar

Share this post


Link to post
Share on other sites
AlienStar

I just wanna know why it works fine before , then it stopped !!

Share this post


Link to post
Share on other sites
Danp2

IDK. But you're missing an ampersand in this line --

Local $url = "https://engnajjar.wordpress.com/wp-admin/post-new.php?content="_URIEncode($content)

and there also appears to be an issue with this line ($post_Category is undefined)  --

Local $Category_ID = "in-category-"&$post_Category

 

  • Like 1

Share this post


Link to post
Share on other sites
AlienStar
Just now, Danp2 said:

IDK. But you're missing an ampersand in this line --

Local $url = "https://engnajjar.wordpress.com/wp-admin/post-new.php?content="_URIEncode($content)

and there also appears to be an issue with this line ($post_Category is undefined)  --

Local $Category_ID = "in-category-"&$post_Category

 

I put $content in my code , you can see it again 

Local $content = FileRead($files[$i])

also for $post_Category I get it by inputbox so I delete it  then set a number instead of $post_Category

you can re-read my code after editing  

Share this post


Link to post
Share on other sites
AlienStar

sorry when I copied the code I've forgotten "&" before the function 

_URIEncode($content)

I've edited the reply

Share this post


Link to post
Share on other sites
Danp2

Does the error occur on the initial pass of your For loop? If not, then you may want to change your logic to only call _IECreate / _IEQuit once (outside of your For loop). You would then call _IENavigate in place of _IECreate (inside the For loop).

Share this post


Link to post
Share on other sites
AlienStar

I've detected the problem 

the error is related to the function 

_URIEncode($content)

because of the content of the text file 

the new text files contain a lot of "-" as lines like this :

XXXXXXXX
tel: 0123456789
Fax: 0123456789

ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ 
ـ

and these "-" make the error 

thanks my friend @Danp2 for this discussion :)

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

×