Jump to content

Need Help With Code


Recommended Posts

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

Link to comment
Share on other sites

  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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)
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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. :)

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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