Sign in to follow this  
Followers 0
ratacat

I can't get any loops to work besides...

5 posts in this topic

#1 ·  Posted (edited)

here look at some of this code...why is this message coming up when I try to run it?

----------------------

Line 160

WEnd

Error: "Wend" statement with no matching "While" statement.

-----------------------

while $gotseat = 0
    chk_seat ($gotseat)
    if $taken = "1" then
    for $c = 0 to 8
        $cato = $seatselect[$c]
        mouseclick("left", $cato[1], $cato[2])
        do_buyin()
    next
WEnd

I tried this as well.

do
    chk_seat ($gotseat)
    if $taken = "1" then
    for $c = 0 to 8
        $cato = $seatselect[$c]
        mouseclick("left", $cato[1], $cato[2])
        do_buyin()
    next
loop until $gotseat = 1

please help...what am I doing wrong? This is a snippet...I assumed the rest of the code wouldn't affect this, but if anyone needs to see the rest for a true test...here it is. There is a lot of it, and it is messier then all hell. You'll have to excuse me in advance, I'm new to this.

;-----------------------------------------Options----------------------------------------------
Opt("WinTitleMatchMode", 2)

; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage");Shift-Alt-d


;-------------------------------------------Variables----------------------------------------
;VARIABLES    
$jumpto = "3"
$taken = "0"
$level = "0"
$gotseat = "0"
global $b, $ytable, $i, $lost
;------------------------------Determining Level of Engagement---------------------------

If WinExists ("PokerStars Lobby") then
 $level = "1"
endif

If WinExists ("PokerStars Lobby - Logged in as sandycat") then
 $level = "2"
endif

If WinExists ("no all-in") then
 $level = "3"
endif

;------------------------------------Main Loop--------------------------------------------

if $level = "0" then
    do_pstars()
    sleep(300)
    do_logon()
    sleep(300)
    get_table()
    sleep(300)
    get_seat2(0)
endif

If $level = "1" then
do_logon()
sleep(300)
get_table()
sleep(300)
get_seat2(0)
endif

If $level = "2" then
get_table()
sleep(300)
get_seat2(0)
endif

if $level = "3" then
get_seat2(0)
endif
if $lost >=2 then
do_scroll_down()
$lost = $lost +1
$i = 5
endif




;-------------------------------------Functions-------------------------------------------

func do_scroll_down ()
    WinActivate("PokerStars Lobby - Logged in as sandycat")
    WinWaitActive("PokerStars Lobby - Logged in as sandycat")
    mouseclick("left", 534, 422, 2)
endfunc


Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

func do_pstars ()
;___changes localdir to pstars home and runs pstar's exe
    FileChangeDir ("C:\Program Files\PokerStars")
    run("PokerStars.exe")
endfunc




func do_logon ()
;msgbox (262144, "loopstart2", $jumpto)
;___activates pstars window if it is minimized or in backdrop
    WinActivate("PokerStars Lobby")
    WinWaitACtive("PokerStars Lobby")


;___Uses keyboard Alt + L + Enter to access login menu
;send("!l")
;send("{ENTER}")

;___Uses two sets of mouseclicks to access login menu
    mouseclick("Left", 22, 39)
    sleep(100)
    mouseclick("Left", 33, 53)
    sleep(300)

;___Making sure windows is focus'ed on PStars login screen
    WinActivate("Login")
    MouseClick("Left", 423, 236)

;___Entering ******* as a password, and waiting for client
    send("*******", 1)
    Send("{ENTER}")
endfunc




func get_table ()
    get_random()
    WinActivate("PokerStars Lobby - Logged in as sandycat")
    WinWaitActive("PokerStars Lobby - Logged in as sandycat")
    sleep(300)

;___Select Hold'em Tables, then sort ascending stakes
    MouseClick("Left", 42, 157)
    sleep(300)

;___Open up tourney listed as 'b' or THe bottom on the list.
    MouseCLick("Left", 265, $ytable, 2)
endfunc

func get_seat2 ()
    WinActivate ("no all-in")
    WinWaitActive ("no all-in")
    
while $gotseat = 0
    chk_seat ($gotseat)
    if $taken = "1" then
    for $c = 0 to 8
        $cato = $seatselect[$c]
        mouseclick("left", $cato[1], $cato[2])
        do_buyin()
    next
WEnd

endfunc


func get_seat ($taken)
    WinActivate ("no all-in")
    WinWaitActive ("no all-in")
;seat1
    chk_seat ($gotseat)
    findseat ( 0, 205, 375)
    if $taken = "0" then
    MouseClick("left", 205, 375)
    endif
    

;seat2
        chk_seat ($gotseat)
        if $taken = "1" then
        findseat(0, 410, 407)
        endif
        if $taken = "0" then
        MouseClick("left", 410, 407)
        $alltaken = "0"
        endif
;seat3
            chk_seat ($gotseat)
            if $taken = "1" then
            findseat(0, 629, 371)
            endif
            if $taken = "0" then
            MouseClick("left", 629, 371)
            $alltaken = "0"
            endif
;seat4
                chk_seat ($gotseat)
                if $taken = "1" then
                findseat(0, 754, 264)
                endif
                if $taken = "0" then
                MouseClick("left", 754, 264)
                $alltaken = "0"
                endif
;seat5
                    chk_seat ($gotseat)
                    if $taken = "1" then
                    findseat(0, 676, 131)
                    endif
                    if $taken = "0" then
                    MouseClick("left", 676, 131)
                    $alltaken = "0"
                    endif
;seat6
                        chk_seat ($gotseat)
                        if $taken = "1" then
                        findseat(0, 538, 74)
                        endif
                        if $taken = "0" then
                        MouseClick("left", 538, 74)
                        $alltaken = "0"
                        endif
;seat7
                            chk_seat ($gotseat)
                            if $taken = "1" then
                            findseat(0, 298, 72)
                            endif
                            if $taken = "0" then
                            MouseClick("left", 298, 72)
                            $alltaken = "0"
                            endif
;seat8
                                chk_seat ($gotseat)
                                if $taken = "1" then
                                findseat(0, 162, 135)
                                endif
                                if $taken = "0" then
                                MouseClick("left", 162, 135)
                                $alltaken = "0"
                                endif
;seat9
                                    chk_seat ($gotseat)
                                    if $taken = "1" then
                                    findseat(0, 76, 271)
                                    endif
                                    if $taken = "0" then
                                    MouseClick("left", 76, 271)
                                    $alltaken = "0"
                                    endif
                                    mouseclick("left", 786, 11)
                                    


endfunc





func findseat ( $taken, $xs, $ys)
    $checkx = $xs - 8
    $checky = $ys - 8
    MouseMOve ( $xs, $ys)
    sleep (300)
    $colorcheck = PixelGetColor ( $checkx, $Checky)
;msgbox (262144, "color", $colorcheck)
    if $colorcheck = 16774863 then
    $taken = "1"
    endif
    return $taken
    
endfunc

func chk_seat ($gotseat)
    sleep(1000)
    if WinExists("Buy-in") then
    $b = 1
    endif
    if $b = 1 then
    $gotseat = "1"
    do_buyin()
    else
    $gotseat = "0"
    endif
    return $gotseat
endfunc

func do_buyin ()
WinWaitActive("Buy-in", "", 4)
if winactive("Buy-in") then
    mouseclick("left", 363, 333)
    sleep(300)
    mouseclick("left", 354, 487)
    sleep(300)
    mouseclick("left", 16, 416)
endif

endfunc



func get_random ()
local $adjust
local $xtable
$adjust = Int(random(1, 20))
$xtable = "265"
if $adjust <= "20" then
$ytable = "425"
elseif $adjust <= "15" then
$ytable = "410"
endif
if $adjust <= "10" then
$ytable = "398"
elseif $adjust <= "5" then
$ytable = "385"
endif
if $adjust = "4" then
$ytable = "372"
endif
endfunc
Edited by xeonz16

Share this post


Link to post
Share on other sites



try putting an endif after next

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That and SciTE for Autoit3. Tidy helps more than you realize with the auto code indentation and basic error checking.

Makes loop tracing so much easier.

Your code, with the "Endif" added in the proper spot, run through Tidy.

;-----------------------------------------Options----------------------------------------------
Opt ("WinTitleMatchMode", 2)

; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage");Shift-Alt-d


;-------------------------------------------Variables----------------------------------------
;VARIABLES
$jumpto = "3"
$taken = "0"
$level = "0"
$gotseat = "0"
Global $b, $ytable, $i, $lost
;------------------------------Determining Level of Engagement---------------------------

If WinExists("PokerStars Lobby") Then
   $level = "1"
EndIf

If WinExists("PokerStars Lobby - Logged in as sandycat") Then
   $level = "2"
EndIf

If WinExists("no all-in") Then
   $level = "3"
EndIf

;------------------------------------Main Loop--------------------------------------------

If $level = "0" Then
   do_pstars()
   Sleep(300)
   do_logon()
   Sleep(300)
   get_table()
   Sleep(300)
   get_seat2(0)
EndIf

If $level = "1" Then
   do_logon()
   Sleep(300)
   get_table()
   Sleep(300)
   get_seat2(0)
EndIf

If $level = "2" Then
   get_table()
   Sleep(300)
   get_seat2(0)
EndIf

If $level = "3" Then
   get_seat2(0)
EndIf
If $lost >= 2 Then
   do_scroll_down()
   $lost = $lost + 1
   $i = 5
EndIf




;-------------------------------------Functions-------------------------------------------

Func do_scroll_down()
   WinActivate("PokerStars Lobby - Logged in as sandycat")
   WinWaitActive("PokerStars Lobby - Logged in as sandycat")
   MouseClick("left", 534, 422, 2)
EndFunc  ;==>do_scroll_down


Func TogglePause()
   $Paused = Not $Paused
   While $Paused
      Sleep(100)
      ToolTip('Script is "Paused"', 0, 0)
   WEnd
   ToolTip("")
EndFunc  ;==>TogglePause

Func Terminate()
   Exit 0
EndFunc  ;==>Terminate

Func ShowMessage()
   MsgBox(4096, "", "This is a message.")
EndFunc  ;==>ShowMessage

Func do_pstars()
  ;___changes localdir to pstars home and runs pstar's exe
   FileChangeDir("C:\Program Files\PokerStars")
   Run("PokerStars.exe")
EndFunc  ;==>do_pstars




Func do_logon()
  ;msgbox (262144, "loopstart2", $jumpto)
  ;___activates pstars window if it is minimized or in backdrop
   WinActivate("PokerStars Lobby")
   WinWaitActive("PokerStars Lobby")
   
   
  ;___Uses keyboard Alt + L + Enter to access login menu
  ;send("!l")
  ;send("{ENTER}")
   
  ;___Uses two sets of mouseclicks to access login menu
   MouseClick("Left", 22, 39)
   Sleep(100)
   MouseClick("Left", 33, 53)
   Sleep(300)
   
  ;___Making sure windows is focus'ed on PStars login screen
   WinActivate("Login")
   MouseClick("Left", 423, 236)
   
  ;___Entering ******* as a password, and waiting for client
   Send("*******", 1)
   Send("{ENTER}")
EndFunc  ;==>do_logon




Func get_table()
   get_random ()
   WinActivate("PokerStars Lobby - Logged in as sandycat")
   WinWaitActive("PokerStars Lobby - Logged in as sandycat")
   Sleep(300)
   
  ;___Select Hold'em Tables, then sort ascending stakes
   MouseClick("Left", 42, 157)
   Sleep(300)
   
  ;___Open up tourney listed as 'b' or THe bottom on the list.
   MouseClick("Left", 265, $ytable, 2)
EndFunc  ;==>get_table

Func get_seat2()
   WinActivate("no all-in")
   WinWaitActive("no all-in")
   
   While $gotseat = 0
      chk_seat ($gotseat)
      If $taken = "1" Then
         For $c = 0 To 8
            $cato = $seatselect[$c]
            MouseClick("left", $cato[1], $cato[2])
            do_buyin ()
         Next
      EndIf
      
   WEnd
   
EndFunc  ;==>get_seat2


Func get_seat ($taken)
   WinActivate("no all-in")
   WinWaitActive("no all-in")
  ;seat1
   chk_seat ($gotseat)
   findseat (0, 205, 375)
   If $taken = "0" Then
      MouseClick("left", 205, 375)
   EndIf
   
   
  ;seat2
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 410, 407)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 410, 407)
      $alltaken = "0"
   EndIf
  ;seat3
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 629, 371)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 629, 371)
      $alltaken = "0"
   EndIf
  ;seat4
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 754, 264)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 754, 264)
      $alltaken = "0"
   EndIf
  ;seat5
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 676, 131)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 676, 131)
      $alltaken = "0"
   EndIf
  ;seat6
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 538, 74)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 538, 74)
      $alltaken = "0"
   EndIf
  ;seat7
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 298, 72)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 298, 72)
      $alltaken = "0"
   EndIf
  ;seat8
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 162, 135)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 162, 135)
      $alltaken = "0"
   EndIf
  ;seat9
   chk_seat ($gotseat)
   If $taken = "1" Then
      findseat (0, 76, 271)
   EndIf
   If $taken = "0" Then
      MouseClick("left", 76, 271)
      $alltaken = "0"
   EndIf
   MouseClick("left", 786, 11)
   
   
   
EndFunc  ;==>get_seat





Func findseat ($taken, $xs, $ys)
   $checkx = $xs - 8
   $checky = $ys - 8
   MouseMove($xs, $ys)
   Sleep(300)
   $colorcheck = PixelGetColor($checkx, $checky)
  ;msgbox (262144, "color", $colorcheck)
   If $colorcheck = 16774863 Then
      $taken = "1"
   EndIf
   Return $taken
   
EndFunc  ;==>findseat

Func chk_seat ($gotseat)
   Sleep(1000)
   If WinExists("Buy-in") Then
      $b = 1
   EndIf
   If $b = 1 Then
      $gotseat = "1"
      do_buyin ()
   Else
      $gotseat = "0"
   EndIf
   Return $gotseat
EndFunc  ;==>chk_seat

Func do_buyin ()
   WinWaitActive("Buy-in", "", 4)
   If WinActive("Buy-in") Then
      MouseClick("left", 363, 333)
      Sleep(300)
      MouseClick("left", 354, 487)
      Sleep(300)
      MouseClick("left", 16, 416)
   EndIf
   
EndFunc  ;==>do_buyin



Func get_random ()
   Local $adjust
   Local $xtable
   $adjust = Int(Random(1, 20))
   $xtable = "265"
   If $adjust <= "20" Then
      $ytable = "425"
   ElseIf $adjust <= "15" Then
      $ytable = "410"
   EndIf
   If $adjust <= "10" Then
      $ytable = "398"
   ElseIf $adjust <= "5" Then
      $ytable = "385"
   EndIf
   If $adjust = "4" Then
      $ytable = "372"
   EndIf
EndFunc  ;==>get_random
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

try putting an endif after next

<{POST_SNAPBACK}>

heh thanks a bunch I just checked it out...worked fine.

I feel awful silly now, but thankyou so much for that. I'd woulda spent the next 20 minutes trying to figure that out.

Share this post


Link to post
Share on other sites

For future reference, Au3Check would immediately spot all problems with this code:

AutoIt3 Syntax Checker v1.26  Copyright (c) Tylo 2005

C:\xeonz16.au3(148,18) : ERROR: get_seat2() previously called with 1 arg(s). Max = 0.
func get_seat2 ()
~~~~~~~~~~~~~~~~~^
C:\xeonz16.au3(156,32) : WARNING: $seatselect: possible used before declaration.
        $cato = $seatselect[$c]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\xeonz16.au3(160,1) : ERROR: missing EndIf.
WEnd
^
C:\xeonz16.au3(154,25) : REF: missing EndIf.
    if $taken = "1" then
~~~~~~~~~~~~~~~~~~~~~~~~^
C:\xeonz16.au3(156,32) : ERROR: $seatselect: undeclared global variable.
        $cato = $seatselect[$c]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\xeonz16.au3 - 3 error(s), 1 warning(s)

Tool completed with exit code 2

You can download Au3Check here


blub

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