Wheezer

Problem with IE

9 posts in this topic

Hello guys, i'm a rookie trying to create a script that logs me in to steam forums. After that it has to refresh every x seconds.

But there is a problem, whenever i run the script it says variable not declared.

Can somebody please help me out?

 

#include <ie.au3>
#include <MsgBoxConstants.au3>

Call ("internetexist")

Func internetexist()
If WinExists("Steam Community - Internet Explorer") Or WinExists("Rocket League Ruilen :: Steam Community - Internet Explorer") Then
    MsgBox($MB_SYSTEMMODAL, "IE", "Found it.")
    Call("Logn")
Else
Global $oIE = _IECreate("https://steamcommunity.com/login/home/?goto=app%2F252950%2Ftradingforum%2F"); i declared $oIE here, but...
Call("Logn")
        EndIf
EndFunc

Func Logn()
;Global $oIE = _IECreate("https://steamcommunity.com/login/home/?goto=app%2F252950%2Ftradingforum%2F");if i remove this line it gives "Variable used without being declared." why??
Global $oIEA = _IEAttach("", "instance", 1)
Global $user = _IEGetObjByName ($oIE, "username")
Global $pass = _IEGetObjByName ($oIE, "password")
_IEFormElementSetValue ($user, "test")
_IEFormElementSetValue ($pass, "****")
Global $oSubmit = _IEGetObjById($oIE, "SteamLogin")
Global $clicklogin = _IEAction($oSubmit, "Click")
Sleep(2000)
EndFunc

While 1
    Sleep(10000)
    ConsoleWrite("Refreshing")
    _IEAction($oIE, "refresh")
WEnd

"C:\Users\X\Desktop\autoit\trading rl BIJNA.au3" (19) : ==> Variable used without being declared.:
Global $user = _IEGetObjByName ($oIE, "username")
Global $user = _IEGetObjByName (^ ERROR

Share this post


Link to post
Share on other sites



try to declare Global $oIE outside the function (just before the Call ("internetexist")) and remove the "Global" statement from within the function.


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

It's no good codind practice to declare Globaal variable in a func. Try it this way:

#include <ie.au3>
#include <MsgBoxConstants.au3>

Global $oIE

Call("internetexist")

Func internetexist()
    If WinExists("Steam Community - Internet Explorer") Or WinExists("Rocket League Ruilen :: Steam Community - Internet Explorer") Then
        MsgBox($MB_SYSTEMMODAL, "IE", "Found it.")
        $oIE = _IEAttach("", "instance", 1)
        Call("Logn")
    Else
        $oIE = _IECreate("https://steamcommunity.com/login/home/?goto=app%2F252950%2Ftradingforum%2F")
        Call("Logn")
    EndIf
EndFunc   ;==>internetexist

Func Logn()
    Local $user = _IEGetObjByName($oIE, "username")
    Local $pass = _IEGetObjByName($oIE, "password")
    _IEFormElementSetValue($user, "test")
    _IEFormElementSetValue($pass, "****")
    Local $oSubmit = _IEGetObjById($oIE, "SteamLogin")
    Local $clicklogin = _IEAction($oSubmit, "Click")
    Sleep(2000)
EndFunc   ;==>Logn

While 1
    Sleep(10000)
    ConsoleWrite("Refreshing")
    _IEAction($oIE, "refresh")
WEnd

 

Share this post


Link to post
Share on other sites

This works! Thank you guys :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

When I run your script with the line uncommented, it doesn't generate an error for me.

Edited by VeryGary

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

6 hours ago, VeryGary said:

When I run your script with the line uncommented, it doesn't generate an error for me.

Haven't you read?

 

On 17.9.2016 at 9:49 PM, Wheezer said:
Func Logn() 
;Global $oIE = _IECreate("https://steamcommunity.com/login/home/?goto=app%2F252950%2Ftradingforum%2F");if i remove this line it gives "Variable used without being declared." why??

 

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hey guys,

I'm encountering a new problem, i have to click a button on the site.

When i search for the object Id, it's not there.

Look:

<a class="btn_darkblue_white_innerfade btn_medium responsive_OnClickDismissMenu" href="javascript:Forum_CreateTopic( 'Trading_9036925' );">
<span>          Een nieuwe discussie starten                </span></a>

My unfinished code:

Local $oTopic = _IEGetObjById($oIE, "$???") ;get the topic button
Local $oclicktopic = _IEAction($???, "Click");  click it

Is there a way to tackle this problem?

Edited by Wheezer

Share this post


Link to post
Share on other sites

Edit: If I run the code with the line uncommented or not, it doesn't generate an error for me.

Share this post


Link to post
Share on other sites
12 hours ago, VeryGary said:

Edit: If I run the code with the line uncommented or not, it doesn't generate an error for me.

Then you don't tested it with a already running instance from IE

 

On 17.9.2016 at 9:49 PM, Wheezer said:

 

...
Global $oIEA = _IEAttach("", "instance", 1)
Global $user = _IEGetObjByName ($oIE, "username")
...

 

.

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

  • Similar Content

    • eyegeegeewhy
      Error im trying to trap with _IEFrameGetCollection & _IEPropertyGet
      By eyegeegeewhy
      Hi
      I'm having some trouble with my script that scrapes out the content of iframes from pages using IE. On certain pages the script always fails , my fist thought was it was a timing issue so i tried adding Sleep(5000) in a few places and that doesn't appear to make any difference and it seems to always be the same pages so im not thinking its about timing.
      The error in the console reads
      "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (2308) : ==> The requested action with this object has failed.: $oTemp = $oObject.document.body $oTemp = $oObject^ ERROR My code is as follows
      #include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <String.au3> Local $oIE = _IECreate("about:blank") $OriginalURL = "http://urbanikstreetdance-glasgow.co.uk/contact/3762801" _IENavigate($oIE, $OriginalURL) Local $oFrames = _IEFrameGetCollection($oIE) Local $iNumFrames = @extended If $iNumFrames > 0 Then Sleep(1000) Local $oFrame = 0 For $i = 1 To ($iNumFrames - 1) $oFrame = _IEFrameGetCollection($oIE, $i) ConsoleWrite(@error) $frame_html = _IEPropertyGet($oFrame, "innerhtml") & @CRLF If StringLeft($frame_html, 7) = "<iframe" Then ConsoleWrite(@CRLF & $OriginalURL & "|" & _IEPropertyGet($oIE, "locationurl") & $frame_html) EndIf Next EndIf Does anyone have any ideas on either how to stop it from failing or something i can do to identify that it will fail so i can exclude it from being checked.
      Any help would be greatly appreciated
       
    • MattG1991
      Assistance with Javascript and IE
      By MattG1991
      Hello everyone. I've a quick question. And yes, I am fairly new to AutoIt (in case you were wondering). 
      I'm writing a program that will open a webpage and inject Javascript code into the address bar. 
      _IENavigate($oie, "javascript:var oArray = document.getElementsByClassName('tab_caption'); for(i = 0; i < oArray.length; i++) { if(oArray.innerHTML == 'Information') oArray.click(); };")
      The line clicks on the tab listed as "Information", then it doesn't continue. Is there a way I can make AutoIt run this command for a specified amount of time, then move on to the next line of code?
    • scslmd
      IE.au3 error (Line 715)
      By scslmd
      Hi,
      Version: Autoit v3.3.14.1, IE3 T30-2 released 20140819
      Hoping someone can point me in the right direction. I've been struggling over this error the last week and unable to find a solution or work around.
      Similar issue?
       
      Description of issue: I have an AutoIt script that attaches to an IE9 session and parses an iframe containing patient demographics (name, medical record #, etc) that seems to be working for the first few seconds to minutes but eventually errors out with the error below. Always consistently on line 715. When initially run, it will return valid and correct information but it will eventually error out. Initially I thought it was because I was switching from patient to patient (i.e. catching it when there was no data) but when I don't do anything at all (no activity on the IE9 web page), it will still give an error. I have not found any posts about this specific error at line 715. Any guidance to solving this error is grateful.
      --> COM Error encountered in Patient Demographics on ToolTray.au3 (715) : ----> $IEComErrorNumber            = 0x80020009 (-2147352567) ----> $IEComErrorWinDescription    = Exception occurred. ----> $IEComErrorDescription       = Bad variable type. ----> $IEComErrorSource            =  ----> $IEComErrorHelpFile          = C:\Windows\SysWOW64\mshtml.hlp ----> $IEComErrorHelpContext       = 0 ----> $IEComErrorLastDllError      = 0 ----> $IEComErrorRetcode           = 0x80020008 --> IE.au3 T3.0-2 Error from function _IETableGetCollection, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-2 Error from function _IETableWriteToArray, $_IESTATUS_InvalidDataType --> COM Error encountered in Patient Demographics on ToolTray.au3 (715) : ----> $IEComErrorNumber = 0x80020009 (-2147352567) ----> $IEComErrorWinDescription = Exception occurred. ----> $IEComErrorDescription = Invalid argument. ----> $IEComErrorSource = ----> $IEComErrorHelpFile = C:\Windows\SysWOW64\mshtml.hlp ----> $IEComErrorHelpContext = 0 ----> $IEComErrorLastDllError = 0 ----> $IEComErrorRetcode = 0x80070057 --> IE.au3 T3.0-2 Error from function _IETableGetCollection, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-2 Error from function _IETableWriteToArray, $_IESTATUS_InvalidDataType  
    • allcapone1912
      IE via proxy not working correctly
      By allcapone1912
      i have a simple script that check proxy on ip-score.com(with ie.au3)
      my code
      #include <MsgBoxConstants.au3> #include <IE.au3> Local $oIE = _IECreate("http://www.ip-score.com/", 1, 1, 1, 1) Sleep(5000) Local $TimeZone = _IEBodyReadText($oIE) _IEQuit($oIE) problem is that in internet Explorer is a proxy(not automatic/direct connection)
      ie sometime load the page but sometime not, and i get "The page cannot be displayed"
      If a make a refresh to page with error its work fine
      How to resolve this problem without refreshing page each time?

    • DavidLago
      [SOLVED] Help with Interaction with IE
      By DavidLago
      Hello.

      I'd like to ask some help with IE interaction.
      Basically, My script opens a webpage, then checks for an expected form named login and passwd:
      ; Collects info from the opened page $oForms = _IEFormGetCollection($oIE) Local $iNumForms = @extended If $iNumForms = 1 Then $oForm = _IEFormGetCollection($oIE, 0) $oObjs = _IEFormElementGetCollection($oForm) Local $iNumObj = @extended Else ; insert error treatment here Exit EndIf If $iNumObj = 3 Then ; Check if there are 3 objects in the page (login / pass / submit) Sleep(1000) ; Emulating a user typing infos $oObj = _IEFormElementGetObjByName($oForm, "login") _IEFormElementSetValue($oObj, "barackobama") Sleep(1000) ; Emulating the user $oObj = _IEFormElementGetObjByName($oForm, "passwd") _IEFormElementSetValue($oObj, "UncleSam2015") Sleep(1000) ; Emulating the user _IEFormSubmit($oForm) Else ; insert error treatment here Exit EndIf It goes to a loading screen, it usually takes 2-10 seconds. Then, it goes to a main screen dashboard.
      The ElementGetObjByName gets this info from the page:
      <input class="CTXMSAM_ContentFont" type="Password" title="Enter password" name="passwd" size="30" maxlength="127" style="width:100%;"> I need to verify if it really logs in (kinda worked around this), and how long it takes to load the main screen (that classic loading spinning ball).
      I was trying to do it by counting the forms or objects, but it's not possible, since there is no forms on the main screen, and both the loading screen and the main screen has 1 object. The main screen though, has an object already identifier (searchbox), but it also doesn't have a name. The code of the searchbox is as below:
      <input class="searchbox-textbox lighttext" type="text" autocomplete="off" title="Search"> Is there any way for me to track/identify this page with or without IE.au3?
      Thanks.