Sign in to follow this  
Followers 0
lawpapa

Problems with iterations :S

10 posts in this topic

Error msg sais there is no matching while tag with wend statement, however there is :D

i wonder weather u saw something like this or not ::)

if i replace while with for There is the same error message with for: there is no matching for with statement next :x

$myvar1 = 0
$myvar2 = 0
$myvar3 = 0
$myvar4 = 0

$b = 1


winminimazeall ()

While ( 1 = 1 )

     Sleep (4000)

           select

        case $b = 1  

                      MouseClick( "left", 125, 752 )
                      Sleep(4000)
                  
                   if $myvar1 = 0 then

                    Func1 ()
              Func2 ()
                    RunWait( , "", @SW_HIDE )
                    Func3 ()

                   else
            Func4 ()

                   endif

                case $b = 2

                      MouseClick( "left", 292, 752 )
                      Sleep(4000)

                   if $myvar2 = 0 then

                    Func1 ()
              Func2 ()
                    RunWait( , "", @SW_HIDE )
                    Func3 ()

                   else
            Func4 ()
                   
                   endif

            case $b = 3
              MouseClick( "left", 468, 752 )
              Sleep(4000)

                   if $myvar3 = 0 then

                    Func1 ()
              Func2 ()
                    RunWait( , "", @SW_HIDE )
                    Func3 ()

                   else
            Func4 ()

                   endif

        case $b = 4
              MouseClick( "left", 625, 752 )
              Sleep(4000)

                   if $myvar4 = 0 then

                    Func1 ()
              Func2 ()
                    RunWait( , "", @SW_HIDE )
                    Func3 ()

                   else
            Func4 ()

                   endif

         endselect


    If $b = 4 then
    $b = 1
    else
    $b = $b + 1


wend

HEEEELP meeee ggrgrrgrgr :x:D:D:S:s:S:S B):o:graduated:

Share this post


Link to post
Share on other sites



oops and theese are the functions:

Func 2 ()

        if $localvar = 1 then

          Func 2b ()

        EndIf

  Return

EndFunc

Func 2b ()
 
  select

   case $b = 1 $myvar1 = 1
   case $b = 2 $myvar2 = 1
   case $b = 3 $myvar3 = 1
   case $b = 4 $myvar4 = 1

  endselect

  Return

EndFunc

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Error msg sais there is no matching while tag with wend statement, however there is :D

i wonder weather u saw something like this or not ::)

if i replace while with for There is the same error message with for: there is no matching for with statement next :x

HEEEELP meeee ggrgrrgrgr :x:D:D:S:s:S:S B):o:graduated:

change

While ( 1 = 1 )

to

while 1

Your runwaits look wrong too. Missing filenames

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

change

While ( 1 = 1 )

to

while 1

Your runwaits look wrong too. Missing filenames

HardCopy

Ty for reply my runwaits is ok in my original script i wrote filename and all the things

Anyway i tried to change to While (1) there is the same error message B):(:o

There is no matching while to wend statement :graduated:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Wow, that code is kind of all over the place...

I don't know where to start..

Ok..

1. Where is the function your calling when you start your script winminimazeall () ?

2. While (1 = 1) like HardCopy said Should be..

While 1

;script here

Wend

3. your function calls:

Func2()

Then your Func2 should look like this:

Func Func2()

;script here

EndFunc

4. RunWait( , "", @SW_HIDE)

If your calling to an executable where is it?

Example from help:

RunWait ( "filename" [, "workingdir" [, flag]] ) = RunWait("Notepad.exe", "C:\WINDOWS", @SW_MAXIMIZE)

5. Return , what result are you trying to return? Example, if I'm trying to return the result from $ABCD, it would be Return $ABCD, not just Return.

Try looking at these examples from what I've pointed out as definate problem areas, and then look at what they are supposed to do, and how they are supposed to be coded in the help file.

Hope this helps... Good Luck

Edit: Yes Just an Edit B)

Edited by ronsrules

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I did not ment to bother u with my full script B) I just made a model of it.

The problem of no matching while is resolved.. it was becuz of one single missing endif tag....

Here is the full version of my script:

Global $x, $y, $GameCount


$namivan1 = 0
$namivan2 = 0
$namivan3 = 0
$namivan4 = 0

$b = 1

$GameCreateDelay = 0
$Name = 0
$Pass = 0
$GameCount = 1

$SettingsFile = @SCRIPTDIR & '\Settings.ini'
;$SoundFile = @SCRIPTDIR & '\tada.wav'


$GameCreateDelay = IniRead ( $SettingsFile, 'Settings', 

'GameCreateDelay', "ERROR" )

$DCloneIP1 = IniRead ( $SettingsFile, 'Settings', 'DCloneIP1', 

999 ) & ":4000"
$DCloneIP2 = IniRead ( $SettingsFile, 'Settings', 'DCloneIP2', 

999 ) & ":4000"
$DCloneIP3 = IniRead ( $SettingsFile, 'Settings', 'DCloneIP3', 

999 ) & ":4000"
$DCloneIP4 = IniRead ( $SettingsFile, 'Settings', 'DCloneIP4', 

999 ) & ":4000"
$DCloneIP5 = IniRead ( $SettingsFile, 'Settings', 'DCloneIP5', 

999 ) & ":4000"



$ServerIp = '213.248.106.'


winminimazeall ()

While 1

     Sleep (4000)

           select

        case $b = 1  

                                   MouseClick( "left", 125, 752 )
                                   Sleep(4000)
                  
                                 if $namivan1 = 0 then

                                    Exitgame ()
              CreateGame ()
                    RunWait( @ComSpec & " /c " & 'netstat -n>c:\ip.txt' , "", @SW_HIDE )
                    CompareIP ()

                                   else
            Antiidle ()

                                   endif

                                 case $b = 2

                                      MouseClick( "left", 292, 752 )
                                      Sleep(4000)

            if $namivan2 = 0 then

                                    Exitgame ()
              CreateGame ()
                    RunWait( @ComSpec & " /c " & 'netstat -n>c:\ip.txt' , "", @SW_HIDE )
                    CompareIP ()

                                     else
             Antiidle ()
 
                                     endif

            case $b = 3
              MouseClick( "left", 468, 752 )
              Sleep(4000)

                  if $namivan3 = 0 then

                          Exitgame ()
              CreateGame ()
                    RunWait( @ComSpec & " /c " & 'netstat -n>c:\ip.txt' , "", @SW_HIDE )
                    CompareIP ()

                              else
               Antiidle ()

                              endif
  
        case $b = 4
              MouseClick( "left", 625, 752 )
              Sleep(4000)

                        if $namivan4 = 0 then

                                      Exitgame ()
                CreateGame ()
                      RunWait( @ComSpec & " /c " & 'netstat -n>c:\ip.txt' , "", @SW_HIDE )
                     CompareIP ()


                                     else
                Antiidle ()

                   endif

         endselect


    If $b = 4 then
    $b = 1
    else
    $b = $b + 1
        EndIf


wend


; =========== Subroutines ===============



Func CreateGame ()

;   WinActivate ( 'Diablo II' )
;   WinWaitActive ( 'Diablo II' )
    MouseClick( "left", 601, 482 )
      Sleep ( 1500 )
    $Name = Random ( 100000, 900000 )
    $Pass = Random ( 100000, 900000 )
    Send ( $Name & '{TAB}' )
      Sleep ( 250 )
    Send ( $Pass & '{ENTER}' )
      Sleep ( $GameCreateDelay + 250 )
    EndFunc

  Return

Func CompareIP ()

    Local $IPStart
      $A = 1
      $hit = 0

      for $i = 1 to 20
          $CheckIP = FileReadLine ( 'C:\ip.txt', $A )

           ;Only check if server IP is part of the current 

line and it's port 4000
            $IPStart   = StringInStr ( $CheckIP, $ServerIP )
            $PortStart = StringInStr ( $CheckIP, ":4000" )

              If ( $IPStart >0 ) and ( $PortStart>0 ) then
                SplashTextOn ( 'lawHunter 2.2', "Current try: " 

& $GameCount &@CRLF & "Current IP: " &StringMid ( $CheckIp, 

$IPStart, $PortStart-$IPStart ), 200, 100,824,0 )
                 ;WinActivate ( 'Diablo II' )
             if StringInStr ( $CheckIP, $ServerIP & $DCloneIP1 ) > 0 then $hit = 1
             if StringInStr ( $CheckIP, $ServerIP & $DCloneIP2 ) > 0 then $hit = 1
             if StringInStr ( $CheckIP, $ServerIP & $DCloneIP3 ) > 0 then $hit = 1
             if StringInStr ( $CheckIP, $ServerIP & $DCloneIP4 ) > 0 then $hit = 1
             if StringInStr ( $CheckIP, $ServerIP & $DCloneIP5 ) > 0 then $hit = 1
              EndIf

          $A = $A + 1
      next

        if $hit = 1 then

          CloneFound ()

        EndIf

    $GameCount = $GameCount + 1

  Return

EndFunc

Func ExitGame ()

;   WinActivate ( 'Diablo II', ',' )
      Sleep ( 250 )
    Send ( '{ESC}' )
      Sleep ( 250 )
    Send ( '{UP}' )
      Sleep ( 250 )
    Send ( '{ENTER}' )
      Sleep ( 5000 )

  Return

EndFunc

Func CloneFound ()
 
  select

   case $b = 1 $namivan1 = 1
   case $b = 2 $namivan2 = 1
   case $b = 3 $namivan3 = 1
   case $b = 4 $namivan4 = 1

  endselect

;     filedelete ( 'c:\ip.txt' )
;     SoundPlay ( $SoundFile )

;    While WinActive ( 'Diablo II' )

  Return

EndFunc

Func Antiidle ()

    Send ( '{ENTER}' )
    Send ( "bla" )
    Send ( '{ENTER}' )
    Sleep ($GameCreateDelay)

  Return
EndFunc

Share this post


Link to post
Share on other sites

Actually, you didn't take my advice, your script is a mess... everything I said that was wrong with it was. You're not missing and 'EndIf', your returns were not returning anything, you have function calls with no functions. Please find the SciTE Editor by searching the forum for JdEB, look in his signature and you'll see the link for download.

Your life will be much easier in the future... BTW, I don't play the game Diablo, but never new you had to use netstat to play it?

I doubt seriously this works like you want it to, but I cleaned it up so there were no errors.

Global $x, $y, $GameCount
Dim $Name, $Pass

$namivan1 = 0
$namivan2 = 0
$namivan3 = 0
$namivan4 = 0

$b = 1

$GameCreateDelay = 0
$Name = 0
$Pass = 0
$GameCount = 1

$SettingsFile = @ScriptDir & '\Settings.ini'
;$SoundFile = @SCRIPTDIR & '\tada.wav'


$GameCreateDelay = IniRead($SettingsFile, 'Settings', 'GameCreateDelay', "ERROR")

$DCloneIP1 = IniRead($SettingsFile, 'Settings', 'DCloneIP1', 999) & ":4000"
$DCloneIP2 = IniRead($SettingsFile, 'Settings', 'DCloneIP2', 999) & ":4000"
$DCloneIP3 = IniRead($SettingsFile, 'Settings', 'DCloneIP3', 999) & ":4000"
$DCloneIP4 = IniRead($SettingsFile, 'Settings', 'DCloneIP4', 999) & ":4000"
$DCloneIP5 = IniRead($SettingsFile, 'Settings', 'DCloneIP5', 999) & ":4000"

$ServerIp = '213.248.106.'

;winminimazeall ()

While 1
   
   Sleep(4000)
   
   Select
      
      Case $b = 1
         
         MouseClick( "left", 125, 752)
         Sleep(4000)
         
         If $namivan1 = 0 Then
            
            ExitGame()
            CreateGame()
            RunWait(@ComSpec & " /c " & 'netstat -n>c:\ip.txt', "", @SW_HIDE)
            CompareIP()
            
         Else
            Antiidle()
            
         EndIf
         
      Case $b = 2
         
         MouseClick( "left", 292, 752)
         Sleep(4000)
         
         If $namivan2 = 0 Then
            
            ExitGame()
            CreateGame()
            RunWait(@ComSpec & " /c " & 'netstat -n>c:\ip.txt', "", @SW_HIDE)
            CompareIP()
            
         Else
            Antiidle()
            
         EndIf
         
      Case $b = 3
         MouseClick( "left", 468, 752)
         Sleep(4000)
         
         If $namivan3 = 0 Then
            
            ExitGame()
            CreateGame()
            RunWait(@ComSpec & " /c " & 'netstat -n>c:\ip.txt', "", @SW_HIDE)
            CompareIP()
            
         Else
            Antiidle()
            
         EndIf
         
      Case $b = 4
         MouseClick( "left", 625, 752)
         Sleep(4000)
         
         If $namivan4 = 0 Then
            
            ExitGame()
            CreateGame()
            RunWait(@ComSpec & " /c " & 'netstat -n>c:\ip.txt', "", @SW_HIDE)
            CompareIP()
            
            
         Else
            Antiidle()
            
         EndIf
         
   EndSelect
   
   
   If $b = 4 Then
      $b = 1
   Else
      $b = $b + 1
   EndIf
   
   
WEnd


; =========== Subroutines ===============



Func CreateGame()
   
  ; WinActivate ( 'Diablo II' )
  ; WinWaitActive ( 'Diablo II' )
   MouseClick( "left", 601, 482)
   Sleep(1500)
   $Name = Random(100000, 900000)
   $Pass = Random(100000, 900000)
   Send($Name & '{TAB}')
   Sleep(250)
   Send($Pass & '{ENTER}')
   Sleep($GameCreateDelay + 250)
EndFunc  ;==>CreateGame 

Func CompareIP()
   
   Local $IPStart
   $A = 1
   $hit = 0
   
   For $i = 1 To 20
      $CheckIP = FileReadLine('C:\ip.txt', $A)
      
     ;Only check if server IP is part of the current line and it's port 4000
      $IPStart = StringInStr($CheckIP, $ServerIp)
      $PortStart = StringInStr($CheckIP, ":4000")
      
      If ($IPStart > 0) and ($PortStart > 0) Then
         SplashTextOn('lawHunter 2.2', "Current try: " & $GameCount & @CRLF & "Current IP: " & StringMid($CheckIP, $IPStart, $PortStart - $IPStart), 200, 100, 824, 0)
        ;WinActivate ( 'Diablo II' )
         If StringInStr($CheckIP, $ServerIp & $DCloneIP1) > 0 Then $hit = 1
         If StringInStr($CheckIP, $ServerIp & $DCloneIP2) > 0 Then $hit = 1
         If StringInStr($CheckIP, $ServerIp & $DCloneIP3) > 0 Then $hit = 1
         If StringInStr($CheckIP, $ServerIp & $DCloneIP4) > 0 Then $hit = 1
         If StringInStr($CheckIP, $ServerIp & $DCloneIP5) > 0 Then $hit = 1
      EndIf
      
      $A = $A + 1
   Next
   
   If $hit = 1 Then
      
      CloneFound()
      
   EndIf
   
   $GameCount = $GameCount + 1
   
   Return $GameCount
   
EndFunc  ;==>CompareIP 

Func ExitGame()
   
  ; WinActivate ( 'Diablo II', ',' )
   Sleep(250)
   Send('{ESC}')
   Sleep(250)
   Send('{UP}')
   Sleep(250)
   Send('{ENTER}')
   Sleep(5000)
EndFunc  ;==>ExitGame 

Func CloneFound()
   
   Select
      
      Case $b = 1
         $namivan1 = 1
      Case $b = 2
         $namivan2 = 1
      Case $b = 3
         $namivan3 = 1
      Case $b = 4
         $namivan4 = 1
         
   EndSelect
   
  ;   filedelete ( 'c:\ip.txt' )
  ;   SoundPlay ( $SoundFile )
   
  ;  While WinActive ( 'Diablo II' )
   
EndFunc  ;==>CloneFound 

Func Antiidle()
   
   Send('{ENTER}')
   Send("bla")
   Send('{ENTER}')
   Sleep($GameCreateDelay)
EndFunc  ;==>Antiidle

Good Luck to you, and be sure to read the Help file on the 'Commands' you're using and the proper ways to use them.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Ty so much for everybody especially for Ron

This is high time to see how it works in practice

:o

B)

however i cant use functions properly i think this is quite nice achievement in 2 days of programing autoit-

Edited by lawpapa

Share this post


Link to post
Share on other sites

I sense a language barrier too, so Kudos to you for 2 days. [playful sarcasm] But 'nothing is an achievement, until it's achieved' [/playful sarcasm]


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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