Sign in to follow this  
Followers 0
drbarry920

Need Help With Code

70 posts in this topic

Let me tell you what I want to create. When playing online poker I use a program called No Hands Holdem that gives suggested actions based on the cards shown by calculating odds for you.

This information is a text word located (Using the AUtoIt WIndow Info) at WindowsForm10.STATIC.app319. There are 5 possibilities.

I want to then automatically press the appropriate button on the poker server that

corresponds with the action suggested in the 1st program.

I've put together the code based on the help that comes with AUto it. I've attached the code.

Thanx for your help.

Barry

poker.txt

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

See corresponding cross-thread.

Edit: my apologies, the linked thread has the same code but focusses on a different problem.

Edited by LxP

Share this post


Link to post
Share on other sites

Okay, it looks like you want to populate the $action variable depending on the output of the window referenced by $tablename2. You probably want to do this within your If..EndIf block and just after the Sleep() instruction.

Oops -- it looks like you're referencing the field name by $action too; you might want to rename that variable to $actionField or similar.

After making that change and also the changes discussed in the corresponding cross-thread, something like this should do the trick:

$action = controlGetText($tablename2, "", $actionField)
; message box for debugging purposes
msgBox(64, "$actionField returns:", $action)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yep, you got it right on the nose LxP:

$tablename2 being the Brain Client, and $actionField being the control to read.

Edit: It's late: don't think control is spelled controld :) (fixed..lol)

Edited by ronsrules

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.

Share this post


Link to post
Share on other sites

Not working.

I wish there was way I can get the "Brain Client" program to you so you can help me figure out how to extract the "suggestion box" info and send it to the Poker program to press the button.

Thanx

Barry

Share this post


Link to post
Share on other sites

Alot of these clients drbarry use static controls, so that you can't build bots without knowing how to use their .dll calls.

Can you do a screen shot of the Brain Client?


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.

Share this post


Link to post
Share on other sites

How do I create the screen shot?

Share this post


Link to post
Share on other sites

Not working.

Okay, my legs are tired from running from this thread to the other. I propose that we leave the Scirpt Paused thread just the task of fixing your pausing problem (for which I've given you a solution) and we'll discuss the rest here.

Could you please post your revised code with the WinWait() change? We'll take it from there. :)

Share this post


Link to post
Share on other sites

Alrighty, almost there. What we need to do is move the ControlGetText() line so that it is checked on each pass of the loop.

How does this code function for you (you may wish to comment out the MsgBox()es)? --

; Window names
$pokerWindow = "Table 32371"
$brainWindow = "Hold'em - $0.50/$1"

; Poker button control IDs
$foldButton = "AfxWnd42s14"
$checkButton = "AfxWnd42s15"
$callButton = "AfxWnd42s15"
$betButton = "AfxWnd42s16"
$raiseButton = "AfxWnd42s16"

; No Hands action suggestion field
$actionField = "WindowsForm10.STATIC.app314"

; Wait for the two windows to be displayed
winWait($pokerWindow)
winWait($brainWindow)

msgBox(64, "AutoIt", "Both windows now exist; starting loop")

while (winExists($pokerWindow) and winExists($brainWindow))

    sleep(300)
    $foldVisible = controlCommand($pokerWindow, "", $foldButton, "isVisible", "")
    $raiseVisible = controlCommand($pokerWindow, "", $raiseButton, "isVisible", "")

    if ($foldVisible = 1) then
        msgBox(64, "AutoIt", "Fold is visible; attempting to read from brain in a moment")
        sleep(random(1500, 2500))
        $action = controlGetText($brainWindow, "", $actionField)
        msgBox(64, "AutoIt", "Brain returns:" & @CRLF & $action)
        if $action = "Fold" then controlClick($pokerWindow, "", $foldButton)
        if $action = "Check" then controlClick($pokerWindow, "", $checkButton)
        if $action = "Bet" then controlClick($pokerWindow, "", $betButton)
        if $action = "Raise" then controlClick($pokerWindow, "", $raiseButton)
        if $action = "Call" then controlClick($pokerWindow, "", $callButton)
    endIf

wEnd

Share this post


Link to post
Share on other sites

First... This could be harder than it looks if a screen shot is a native use for you. Screen Shot = Click on window you want to take a picture of - Alt+Print Scrn Button (by F12), Open Paint Start | All Programs | Accessories | Paint (windows xp) | Edit | Paste | Save as .jpg / .gif.

Second... WindowsForm10.STATIC.app319 - I assume that is the control box where the commands to Fold / Check etc... are in. Something tells me that the "STATIC" part is going to cause you problems.


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.

Share this post


Link to post
Share on other sites

I had to change the Tablenames to match the windows and I got a Window Name error.

poker.txt

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

The first line should be a comment -- it's missing the semicolon at the start.

Edited by LxP

Share this post


Link to post
Share on other sites

Tried it...still pausing and not functioing.

PS Thanx for your patience. :)

Share this post


Link to post
Share on other sites

From your screenshot it looks like the second line of the script should read:

$pokerWindow = "Play money"

and not:

$pokerWindow = "Play Money"

(note the case of the M). After changing that, how do things work for you?

Share this post


Link to post
Share on other sites

Nope.

Still not working.

ANy other ideas or things i might need to troubleshoot?

Thanx

Barry

poker.txt

Share this post


Link to post
Share on other sites

Which message boxes are displayed when you run the script? This will let us know how far the script gets and narrow down the error.

Share this post


Link to post
Share on other sites

It is bouncing back and forth between

"Fold is visible; attempting to read from Brain in a moment."

&

"Brain Returns"

It sems to not be reading what th Brain is actually saying and the buttons are not being pressed.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

This confirms that there's an error in the content of $brainWindow and/or $actionField. Could you please:

  • set the 'brain' window to display a suggestion;
  • run AutoIt Window Info on the 'brain' window and
  • paste everything that AutoIt3 Window Info has to say into a post?
Edited by LxP

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Ok U2, using LxP's neatly written: I just went ahead and downloaded the application. You were looking at the wrong things is all.

Opt("WinTitleMatchMode", 4)

; Window names
$pokerWindow = ""; whatever your poker room name is
$brainWindow = "classname=WindowsForms10.window.8.app3"

; Poker button control IDs
$foldButton = "AfxWnd42s14"
$checkButton = "AfxWnd42s15"
$callButton = "AfxWnd42s15"
$betButton = "AfxWnd42s16"
$raiseButton = "AfxWnd42s16"

; No Hands action suggestion field
$actionField = 461808

; Wait for the two windows to be displayed
WinWait($pokerWindow)
WinWait($brainWindow)

MsgBox(64, "AutoIt", "Both windows now exist; starting loop")

while (WinExists($pokerWindow) And WinExists($brainWindow))
   
   Sleep(300)
   $foldVisible = ControlCommand($pokerWindow, "", $foldButton, "IsVisible", "")
   $raiseVisible = ControlCommand($pokerWindow, "", $raiseButton, "IsVisible", "")
   
   if ($foldVisible = 1) Then
      MsgBox(64, "AutoIt", "Fold is visible; attempting to read from brain in a moment")
      Sleep(Random(1500, 2500))
      $action = ControlGetText($brainWindow, "", $actionField)
      MsgBox(64, "AutoIt", "Brain returns:" & @CRLF & $action)
      If $action = "Fold" Then ControlClick($pokerWindow, "", $foldButton)
      If $action = "Check" Then ControlClick($pokerWindow, "", $checkButton)
      If $action = "Bet" Then ControlClick($pokerWindow, "", $betButton)
      If $action = "Raise" Then ControlClick($pokerWindow, "", $raiseButton)
      If $action = "Call" Then ControlClick($pokerWindow, "", $callButton)
   EndIf
   
WEnd

Added Opt so you get your titles right: Note the classname= , because your title may change alot because it picks up the title of the room.

Edit: Oh, and used the ControlID... Have no idea what you were using.

Edited by ronsrules

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.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0