Sign in to follow this  
Followers 0
Reloaded

Need help with IE Management!

10 posts in this topic

Ok im making a AdminBot program for an old game SWAT4 which has a WebAdmin capability so i figured i'll make something in AutoIt to do some basic admining for me. The problem im having is this code snippet which you can view all the code below and here is the errors i get:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "F:\Jason\Documents\ELITE Files\SWAT4 AdminBot\SWAT4-Admin-Bot.au3"

--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

>Exit code: 0 Time: 13.507

Func startBot()
    
    ;Take the IP that was entered and combine it with the PORT
    ;eg. 192.168.1.1:10490
    $eliteSvrWebAdmin = GUICtrlRead($ip) & ":" & GUICtrlRead($port)
    ;Get the username and store it
    $gotUsername = GUICtrlRead($username)
    ;Get the password and store it
    $gotPass = GUICtrlRead($password)
    Local $logInUserField = _IEFormElementGetObjByName($eliteSvrWebAdmin, "user")
    
    ;Open up IE and connect to WebAdmin and LogIn
    _IECreate($eliteSvrWebAdmin, 0, 1, 1)
    _IEFormElementSetValue($logInUserField, $gotUsername)
    MsgBox(0, "", @Error)
EndFunc

So far here is what i sketched onto paper that it needs to do so you can hopefully see things a bit clearer:

1)Connect to Internet

2)Connect to WebAdmin

2a)For username field filter it to only allow 0-9, . and : (IP:PORT)

3)Click LOGIN

4)Monitor Chat

5)Find player in list

6)Select radio button

7)Click the right Admin button (eg. MUTE)

And you will need to enter this into the URL if you need to check out the webpage > http://81.19.215.32:10490

Currently im trying to get it to enter a username into the username field. If you actually copy/paste this into Scite and run it for the IP just up this: http://81.19.215.32 for the port: 10490 put any username and any password. (NOte that the : is put in automatically.

#cs ----------------------------------------------------------------------------
    Author: |ELITE|Reloaded
    Website: http://www.eliteswat.com
    Date Created: 2-23-2010
    Date Last Modified: 2-23-2010
    Description: |ELITE| AdminBot S4 is an Admin Bot for our SWAT4 servers.
    Email: reloaded@eliteswat.com OR harrisjason10@yahoo.com
    Copyright: |ELITE| Clan
#ce ----------------------------------------------------------------------------

#Include <IE.au3>
#Include <GUIConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <IE.au3>

Opt('MustDeclareVars', 1)
Opt('GUIOnEventMode', 1)


Global $eliteSvrWebAdmin, $ip, $port, $username, $password, $gotUsername, $gotPass
Global $startBot, $msg



GUICreate("|ELITE| AdminBot", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
;IP edit
GUICtrlCreateLabel("WebAdmin IP:", 7, 20, 200, 20)
$ip = GUICtrlCreateEdit("", 7, 40, 120, 20)
;PORT edit
GUICtrlCreateLabel("Port:", 132, 20, 60, 20)
$port = GUICtrlCreateEdit("", 132, 40, 60, 20)
;USERNAME edit
GUICtrlCreateLabel("Username:", 7, 70, 120, 20)
$username = GUICtrlCreateEdit("", 7, 90, 120, 20)
;PASSWORD edit
GUICtrlCreateLabel("Password:", 132, 70, 60, 20)
$password = GUICtrlCreateEdit("", 132, 90, 60, 20)
;START BOT button
$startBot = GUICtrlCreateButton("Start Bot", 50, 118, 100, 20)
GUICtrlSetOnEvent(-1, "startBot")
GUISetState(@SW_SHOW)



While 1
    Sleep(1000)
WEnd



Func close()
    Exit
EndFunc


Func startBot()
    
    ;Take the IP that was entered and combine it with the PORT
    ;eg. 192.168.1.1:10490
    $eliteSvrWebAdmin = GUICtrlRead($ip) & ":" & GUICtrlRead($port)
    ;Get the username and store it
    $gotUsername = GUICtrlRead($username)
    ;Get the password and store it
    $gotPass = GUICtrlRead($password)
    Local $logInUserField = _IEFormElementGetObjByName($eliteSvrWebAdmin, "user")
    
    ;Open up IE and connect to WebAdmin and LogIn
    _IECreate($eliteSvrWebAdmin, 0, 1, 1)
    _IEFormElementSetValue($logInUserField, $gotUsername)
    MsgBox(0, "", @Error)
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

For one thing, you need to have something like $oIE = _IECreate() otherwise, the _IEFormElementGetObjByName() won't know what you're talking about.

try this, worked for me:

startBot()
Func startBot()

    ;Take the IP that was entered and combine it with the PORT
    ;eg. 192.168.1.1:10490
    $eliteSvrWebAdmin = 'http://81.19.215.32:10490';GUICtrlRead($ip) & ":" & GUICtrlRead($port)
    ;Get the username and store it
    $gotUsername = 'asdf';GUICtrlRead($username)
    ;Get the password and store it
    $gotPass = 'asdf';GUICtrlRead($password)

    ;Open up IE and connect to WebAdmin and LogIn
    Local $oIE = _IECreate($eliteSvrWebAdmin, 0, 1, 1)

    Local $logInUserField = _IEGetObjByName($oIE, "user")
    _IEFormElementSetValue($logInUserField, $gotUsername)
    MsgBox(0, "", @error)
    Exit
EndFunc ;==>startBot
Edited by mistersquirrle

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

For one thing, you need to have something like $oIE = _IECreate() otherwise, the _IEFormElementGetObjByName() won't know what you're talking about.

try this, worked for me:

startBot()
Func startBot()

    ;Take the IP that was entered and combine it with the PORT
    ;eg. 192.168.1.1:10490
    $eliteSvrWebAdmin = 'http://81.19.215.32:10490';GUICtrlRead($ip) & ":" & GUICtrlRead($port)
    ;Get the username and store it
    $gotUsername = 'asdf';GUICtrlRead($username)
    ;Get the password and store it
    $gotPass = 'asdf';GUICtrlRead($password)

    ;Open up IE and connect to WebAdmin and LogIn
    Local $oIE = _IECreate($eliteSvrWebAdmin, 0, 1, 1)

    Local $logInUserField = _IEGetObjByName($oIE, "user")
    _IEFormElementSetValue($logInUserField, $gotUsername)
    MsgBox(0, "", @error)
    Exit
EndFunc ;==>startBot

Ok i see, but just a question, why put the "o" in $oIE ? Makes no sense to me, but i do see what you mean by putting it into a variable :mellow:.

Just another quick question, instead of having a whole NEW variable for it, should i just overwrite the IP+PORT that is stored into "$eliteSvrWebAdmin" and place _IECreate..... in it?

YOu are the bombo for replying :())))

Share this post


Link to post
Share on other sites

Ok i see, but just a question, why put the "o" in $oIE ? Makes no sense to me, but i do see what you mean by putting it into a variable :mellow:.

Just another quick question, instead of having a whole NEW variable for it, should i just overwrite the IP+PORT that is stored into "$eliteSvrWebAdmin" and place _IECreate..... in it?

YOu are the bombo for replying :())))

The "o" in $oIE is just how the example in the help file is... I think. I don't understand it either, but then again, it doesn't really matter. Your variable could be $oaihfvoinaekjfshio5 but that'd be hard to remember what it was... meh.

And having a whole new variable for what? Are you talking about the $eliteSvrWebAdmin variable? You could eliminate that variable if you wanted, and just use

GUICtrlRead($ip) & ":" & GUICtrlRead($port)
if you wanted. There's no issue with that, but if you need to use the $eliteSvrWebAdmin variable again (that's a relaly long variable name... something like $WAdminIP or something would probably be easier, but that's my take on it) it might be a hassle to do
GUICtrlRead($ip) & ":" & GUICtrlRead($port)
over and over every time you need it

RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

The "o" in $oIE is just how the example in the help file is... I think. I don't understand it either, but then again, it doesn't really matter. Your variable could be $oaihfvoinaekjfshio5 but that'd be hard to remember what it was... meh.

And having a whole new variable for what? Are you talking about the $eliteSvrWebAdmin variable? You could eliminate that variable if you wanted, and just use

GUICtrlRead($ip) & ":" & GUICtrlRead($port)
if you wanted. There's no issue with that, but if you need to use the $eliteSvrWebAdmin variable again (that's a relaly long variable name... something like $WAdminIP or something would probably be easier, but that's my take on it) it might be a hassle to do
GUICtrlRead($ip) & ":" & GUICtrlRead($port)
over and over every time you need it

Hmm yea i will shorten that variable it will be faster to type.

Yea i was planning on after using the variable $eliteSvrWebAdmin (which has the IP:PORT in it at this time) to replace IP:PORT with _IECreate....

:mellow:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok so now im trying to use StringRegExp to check the fields, im on the IP field so it needs to check only for DIGITS and DECIMALS. At least 1 digit and at most 3 digits in each group. It's not working though and i tried 2 different ways and it says when i enter "192.168.1.1" its wrong, and when i enter "hajldjfld" its wrong (which is good for this last string with the letters). Here is the 2 ways i tried:

Func checkFields()
    ;Get the IP and store it
    Local $gotIP = StringRegExp($ip, "([:digit:]{1,3}\.{1}){4}", 0)
    ;Get the Port and store it
    Local $gotPort = StringRegExp($port, "[:digit:]{1,5}")
    ;Get the Username and store it
    $gotUsername = GUICtrlRead($username)
    ;Get the Password and store it
    $gotPass = GUICtrlRead($password)
    $msg = GUIGetMsg()
    
    Select
        ;Check if the IP is invalid (format: ***.***.***.***)
        Case $gotIP = 0
            MsgBox(0, "Invalid IP", "IP must be in this format: ***.***.***.***" & @CR & "Only characters ""0-9"" and "".""")
            MsgBox(0, "", @Error)
        ;Check if the Port is invalid (only 1-5 digits)
        Case $gotPort = 0
            MsgBox(0, "Invalid Port", "Port must be only characters ""0-9"", 1-5 characters long")
        ;For now used as a test to see if it runs this code when it shouldn't
        Case $gotIP = 1
            MsgBox(0, "", "Start Bot func going to execute")
            ;startBot()
    EndSelect
EndFunc

Func checkFields()
    ;Get the IP and store it
    Local $gotIP = StringRegExp($ip, "[:digit:]{1,3}\.{1}[:digit:]{1,3}\.{1}[:digit:]{1,3}\.{1}[:digit:]{1,3}\.{1}", 0)
    ;Get the Port and store it
    Local $gotPort = StringRegExp($port, "[:digit:]{1,5}")
    ;Get the Username and store it
    $gotUsername = GUICtrlRead($username)
    ;Get the Password and store it
    $gotPass = GUICtrlRead($password)
    
    Select
        ;Check if the IP is invalid (format: ***.***.***.***)
        Case $gotIP = 0
            MsgBox(0, "Invalid IP", "IP must be in this format: ***.***.***.***" & @CR & "Only characters ""0-9"" and "".""")
        ;Check if the Port is invalid (only 1-5 digits)
        Case $gotPort = 0
            MsgBox(0, "Invalid Port", "Port must be only characters ""0-9"", 1-5 characters long")
        ;For now used as a test to see if it runs this code when it shouldn't
        Case $gotIP = 1
            MsgBox(0, "", "Start Bot func going to execute")
            ;startBot()
    EndSelect
EndFunc
Edited by Reloaded

Share this post


Link to post
Share on other sites

the o in $oIE stands for Object.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Ok so now im trying to use StringRegExp to check the fields, im on the IP field so it needs to check only for DIGITS and DECIMALS. At least 1 digit and at most 3 digits in each group. It's not working though and i tried 2 different ways and it says when i enter "192.168.1.1" its wrong, and when i enter "hajldjfld" its wrong (which is good for this last string with the letters).

well you lost me there... I don't know how to use StringRegExp(). That's for someone else to help you with. What are you trying to do with it?


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

well you lost me there... I don't know how to use StringRegExp(). That's for someone else to help you with. What are you trying to do with it?

To make sure they enter an IP and no letters or other characters. I need to figure out how to make a loop that will walk through the code and check... And then cancel the checkFields() if there is something wrong. Edited by Reloaded

Share this post


Link to post
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "F:\Jason\Documents\ELITE Files\SWAT4 AdminBot\SWAT4-Admin-Bot.au3"    
C:\Program Files (x86)\AutoIt3\Include\IE.au3 (2348) : ==> The requested action with this object has failed.:
If IsObj($o_object.document.GetElementsByName($s_Id).item($i_index)) Then
If IsObj($o_object.document^ ERROR
>Exit code: 1    Time: 2.072

Can someone PLEASE tell me why im getting that error in the console? It's weird... It was working perfectly, now it won't enter anything into the Username & Password field and it won't even bother to click on the SUBMIT button...

#cs ----------------------------------------------------------------------------
    Author: |ELITE|Reloaded
    Website: http://www.eliteswat.com
    Date Created: 2-23-2010
    Date Last Modified: 2-23-2010
    Description: |ELITE| AdminBot S4 is an Admin Bot for our SWAT4 servers.
    Email: reloaded@eliteswat.com OR harrisjason10@yahoo.com
    Copyright: |ELITE| Clan
#ce ----------------------------------------------------------------------------

#Include <Array.au3>
#Include <EditConstants.au3>
#Include <GUIConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <IE.au3>

Opt('MustDeclareVars', 1)
Opt('GUIOnEventMode', 1)


Global $ip, $port, $username, $password, $gotUsername, $gotPass, $http
$http = "http://"
Global $startBot, $msg, $startMon



GUICreate("|ELITE| AdminBot", 250, 180)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
;IP edit
GUICtrlCreateLabel("WebAdmin IP:", 67, 20, 200, 20)
GUICtrlCreateLabel("http://", 32, 42, 50, 20)
$ip = GUICtrlCreateInput("", 67, 40, 150, 20)
;PORT edit
;GUICtrlCreateLabel("Port:", 157, 20, 60, 20)
;$port = GUICtrlCreateInput("", 157, 40, 60, 20)
;USERNAME edit
GUICtrlCreateLabel("Username:", 32, 70, 120, 20)
$username = GUICtrlCreateInput("", 32, 90, 120, 20)
;PASSWORD edit
GUICtrlCreateLabel("Password:", 157, 70, 60, 20)
$password = GUICtrlCreateInput("", 157, 90, 60, 20, BitOr($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
;START BOT button
$startBot = GUICtrlCreateButton("Start Bot", 75, 130, 100, 30)
GUICtrlSetOnEvent(-1, "startBot")
GUISetState(@SW_SHOW)



While 1
    Sleep(1000)
WEnd



Func close()
    Exit
EndFunc



Func checkFields()
    ;Get the IP and store it
    Local $gotIP = $ip
    ;Get the Username and store it
    $gotUsername = GUICtrlRead($username)
    ;Get the Password and store it
    $gotPass = GUICtrlRead($password)
    
    Select
        ;Check if the IP is invalid (format: ***.***.***.***)
        Case $gotIP = 0
            MsgBox(0, "Invalid IP", "IP must be in this format: ***.***.***.***" & @CR & "Only characters ""0-9"" and "".""")
        ;For now used as a test to see if it runs this code when it shouldn't
        Case $gotIP = 1
            MsgBox(0, "", "Start Bot func going to execute")
            ;startBot()
    EndSelect

EndFunc



Func startBot()
    Local $svrWebAdmin, $logInForm, $logInUserField, $logInPassField, $playerList, $console, $playerChat, $kickButton, $banButton, $fnwButton, $fnaButton, $muteButton, $addBanButton, $sayButton, $oIE
    ;Store the IP
    ;eg. 192.168.1.1:10490
    $svrWebAdmin = "http://81.19.215.40:10490" ;$http & GUICtrlRead($ip)
    ;Get the username and store it
    $gotUsername = "someUsername" ;GUICtrlRead($username)
    ;Get the password and store it
    $gotPass = "somePass" ;GUICtrlRead($password)
    
    ;----Open up IE and connect to WebAdmin and LogIn
    $oIE = _IECreate($svrWebAdmin, 0, 1, 0, 1)
    $logInUserField = _IEGetObjByName($oIE, "user")
    _IEFormElementSetValue($logInUserField, $gotUsername)
    $logInPassField = _IEGetObjByName($oIE, "pw")
    _IEFormElementSetValue($logInPassField, $gotPass)
    $logInForm = _IEFormGetCollection($oIE, 0)
    _IEFormSubmit($logInForm)
    
    ;----Start Monitoring
    ;$console  = _IEGetObjById($oIE, "console")
    ;$playerChat = _IEBodyReadText($console)
    
EndFunc

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