Sign in to follow this  
Followers 0
vikingcoder

Same thing different results ?

1 post in this topic

Hi !

Today I was introduced to AutoIT and I must say it looks very promising. Eager to start coding I decided to read up on and start coding a very easy

card detector. Basically it should detect some pixels in a pokerwindow(play money) with PixelChecksum and with the help of that decide what card you have in your hand. My first code snippet was in a file and looked like this:

$window = "Play Money"  ; window name

;holecard 1
$x1=199
$y1=354
$x2=215
$y2=388
WinActivate($window)
$checksum1 = PixelChecksum($x1, $y1, $x2, $y2)

MsgBox(0, "Tutorial", $checksum1)

So I just ran the program a few times when I got a hand a made sure when I got the same holecard on tha position that it did show the same value, it went smooth.

Excited I went on to code some kind of GUI(with the help of some code examples on this site), so I had a file with this code:

#include <GUIConstants.au3>

$window = "Play Money"  ; window name

;Seat 1 coordinates, holecard 1
$x1=199
$y1=354
$x2=215
$y2=388

;Global variable
Global $x1,$x2,$y1,$y2

;----------------------------------------------------------
; GUI
;----------------------------------------------------------
$gui = GUICreate("Testpok", 200, 200,800,0)
GUICtrlCreateLabel("Hole Cards:", 8, 8, 59, 17)
$gui_hole_card_1 = GUICtrlCreateInput("", 72, 4, 25, 21)
$gui_hole_card_2 = GUICtrlCreateInput("", 104, 4, 25, 21)
$gui_progress_check = GUICtrlCreateProgress(0, 140, 137, 13)
GUICtrlCreateLabel("Flop:", 8, 40, 27, 17)
$gui_flop_card_1 = GUICtrlCreateInput("", 40, 36, 25, 21)
$gui_flop_card_2 = GUICtrlCreateInput("", 72, 36, 25, 21)
$gui_flop_card_3 = GUICtrlCreateInput("", 104, 36, 25, 21)
GUICtrlCreateLabel("Turn:", 72, 68, 29, 17)
$gui_turn_card = GUICtrlCreateInput("", 104, 64, 25, 21)
GUICtrlCreateLabel("River:", 72, 96, 32, 17)
$gui_river_card = GUICtrlCreateInput("", 104, 92, 25, 21)
GUICtrlCreateLabel("Checksum:", 0, 120, 75, 17)
$gui_checksum = GUICtrlCreateInput("", 54, 120, 75, 21)
$button = GUICtrlCreateButton ("Update",  30, 170, 100)

;Settings
opt("PixelCoordMode", 0)
opt("WinTitleMatchMode", 2)
WinSetOnTop("Testpoker", "", 1)
GUISetState (@SW_SHOW)

;Main Loop
While 1
   $msg = GUIGetMsg()
  Select
     Case $msg = $GUI_EVENT_CLOSE   
        Exitloop
    ;When update button gets pressed, find the checksum value for seat1 and holecard1
    ;and print it to the field($gui_checksum)
     Case $msg = $button
        WinActivate($window)
        $checksum1 = PixelChecksum($x1, $y1, $x2, $y2)
        GUICtrlSetData($gui_checksum, $checksum1)
    EndSelect
Wend

The idea is that when I press the update button it should show the checksum of holecard 1 (as in the first code snippet but with little GUI) and put it in the field($gui_checksum). Now here is the strange thing. When I do press the update button and update the checksum during a hand that I play the checksum values jumps like crazy even tho I have the same holecards, even without holecards it should not jump, but it does a lot. This didnt happen when I ran the first code snippet. Even tho I am new to this scripting language I can not really see what the problem is and want to kindly ask someone to point me in the right direction.

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