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

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

    • FMS
      By FMS
      Hello,
      I try to get all the text from a news site around a subject.
      The first run I get all the text inside a attribute in an array.
      When i try to go back and reload another page it chrashes and think it because "$oIE.GoBack"
      I couldn't find anything in the help/forum around this subject.
      Do I need to reload the $oIE or something afther an X.GoBack?
      The error i got is :
      if $oTag2.GetAttribute("class") == "NewsDetail" Then if $oTag2^ ERROR I'm not shure why I got this error, maybe someone could explain?
      Also I'm open for some pointers in this test script because I'm pretty new in working whit the IE.UDF
      Maybe there is an simpler way to get the same results?

      test script:
      #include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "Terminate") Global $oIE = _IECreate("https://www.iex.nl/Zoeken/Nieuws.aspx?q=air%20france") ;get first subject Global $oLink1 = _IEGetObjById($oIE, "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl00_linkNews") Sleep(500) _IEAction($oLink1, "click") Sleep(500) Global $oTags = _IETagNameGetCollection($oIE, "div") Global $aResults[1] For $oTag In $oTags if $oTag.GetAttribute("class") == "NewsDetail" Then _ArrayAdd($aResults, $oTag.innerTEXT) EndIf Next $aResults[0] = UBound($aResults) - 1 _ArrayDisplay($aResults, "Episodelist") ConsoleWrite($aResults[1] & @CRLF) $oIE.GoBack ;get second subject Global $oLink2 = _IEGetObjById($oIE, "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl01_linkNews") Sleep(500) _IEAction($oLink2, "click") Sleep(500) Local $oTags2 = _IETagNameGetCollection($oIE, "div") Local $aResults2[1] For $oTag2 In $oTags2 if $oTag2.GetAttribute("class") == "NewsDetail" Then _ArrayAdd($aResults2, $oTag2.innerTEXT) EndIf Next $aResults2[0] = UBound($aResults2) - 1 ConsoleWrite($aResults2[1] & @CRLF) Func Terminate() _IEQuit($oIE) Exit EndFunc ;==>Terminate  
    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • SkysLastChance
      By SkysLastChance
      I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)
      Is there a way I can find a id or name by the last 3 charcters?
      Using something like "stringright?"
      So I would want to search for just "_26" in this case.
      This is assuming that there are no other _26
       

      #include <Excel.au3> #include <IE.au3> #include <GUIConstantsEx.au3> Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = "" $oIE = _IEAttach("MEDITECH") $TagName = "input" $Value = "in2xk_26" $Attribute = "id" $tags = $oIE.document.GetElementsByTagName($TagName) ;TagName ------ MAKE SURE TO NAME THESE For $tag in $tags $class_value = $tag.GetAttribute($Attribute) ;Attribute ------ MAKE SURE TO NAME THESE If string($class_value) = $Value Then ;Value ------ MAKE SURE TO NAME THESE $target = $tag $iScreenX = _IEPropertyGet($target, "screenx") $iScreenY = _IEPropertyGet($target, "screeny") $iWidth = _IEPropertyGet($target, "width") $iHeight = _IEPropertyGet($target, "height") $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed) MouseClick($MOUSE_CLICK_LEFT) ExitLoop EndIf Next  
       
    • SkysLastChance
      By SkysLastChance
      I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag. 
      The id and name change all the time so I can't use those. 
      The code highlighted in blue is what I am trying to click. (second picture)
      Here is what I have tried.
      $target = "" $tags = $oIE.document.GetElementsByTagName("div") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "s_92 altstyle s_93 s_94" Then $target = $tag ConsoleWrite("Tag Found " & $target.outerText&@CRLF) ExitLoop EndIf Next  

       
       

    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

×