drbarry920 Posted July 31, 2005 Share Posted July 31, 2005 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. Barrypoker.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (edited) See corresponding cross-thread.Edit: my apologies, the linked thread has the same code but focusses on a different problem. Edited July 31, 2005 by LxP Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 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 More sharing options...
Moderators SmOke_N Posted July 31, 2005 Moderators Share Posted July 31, 2005 (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 July 31, 2005 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 More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 31, 2005 Moderators Share Posted July 31, 2005 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 More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 How do I create the screen shot? Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 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 More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Here 'tispoker.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 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)? --expandcollapse popup; 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 More sharing options...
Moderators SmOke_N Posted July 31, 2005 Moderators Share Posted July 31, 2005 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 More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 I had to change the Tablenames to match the windows and I got a Window Name error.poker.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (edited) The first line should be a comment -- it's missing the semicolon at the start. Edited July 31, 2005 by LxP Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Tried it...still pausing and not functioing. PS Thanx for your patience. Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 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 More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Nope. Still not working. ANy other ideas or things i might need to troubleshoot? Thanx Barrypoker.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 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. Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 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. Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (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 andpaste everything that AutoIt3 Window Info has to say into a post? Edited July 31, 2005 by LxP Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 31, 2005 Moderators Share Posted July 31, 2005 (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. expandcollapse popupOpt("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 July 31, 2005 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 More sharing options...
Recommended Posts