Jump to content

Rookie: Can't get it to work


Recommended Posts

Hi everybody...

All new in this forum, but looking for some help with the amazing program called AutoIT that I downloaded today- together with some scripts.

When I try to run a script, say the example calculator&notepad&count-while, they do not work.

I will see the calculator, but nothing is being typed.... or the notepad will come up but no text is being auto writed in there....

im running a danish version of windows xp if that does matter... I will offcourse respond in this topic... looking forward to some assistance ;) cheers! :lmao:

Link to comment
Share on other sites

  • Moderators

Welcome to the forums. Want to post the code that isn't working for you that you've tried?

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.

Link to comment
Share on other sites

Programs don't work because your Windows is Danish. You gotta see what's the title of window when you start Calculator or Notepad.

In polish version you would have to change Calculator to Kalkulator, and Notepad to Notatnik and it would work. So all:

WinWaitActive("Calculator")

WinClose("Calculator")

WinWaitClose("Calculator")

have to be modified to your language version. Everything should work then. Most AutoIT scripts are based on English version so you gotta check them before running.

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

offcourse...

these are the standards examples and when I run them nothing happens besides calc.exe & notepad.exe opens ?

Hi, I`ve modifited your scripts to my language and it realy works - is your windows title realy "Untitled - Notepad"?

Edited by rudika

[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

Link to comment
Share on other sites

Hi, I`ve modifited your scripts to my language and it realy works - is your windows title realy "Untitled - Notepad"?

Thanks for your answers... I works now :lmao:) and copying from the AutoIT window is great...

Have a new problem now, hope you can help. Get the error

"AutoIt Error

Line 51 (File "C:\.......\....\script.au3"):

elseif $action = 4 then

elseif ^ ERROR

Error: Variable used without being declared"

and here are my text from line 51 and 4 sentence down

elseif $action = 4 then

ControlClick($tablename, "", $RaiseButton);

endif

WEnd

anyone know whats wrong? I can give you more info if you need it :">

Link to comment
Share on other sites

Thanks for your answers... I works now :lmao:) and copying from the AutoIT window is great...

Have a new problem now, hope you can help. Get the error

"AutoIt Error

Line 51 (File "C:\.......\....\script.au3"):

elseif $action = 4 then

elseif ^ ERROR

Error: Variable used without being declared"

Did you declare this variable before line 51 - the error message is indicate for it...

Edited by rudika

[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

Link to comment
Share on other sites

Did you declare this variable before line 51 - the error message is indicate for it...

I havent declared

"elseif $action = 4 then

ControlClick($tablename, "", $RaiseButton);

endif"

before

but later in the script I have a line saying

"$color = PixelGetColor (338, 88);

if $color = 65280 then

WinActivate($tablename);

return 4;

endif

WinActivate($tablename);

return 1;

EndFunc"

Link to comment
Share on other sites

Since I have a really good idea of what your script is (because it's been on these forums half a million times already), it would be simplest just to put a "global $action" statement at the top with the rest of the globals.

there is only one other global action on top....

I have all together four of these $action = 1,2,3,4 with some lines under them. Should they all go into global actions?

anyone on messenger? write pm perhaps

Link to comment
Share on other sites

$action is a variable. Anything with the $ in front of it is a variable in AutoIt. Variables store data, in this case a number. So $action can be either 1, 2, 3, 4, or none of them. By putting "global $action" at the top of the script, you are saying the $action variable will be used throughout the whole script.

I suggest you read this thread

http://www.autoitscript.com/forum/index.php?showtopic=19434

and the helpfile.

Other topics related to your script:

http://www.autoitscript.com/forum/index.php?showtopic=20534

http://www.autoitscript.com/forum/index.php?showtopic=19764

Link to comment
Share on other sites

$action is a variable. Anything with the $ in front of it is a variable in AutoIt. Variables store data, in this case a number. So $action can be either 1, 2, 3, 4, or none of them. By putting "global $action" at the top of the script, you are saying the $action variable will be used throughout the whole script.

Other topics related to your script:

http://www.autoitscript.com/forum/index.php?showtopic=20534

Having the exact same problem as topic 20534. Do you know how this guy figured it out ? have tried to read the post... hmm :lmao:

Edited by Salomonsson
Link to comment
Share on other sites

Ok, you didn't need to make action a global variable. What you needed to do was fix the indenting and the If/Endif ratio.

; Pre-initialization : Set Name of Table
Global $tablename = "Play money 4014630"

; Initialize Buttons
; These are the button names you might have to change these for different poker clients
$FoldButton = "AfxWnd42s20"
$CheckButton = "AfxWnd42s20"
$CallButton = "AfxWnd42s22"
$BetButton = "AfxWnd42s22"
$RaiseButton = "AfxWnd42s23"

; Set Coordinate mode to relative to window
AutoItSetOption("PixelCoordMode", 0)

; Wait for the window of table to become active
WinWaitActive($tablename)

; Main Loop
While WinExists($tablename)
    Sleep(300);
    $FoldVisible = ControlCommand($tablename, "", $FoldButton, "IsVisible", "");
    $RaiseVisible = ControlCommand($tablename, "", $RaiseButton, "IsVisible", "");
    If $FoldVisible = 1 Then
        Sleep(Random(1500, 2500))
        $action = GetAction();
        
       ; Fold/Check
       ; if we can check for free, then do that instead of folding
        If $action = 1 Then
            If StringInStr(ControlGetText($tablename, "", $CheckButton), "Check") = 1 Then
                ControlClick($tablename, "", $CheckButton);
            Else
                ControlClick($tablename, "", $FoldButton);
            EndIf
            
           ; Check/Call
           ;Sleep(Random(0, 2000));
        ElseIf $action = 2 Then
            ControlClick($tablename, "", $CallButton);
            
           ; Call/Bet
           ; if we can call then call otherwise bet
        ElseIf $action = 3 Then
            If StringInStr(ControlGetText($tablename, "", $CallButton), "Call") = 1 Then 
                ControlClick($tablename, "", $CallButton);
            Else
                ControlClick($tablename, "", $BetButton);
            EndIf
            
           ; Bet/Raise
           ;Sleep(Random(0, 2000));
        ElseIf $action = 4 Then
            ControlClick($tablename, "", $RaiseButton);
        EndIf
    EndIf
WEnd

; Poker Inspector Actions
Func GetAction()
    WinActivate("Connected to """ & $tablename);
    
   ; red - fold
    $color = PixelGetColor(338, 55);
    If $color = 255 Then
        WinActivate($tablename);
        Return 1;
    EndIf
    
   ;yellow
    $color = PixelGetColor(338, 67);
    If $color = 65535 Then
        WinActivate($tablename);
        Return 2;
    EndIf
    
   ; blue
    $color = PixelGetColor(338, 79);
    If $color = 16776960 Then
        
       ; sometimes bet or just call 50% of the time
        WinActivate($tablename);
        Return 3;
    EndIf
    
   ; green
    $color = PixelGetColor(338, 88);
    If $color = 65280 Then
        
       ; If we've got the nuts or close to then sometimes just check 20% of the time
       ; otherwise raise or reraise
        WinActivate($tablename);
        Return 4;
    EndIf
    WinActivate($tablename);
    Return 1;
EndFunc  ;==>GetAction

; Checks how many empty seats there are
Func OccupiedSeats()
    Local $Count = 0
    Local $SeatOpenColor = 3246765
    
   ;Seat 1
    If (PixelGetColor(517, 96) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ;Seat 2
    If (PixelGetColor(665, 133) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ;Seat 3
    If (PixelGetColor(735, 251) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 4
    If (PixelGetColor(660, 378) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 5
    If (PixelGetColor(493, 413) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 6
    If (PixelGetColor(262, 413) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 7
    If (PixelGetColor(108, 378) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 8
    If (PixelGetColor(53, 247) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 9
    If (PixelGetColor(126, 133) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    
   ; Seat 10
    If (PixelGetColor(264, 96) == $SeatOpenColor) Then
        $Count = $Count + 1;
    EndIf
    Return $Count;
EndFunc  ;==>OccupiedSeats

Get Scite if you don't already have it. With Scite is Tidy. Use it often.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...