Jump to content

Works fine on WIN7 and not in WIN10


Recommended Posts

 Hi Guys,

Could you please try out my script on win10 machine (simple site scrape)? One of my users complains it doesnt work on his win10, but it works fine on my win7. The error he gets is on the .FireEvent call. I think it is admin rights or IE / Edge issue, but don't have win10 to test it out.

Thanks in advance.

 

#include <IE.au3>
#include <Array.au3>
#include <Excel.au3>

Global $oIE,$string
Dim $destination[8] = ["Viña del Mar", "Rancagua", "Pucon", "Copiapo", "Temuco", "La serena", "Puerto Montt", "Valdivia"]
Dim $FinalResult[1][3]
$FinalResult[0][0] = "Destination"
$FinalResult[0][1] = "Ida"
$FinalResult[0][2] = "Vuelta"

Attach("https://www.turbus.cl/")
If IsObj($oIE) = 0 Then
    ConsoleWrite("IE error??"&@CRLF)
    $oIE = _IECreate()
EndIf

For $i=0 to UBound($destination)-1 Step 1
    _IENavigate($oIE,"https://www.turbus.cl/")
    $site1 = _IEGetObjById($oIE,"j_id_id122:cmbCiudadOrigenV2")
    While @error
        Sleep(1000)
        $site1 = _IEGetObjById($oIE,"j_id_id122:cmbCiudadOrigenV2")
    WEnd
    $site2 = _IEGetObjById($oIE,"j_id_id122:cmbCiudadDestinoV2")
    $date1 = _IEGetObjById($oIE,"j_id_id122:calIdaV2InputDate")
    $date2 = _IEGetObjById($oIE,"j_id_id122:calVueltaV2InputDate")
    $buttun1 = _IEGetObjById($oIE,"j_id_id122:botonContinuarV2")
    $site1.Value = "Santiago"
    $site2.Value = $destination[$i]
    $date1.Value = @MDAY+1&"/"&@MON&"/"&@YEAR
    $date2.Value = @MDAY+4&"/"&@MON&"/"&@YEAR
    _IEAction($buttun1,"click")
    _IELoadWait($oIE)
    $array = GetResult(GetData())
    If IsArray($array) = 0 OR UBound($array,1) < 1 Or UBound($array,2) < 2 Then
        MsgBox(0,UBound($array,1), UBound($array,2))
        _ArrayDisplay($array,"$array")
        ContinueLoop
    EndIf
    _ArrayAdd($FinalResult,"Santiago-"&$destination[$i]&"|"&$array[0][0]&"|"&$array[0][1])
Next
;~ _ArrayDisplay($FinalResult)
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $FinalResult, "A1")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 2", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


Func GetData()
    Local $string1,$string2
    $ida = _IEGetObjById($oIE,"tbIda_lbl")
    While @error
        Sleep(1000)
        $ida = _IEGetObjById($oIE,"tbIda_lbl")
    WEnd
    _IEAction($ida,"click")
    Sleep(2000)
    $result1 = _IEGetObjById($oIE,"pnlReglaIda:idPersonalizaPasaje:tb")
    While @error
        $ida.FireEvent("onmouseover")
        Sleep(1000)
        $ida.FireEvent("onclick")
        Sleep(1000)
        $result1 = _IEGetObjById($oIE,"pnlReglaIda:idPersonalizaPasaje:tb")
    WEnd
    $string1 = $string1 & $result1.innertext&@CRLF
    $vuelta = _IEGetObjById($oIE,"tbVuelta_lbl")
    _IEAction($vuelta,"click")
    Sleep(2000)
    $result2 = _IEGetObjById($oIE,"pnlReglaVuelta:idPersonalizaPasajeRegreso:tb")
    While @error
        $vuelta.FireEvent("onmouseover")
        Sleep(1000)
        $vuelta.FireEvent("onclick")
        Sleep(1000)
        $result2 = _IEGetObjById($oIE,"pnlReglaVuelta:idPersonalizaPasajeRegreso:tb")
    WEnd
    $string2 = $string2 & $result2.innertext&@CRLF
    Return $string1&"|"&$string2
EndFunc

Func Attach($atachadres)
    Local $i = 1
    While 1
        $oIE = _IEAttach("", "instance", $i)
        If @error = $_IEStatus_NoMatch Then
            $oIE = 0
            ExitLoop
        EndIf
        If StringLeft(_IEPropertyGet($oIE, "locationurl"),StringLen($atachadres)) = $atachadres Then ExitLoop
        $i += 1
    WEnd
EndFunc

Func GetResult($String)
    Dim $Master[0][2] ,$Master2[1][2]
    $2strings = StringSplit($String,"|",2)
    $Strings = StringSplit($2strings[0],@CRLF,2)
    $Strings = _ArrayUnique($Strings)
    For $i=0 to UBound($Strings)-1 Step 1
        $Data = StringSplit($Strings[$i],"$",2)
        $add = _ArrayToString($Data)
        _ArrayAdd($Master,$add)
    Next
    For $i=UBound($Master,1)-1 to 0 Step -1
        If $Master[$i][1] = "" Then _ArrayDelete($Master,$i)
    Next
    _ArraySort($Master,0, 0, 0,1)
    $Master2[0][0] = $Master[0][0]&$Master[0][1]
    Dim $Master[0][2]
    $Strings = StringSplit($2strings[1],@CRLF,2)
    $Strings = _ArrayUnique($Strings)
    For $i=0 to UBound($Strings)-1 Step 1
        $Data = StringSplit($Strings[$i],"$",2)
        $add = _ArrayToString($Data)
        _ArrayAdd($Master,$add)
    Next
    For $i=UBound($Master,1)-1 to 0 Step -1
        If $Master[$i][1] = "" Then _ArrayDelete($Master,$i)
    Next
    _ArraySort($Master,0, 0, 0,1)
    $Master2[0][1] = $Master[0][0]&$Master[0][1]
    Return $Master2
EndFunc

 

Link to comment
Share on other sites

The user is using a compiled exe file. I am guessing it is something about 'edge' or admin rights. I have added 'require admin' and created 4 versions of the script

  1. 32bit no admin
  2. 32bit requireadmin
  3. 64bit no admin
  4. 64bit requireadmin

I have asked the user to test and will see why this happens.

 

Link to comment
Share on other sites

On 7/5/2018 at 11:37 AM, Subz said:

Get the same error on my system Windows 10 x64 1709 with IE 11, on Windows 7 x64 with IE 11 get an error with $ida.fireevent.

I didnt understand what you mean ...

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