Jump to content

Problem with IE


Wheezer
 Share

Recommended Posts

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

Link to comment
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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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")
...

 

.

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