Jump to content
Sign in to follow this  
nick448

Script Help

Recommended Posts

nick448

Need help logging into the web interface of my WhatsUP gold server for an overhead display in our IT dept.

Essentially I want the script to open IE, navigate to our servers web address, login to whats up, then kill IE and start the process over. ( only because the web interface times out after about 10 mins and logs you out )

Currently I have this:

$user='admin'
$pass='squirrel69'

#include <IE.au3>

Dim $oIE = _IECreate('about:blank', 0, 0)

With $oIE
    .Left = 0
    .Top = 0
    .Menubar = False
    .Resizable = False
    .StatusBar = False
    .TheaterMode = True
    .Toolbar = False
    .Visible = True
EndWith

_IENavigate($oIE, 'http://srv13app8/NmConsole/CoreNm/User/DlgUserLogin/DlgUserLogin.asp')

 

I AM STUCK please help !! :)

 

Share this post


Link to post
Share on other sites
nick448

Thanks!

Share this post


Link to post
Share on other sites
nick448

Need help logging into the web interface of my WhatsUP gold server for an overhead display in our IT dept.

Essentially I want the script to open IE, navigate to our servers web address, login to whats up, then kill IE and start the process over. ( only because the web interface times out after about 10 mins and logs you out )

Currently I have this:

$user='admin'$pass='squirrel69'
#include <IE.au3>
Dim $oIE = _IECreate('about:blank', 0, 0)
With $oIE.Left = 0.Top = 0.Menubar = False.Resizable = 
False.StatusBar = False.TheaterMode = True.Toolbar = 
False.Visible = TrueEndWith
_IENavigate($oIE, 'http://srv13app8/NmConsole/CoreNm/User/DlgUserLogin/DlgUserLogin.asp')

I AM STUCK please help !! :)

 

Share this post


Link to post
Share on other sites
jdelaney

Need a paste in of the user and password inputs (html).

You can also then do a loop waiting for the login screen again, and re-login

edit: not sure if that's a public page, but you might want to remove those creds :)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
nick448

I am not sure how to do that

I was thinking I could do a

send($user)
send("{TAB}")
send($pass)
send ("{ENTER}")

But there has to be a better way

Share this post


Link to post
Share on other sites
nick448

It is not a public site and I changed the creds to fakes :) thankss

Share this post


Link to post
Share on other sites
jdelaney

I wouldn not recommend sends...they can be flawed (other apps pick up the sends) or not registered by the app...controlsend is better, but still no way to validate that you are in the proper webpage input.

Download a dom viewer (like IE Developer tools)

They have a pointer tool, you can drag into the inputs (user/password), and will show you the html for that input...paste that back here...or right click the page, and view source...and search for the user/password <input>s.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
nick448

DlgUserLogin.sUserName

DlgUserLogin.sPassword

 

:thumbsup:

Share this post


Link to post
Share on other sites
jdelaney

paste in the whole tag <input blahblahblahblah>blahblab</input> for both


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
nick448

Sorry

<input name="DlgUserLogin.sPassword" class="Aspf-EditPassword" id="DlgUserLogin.sPassword" accessKey="p" style="width: 190px;" onfocus="this.className+=' Aspf-Control-Focus';" onblur="this.className='Aspf-EditPassword'" type="password" maxLength="100"/>

 

<input name="DlgUserLogin.sUserName" class="Aspf-Edit Aspf-Control-Focus" id="DlgUserLogin.sUserName" accessKey="u" style="width: 190px;" onfocus="this.className+=' Aspf-Control-Focus';" onblur="this.className='Aspf-Edit'" type="text" maxLength="100"/>

Share this post


Link to post
Share on other sites
jdelaney

use the _IEgetobjbyid function...pass in the dom object, and "DlgUserLogin.sPassword" to get the password, DlgUserLogin.sUserName for the user...then you can use those returned objects in _IEFormElementSetValue to set the values

do the same to get the login button (by id), and do _ieaction "click" to login

If you can't get it to work, post the new code doing the above steps.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
nick448

this is what I did, with no luck. I am new to this sorry

#include <IE.au3>_IEGetObjById(ByRef <input 
name="DlgUserLogin.sPassword" class="Aspf-EditPassword" 
id="DlgUserLogin.sPassword" accessKey="p" style="width: 190px;" 
onfocus="this.className+=' Aspf-Control-Focus';" 
onblur="this.className='Aspf-EditPassword'" type="password" 
maxLength="100"/>  , DlgUserLogin.sPassword)

It did not work

Share this post


Link to post
Share on other sites
jdelaney

check the help file for what to add into the function (variables)

example:

$oIE = _IECreate("Yoururl")
_IELoadWait($oIE)
$oLoginPassword = _IEGetObjById($oIE,"DlgUserLogin.sPassword")
_IEFormElementSetValue ($oLoginPassword,"yourpassword")

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
nick448

This is what I did

#include <IE.au3>
$oIE = _IECreate("http://srv13app8/NmConsole/CoreNm/User/DlgUserLogin/DlgUserLogin.asp")_IELoadWait($oIE)$oLoginPassword 
= _IEGetObjById($oIE,"DlgUserLogin.sPassword")_IEFormElementSetValue 
($oLoginPassword,"yourpassword")

This is the error in my output window

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut 
"E:\SCRIPTS\monitors\whatsup2.au3"C:\Program Files 
(x86)\AutoIt3\Include\IE.au3 (560) : ==> The requested action with this 
object has failed.:WEndWEnd^ ERROR>Exit code: 1    
Time: 0.531

Please help

Share this post


Link to post
Share on other sites
jdelaney

Please do no paste in text, highlight, and then click the code button...it mangles your output...press the code button THEN paste into that window.

Looks like an issue with _IELoadWait...is this consistent?  please paste in the error output again.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
nick448

#include <IE.au3>



Call ("signIn")

Func signIn ()
Global $oIE = _IECreate ("http://srv13app8/nmconsole")

Local $username = _IEGetObjByName ($oIE,"DlgUserLogin.sUserName")
Local $password = _IEGetObjByName ($oIE,"DlgUserLogin.sPassword")

_IEFormElementSetValue ($username,"admin")
_IEFormElementSetValue ($password,"squirrel")

EndFunc

Error

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\SCRIPTS\monitors\whatsup.au3"
C:\Program Files (x86)\AutoIt3\Include\IE.au3 (560) : ==> The requested action with this object has failed.:
WEnd
WEnd^ ERROR
>Exit code: 1    Time: 0.732

Share this post


Link to post
Share on other sites
jdelaney

Just for fun, try this one...send back the consolewrite data:

Func signIn()
    Global $oIE = _IECreate("http://srv13app8/nmconsole")
    If IsObj($oIE) Then
        ConsoleWrite("Created IE and navigated" & @CRLF)
    Else
        ConsoleWrite("UNable to create IE and navigate" & @CRLF)
        Return False
    EndIf

    If _IELoadWait($oIE) Then
        ConsoleWrite("Page loaded" & @CRLF)
    Else
        ConsoleWrite("UNable to load page" & @CRLF)
        Return False
    EndIf

    Local $username = _IEGetObjByName($oIE, "DlgUserLogin.sUserName")
    If IsObj($username) Then
        ConsoleWrite("Able to find login node" & @CRLF)
    Else
        ConsoleWrite("UNable to find login node" & @CRLF)
        Return False
    EndIf

    Local $password = _IEGetObjByName($oIE, "DlgUserLogin.sPassword")
    If IsObj($password) Then
        ConsoleWrite("Able to find password node" & @CRLF)
    Else
        ConsoleWrite("UNable to find password node" & @CRLF)
        Return False
    EndIf

    If _IEFormElementSetValue($username, "admin") Then
        ConsoleWrite("Able to set login node" & @CRLF)
    Else
        ConsoleWrite("UNable to set login node" & @CRLF)
        Return False
    EndIf

    If _IEFormElementSetValue($password, "squirrel") Then
        ConsoleWrite("Able to set password node" & @CRLF)
        Return True
    Else
        ConsoleWrite("UNable to set password node" & @CRLF)
        Return False
    EndIf

EndFunc   ;==>signIn
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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
Sign in to follow this  

  • Similar Content

    • rm4453
      By rm4453
      Hello,
       
      I am currently writing a program that parses a massive table from a website, and need a way to add a progress bar while parsing.
      I am currently using the function _IETableWriteToArray($oObj, True) to parse the array. I need the progress bar to update as the table is parsed, not just at the end of the parsing.
      Any help at all would be very much appreciated!
       
      *EDIT --> The array I am left with after parsing is $array[0-50000][16]
    • SkysLastChance
      By SkysLastChance
      I have a goofy problem. I am hoping someone could shed some light. The example is not going around the text box. It is way off. 
      I have seen some post blaming IE 11, however I have IE11 on my desktop and it works fine.
      Is there anything I can do that might fix this? 
       
      ; Open a browser with the form example and get a reference to the form ; textarea element. Get the coordinates and dimensions of the text area, ; outline its shape with the mouse and come to rest in the center #include <IE.au3> Local $oIE = _IE_Example("form") Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm") Local $oTextArea = _IEFormElementGetObjByName($oForm, "textareaExample") ; Get coordinates and dimensions of the textarea Local $iScreenX = _IEPropertyGet($oTextArea, "screenx") Local $iScreenY = _IEPropertyGet($oTextArea, "screeny") Local $iWidth = _IEPropertyGet($oTextArea, "width") Local $iHeight = _IEPropertyGet($oTextArea, "height") ; Outline the textarea with the mouse, come to rest in the center Local $iMousespeed = 50 MouseMove($iScreenX, $iScreenY, $iMousespeed) MouseMove($iScreenX + $iWidth, $iScreenY, $iMousespeed) MouseMove($iScreenX + $iWidth, $iScreenY + $iHeight, $iMousespeed) MouseMove($iScreenX, $iScreenY + $iHeight, $iMousespeed) MouseMove($iScreenX, $iScreenY, $iMousespeed) MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed)  
       
    • SkysLastChance
      By SkysLastChance
      So I have two things I am trying to click.
      Policy which works.
      $oInputs3 = _IETagNameGetCollection($oIE, "div") For $oInput3 in $oInputs3 If StringStripWS($oInput3.innertext,1) = "Policy" Then $target = $oInput3 _IELoadWait($target,"",70000) ExitLoop EndIf Next _IEAction($target, "click")  

      And Add Insurance which I havent been able to get to work. 
      $oInputs2 = _IETagNameGetCollection($oIE, "div") For $oInput2 in $oInputs2 If StringStripWS($oInput2.innertext,1) = "Add Insurance" Then $target = $oInput2 _IELoadWait($target,"",70000) ExitLoop EndIf Next _IEAction($target, "click")

      Any Ideas on what I am doing wrong?  I feel like it might be the spaces between >  Add Insurance  < but I am not sure. 
    • FMS
      By FMS
      Hello,
      I'm trying to read a div element and wait until it hits 100%.
      The structure is like :
      <div class="progress-bar" style="width: 48.0219%;  overflow: hidden; "></div>
      And want to wait until :
      <div class="progress-bar" style="width: 100%;  overflow: hidden; "></div>
      because afther this there will be an redirection whish i don't know the URL from and want to catsh this URL.
      And want to push a button on this redidertion page.

      Is there a best pratice way how to do this or is there a better way to wait for the redirection?
      Maybe wait until button exist or something?

      Does anybody could give me some tips about this challange?
       
      thnx in advanced.
       
      #include <IE.au3> Global $IE_flvto = _IECreate("https://www.website.com/",0,1,1,1) Global $oForm = _IEFormGetObjByName ($IE_flvto, "convertForm") Global $oText = _IEFormElementGetObjByName ($oForm, "convertUrl") _IEFormElementSetValue ($oText, "some text") _IEFormSubmit($oForm) ;wait for redirection ;if redirection loaded push button  
    • Juvigy
      By Juvigy
       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  
×