Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 13:36

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[AutoIt, Help] parse/login problem

Discussion on [AutoIt, Help] parse/login problem within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
D3adlySil3nc3's Avatar
 
elite*gold: 0
Join Date: Apr 2011
Posts: 288
Received Thanks: 40
[AutoIt, Help] parse/login problem

Hey
I´m playing around with AutoIt since a few Weeks, now I wanted to try to make a Bot for Ogame(yeah a another one...)
Well as the Theme says I have a few Prolems, which I couldn´t eliminate with Google and the Helpfile.
So hoping that someone of you can help me.

PHP Code:
While 1

    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit
        Case 
$loginButton
            
Global $name GUICtrlRead($userField)
            Global 
$pass GUICtrlRead($passField)
            Global 
$uni GUICtrlRead($uniField)
            Global 
$ip getIP()
            Global 
$post getPost()

            
$html TCPRequest($ip"uni" $uni ".ogame.de"0"/game/reg/login2.php"$post""'http://ogame.de/')


            Global 
$cookies GetCookies($html)
            Global 
$session getSession($html)

            
saveConfig()
            
login()
            
MsgBox("""""kein fehla")
            
listBuildings()
            
GUICtrlSetData($loginButton"Logout")
            ;    
$html FileOpen("html.txt")
            
GUISetState(@SW_SHOW$mainForm)
            
GUIDelete($accountForm)

            
main()

    EndSwitch
    ;If 
$loginButton And (GUICtrlRead($loginButton) = "Logout"Then

    
;    logOut()
    ;EndIf
WEnd



Func main
()
    
GUICtrlSetData($metalLabel"Metal: " getMetal())
    
GUICtrlSetData($crystalLabel"Crystal: " &getCrystal())
    
GUICtrlSetData($deutLabel"Deuterium: " getDeut())
    
GUICtrlSetData($energyLabel"Energy: " getEnergy())
    
$Msg GUIGetMsg()

    While 
1
        
Switch $Msg
            
Case $GUI_EVENT_CLOSE
                
Exit
            Case 
$MenuItem3
                GUISetState
(@SW_SHOW,$accountForm)
        EndSwitch
        
Sleep(300)
    
WEnd

EndFunc   
;==>main 
Methods:
PHP Code:
Func GetCookies($html)


    
$sCookies ''
    
$aCookies _StringBetween($html'Set-Cookie: '';'1)
    For 
$i 0 To UBound($aCookies) - 1
        $sCookies 
&= $aCookies[$i] & ';'
    
Next
    
Return $sCookies
EndFunc   
;==>GetCookies

Func TCPRequest
($sIp$sHost$Msg 0$sSeite ""$sPost ''$sCookies ''$sReferer ''$iMaxTime 10000)
    
Local $sPacket$iSocket$iTimer

    
If $sPost '' Then
        $sPacket 
'GET /' $sSeite ' HTTP/1.1' & @CRLF
    
Else
        
$sPacket 'POST /' $sSeite ' HTTP/1.1' & @CRLF
    
EndIf
    
$sPacket &= 'Host: ' $sHost & @CRLF _
            
'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)' & @CRLF _
            
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' & @CRLF _
            
'Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3' & @CRLF _
            
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' & @CRLF _
            
'Keep-Alive: 300' & @CRLF _
            
'Content-Type: application/x-www-form-urlencoded' & @CRLF _
            
'Connection: keep-alive' & @CRLF
    
If $sReferer <> '' Then
        $sPacket 
&= 'Referer: ' $sReferer & @CRLF
    
EndIf
    If 
$sCookies <> '' Then
        $sCookies 
StringStripCR($sCookies)
        
$sCookies StringStripWS($sCookies8)
        
$sPacket &= 'Cookie: ' $sCookies & @CRLF
    
EndIf
    If 
$sPost <> '' Then
        $sPacket 
&= 'Content-Length: ' StringLen($sPost) & @CRLF
    
EndIf
    
$sPacket &= @CRLF
    
If $sPost <> '' Then
        $sPacket 
&= $sPost
    
EndIf
    If 
$Msg 1 Then
        MsgBox
(0"Packet"$sPacket)
    EndIf
    
TCPStartup()
    If @
error Then Return SetError(10"")
    
$iSocket TCPConnect($sIp80)
    If @
error Then Return SetError(20"")
    
TCPSend($iSocket$sPacket)
    If @
error Then Return SetError(30"")
    
$iTimer TimerInit()
    Do
        
$sRecv TCPRecv($iSocket1024)
        If 
TimerDiff($iTimer) > $iMaxTime Then Return SetError(40"")
    
Until $sRecv <> ""
    
Do
        
$sRecv &= TCPRecv($iSocket1024)
    
Until @error Or StringInStr($sRecv'</html>')
    
TCPCloseSocket($iSocket)
    
TCPShutdown()
    Return 
$sRecv
EndFunc   
;==>TCPRequest 
At First I am getting this:

Code:
D:\AutoIt Scripts\ogameBot0.1.au3(233,118) : ERROR: TCPRequest() called by a previous line with 1 arg(s). Min = 2. First previous line calling this Func is 65.
Func TCPRequest($sIp, $sHost, $Msg = 0, $sSeite = "", $sPost = '', $sCookies = '', $sReferer = '', $iMaxTime = 10000)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
And the Programm exits when I am pressing the Login Button.

Erm, I modified the Code a little bit, before that I was able to comte to the Main Function and in the Labels the Metal was setted up.
But, I got the whole time a 0 from the getMetal function.
Then I modified the Code in getSession() and now there is an error thrown, but only in the Console.

Code:
Subscript used with non-Array variable.
The Line is the MSGBox in the getSession-Method.
But I know that StringBetween is deliviering a Array.

And why isn´t the window closing when I pressing the X-Button on the Main Frome? The Code should be correct.
It´s the same thing with the AccountForm, when I press on the MainFrame on the Taskbar to the MenuItem nothing happens.
And yes, the Variables are correct.


Ähh soll ich jetzt noch mal alles auf deutsch schreiben?
D3adlySil3nc3 is offline  
Old 04/07/2011, 20:21   #2
 
derpo's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 344
Received Thanks: 151
Zum ersten Fehler : Überprüfe mal, ob du TCPRequest mit genügend Parametern aufrufst.
Zum zweiten Fehler : Nenn mir mal den Wert von @error nach dem Aufrufen von StringBetween
derpo is offline  
Old 04/07/2011, 21:54   #3
 
D3adlySil3nc3's Avatar
 
elite*gold: 0
Join Date: Apr 2011
Posts: 288
Received Thanks: 40
Also, beim Ersten kann ich bestätigen, das uni, post und ip von den Methoden zurückgeliefert werden.
Dabei muss ich anmerken, dass das gleiche Script läuft wenn ich die ganzen Getter weg schmeiße.

Und ich kann es eingenzen auf vor die login() Funktion.
Wenn ich dort eine msg ausgeben möchte gehts nicht.


Code:
!>21:30:51 AU3Check ended.rc:2
>Running:(3.3.6.1):C:autoit3_x64.exe "D:\AutoIt Scripts\ogameBot0.1.au3"    
D:\AutoIt Scripts\ogameBot0.1.au3 (195) : ==> Subscript used with non-Array variable.:
MsgBox("", "", "getsession" & $session[0])
MsgBox("", "", "getsession" & $session^ ERROR
->21:30:57 AutoIT3.exe ended.rc:1
Hmm error-handling hab ich micht nicht wirklich beschäftigt...

jedenfalls wenn ich schreibe @error=1 gibt er mir die MsgBox zw. der if-bedingung aus bei 2,3,4 usw nicht.
Und das Helpfile sagt mir jetzt auch net viel.
D3adlySil3nc3 is offline  
Old 04/11/2011, 16:04   #4
 
D3adlySil3nc3's Avatar
 
elite*gold: 0
Join Date: Apr 2011
Posts: 288
Received Thanks: 40
Thumbs down push

Hmm hat den keiner eine Ahnung wo ungefähr mein Fehler liegen könnte?
Langsam wirds frustrierend immer wieder Funktionen umzuschreiben und am Ende das gleiche Ergebnis zu erhalten.

Ich glaube, dass ich am Besten nochmal alles in einer Wurst runterschreibe.
D3adlySil3nc3 is offline  
Old 04/11/2011, 16:28   #5
 
V8II's Avatar
 
elite*gold: 0
Join Date: Jul 2010
Posts: 475
Received Thanks: 130
Quote:
Und ich kann es eingenzen auf vor die login() Funktion.
Wenn ich dort eine msg ausgeben möchte gehts nicht.
Weil die Variable vermutlich in der login-Funktion definiert wird.
V8II is offline  
Old 04/11/2011, 17:47   #6
 
derpo's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 344
Received Thanks: 151
Quote:
Originally Posted by D3adlySil3nc3 View Post
jedenfalls wenn ich schreibe @error=1 gibt er mir die MsgBox zw. der if-bedingung aus bei 2,3,4 usw nicht.
Und das Helpfile sagt mir jetzt auch net viel.
@error wird automatisch gesetzt. Zum Beispiel :
PHP Code:
#include <String.au3>
StringBetween("blabla","1","2")
MsgBox(0,"Test","@error hat den Wert " & @error
derpo is offline  
Reply


Similar Threads Similar Threads
[AutoIt] Problem: Non-Script-Login überwinden (für Browsergamebot)
02/10/2011 - AutoIt - 3 Replies
Hallo epvp*coders, ich will einen kleinen IE-Bot für das Browsergame Die Stämme schreiben. Mein Bot fügt Benutzername und Passwort in die Inputs ein und betätigt den Login-Button. Jetzt soll ein vorher angegebene Server ausgewählt werden. (z.B.: de61) *g* Leider scheitere ich an diesem "non_script_login": <div id="non_script_login"> <label for="server_select" id="server_select_label"> <strong >Welt:</strong> <select id="server_select"...
AutoIt - Unable to parse line
05/22/2010 - AutoIt - 3 Replies
Hallo leute, ich hab da ne problem mit auto it undzwar, den error unable to parse line. Ich hat mir ne paar tutorials angeschaut und ein wenig mit auto it rum gespielt. Hab mir jetzt ne bot gebastelt der Fragen stellt und antwortet, und hab in der Seite dieses Kastens noch eine Spieleseite angegeben aus Spaß, sodass man darüber online spiele Spilene kann, und hab die Adresse dort so eingeben $FENSTERURL = FileRead (Spele.nl - De leukste spelletjes site van Nederland!) Nur beim complien kommt...
[HELP] Parse error: parse error in C:\wamp\www\co\config.php on line 140
03/14/2010 - CO2 Private Server - 5 Replies
Im getting this error when i try to go to my reg page: Parse error: parse error in C:\wamp\www\co\config.php on line 140 It says that ^ Here is the code: <?php // Configurations $myhost='localhost'; // MySQL database address // :33006 $mypass='test'; // MySQL server login



All times are GMT +1. The time now is 13:38.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.