drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 In order to have that 'Brain' window up, I must have a poker window open to. How do I choose which window to run this code on...or does it matter? Thanx Barry Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Here 'tisClassList.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 It won't matter -- the code I posted will work with the 'brain' window (unless of course the window also likes to change its class name each time, which we'll shortly find out). Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Here tistest.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (edited) Oops -- could you please rename that same file as an AutoIt script, run it and then post the resultant ClassList.txt file that appears on your desktop?Edit: ignore me! I just saw your last post which has what I want. Sorry again. (This is the problem with stereophonic messaging!) 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 I did...posted wrong txt file ClassList.txt Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 Beautiful. I'm going to start coding something based on the assumption that while the control has a different class name each time the window opens, it always begins with WindowsForms10.STATIC.app3.Please let me know if you discover otherwise and I'll get back to you shortly. Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (edited) We are close now. Please run this code with your windows open and let me know how it goes:Edit: should place the actual values in one of the lines and not just x...Edit: and know that control IDs are 1-based...Edit: no such thing as a += operator...opt("winTitleMatchMode", 4) local $id = _theControl() if ($id <> "") then local $action = controlGetText("classname=WindowsForms10.window.8.app3", "", $id) msgBox(64, "Success", "The control ID in this instance is '" & $id & "' and its value is " & $action) else msgBox(16, "Failure", "No such luck this time...") endIf func _theControl() local $counter = 1 local $pos local $id while ($counter < 1000) $id = "WindowsForms10.STATIC.app3" & $counter $pos = controlGetPos("classname=WindowsForms10.window.8.app3", "", $id) if (isArray($pos) and $pos[0] = 464 and $pos[1] = 96 and $pos[2] = 80 and $pos[3] = 32) then return $id $counter = $counter + 1 wEnd return "" endFunc 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 Got an Unknown Function name error in: if ($pos[0] = x and $pos[0] = x and $pos[0] = x and $pos[0] = x) then return $id Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 Sorry, dumb error on my part is fixed now. Please try again. Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Error in same line: Subscript used with non-array variable. Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (edited) Fixed. Third time lucky?...Edit: for those who have been trying to follow this saga, what the window is doing is creating its controls in a random order each time the window is created. This means that we can never address the item on the window by a constant name -- we can only search for it by its position in the window. 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 Error: Expected a "=" oerator in assignment statement $ counter +=1 should that be $counter = 1? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 31, 2005 Moderators Share Posted July 31, 2005 Ugh... You guys are still going at it.. 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...
LxP Posted July 31, 2005 Share Posted July 31, 2005 Argh! Should be $counter = $counter + 1. Will fix in above code. Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 Im in Florida...I went to sleep for 6 hours and just got up Link to comment Share on other sites More sharing options...
drbarry920 Posted July 31, 2005 Author Share Posted July 31, 2005 I believe we got a successful response: The conrol ID in this instance is "WindowsForms10.STATIC.app326" and its value is Fold Link to comment Share on other sites More sharing options...
LxP Posted July 31, 2005 Share Posted July 31, 2005 (edited) Try this on for size:Edit: was missing a bracket.Edit: should detect all windows automatically now.Edit: debugging message boxes.expandcollapse popup; Detect windows by class name opt("winTitleMatchMode", 4) ; Poker button control IDs local $foldButton = "AfxWnd42s14" local $checkButton = "AfxWnd42s15" local $callButton = "AfxWnd42s15" local $betButton = "AfxWnd42s16" local $raiseButton = "AfxWnd42s16" ; Wait for the two windows to be displayed msgBox(64, "AutoIt", "Going to wait for the Poker window") winWait("classname=#32770", "Auto Post Blind") msgBox(64, "AutoIt", "Poker window found -- now going to wait for the brain window") winWait("classname=WindowsForms10.window.8.app3", "Chance to Win:") msgBox(64, "AutoIt", "Windows now exist") ; Window handles local $pokerWindow = winGetHandle("classname=#32770", "Auto Post Blind") local $brainWindow = winGetHandle("classname=WindowsForms10.window.8.app3", "Chance to Win:") msgBox(64, "AutoIt", "Handles are '" & $pokerWindow & "' and '" & $brainWindow & "'; neither should be empty") while (winExists($pokerWindow) and winExists($brainWindow)) sleep(300) local $foldVisible = controlCommand($pokerWindow, "", $foldButton, "isVisible", "") local $raiseVisible = controlCommand($pokerWindow, "", $raiseButton, "isVisible", "") if ($foldVisible) then sleep(random(1500, 2500)) local $action = _action($brainWindow) 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 func _action($brainWindow) local $counter = 1 while ($counter <= 100) local $id = "WindowsForms10.STATIC.app3" & $counter local $pos = controlGetPos($brainWindow, "", $id) if (isArray($pos) and $pos[0] = 464 and $pos[1] = 96 and $pos[2] = 80 and $pos[3] = 32) then _ return controlGetText($brainWindow, "", $id) $counter = $counter + 1 wEnd return "" endFunc Edited August 1, 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 This works on mine: expandcollapse popup; Detect windows by class name opt("winDetectHiddenText", 1) opt("winTitleMatchMode", 4) Opt("MouseCoordMode", 0) ; Window handles Global $pokerWindow = WinGetTitle("Play money ") Global $brainWindow = WinGetTitle("classname=WindowsForms10.window.8.app3") ; Poker button control IDs Global $foldButton = "AfxWnd42s14" Global $checkButton = "AfxWnd42s15" Global $callButton = "AfxWnd42s15" Global $betButton = "AfxWnd42s16" Global $raiseButton = "AfxWnd42s16" ; Wait for the two windows to be displayed winWait($pokerWindow) winWait($brainWindow) while (winExists($pokerWindow) and winExists($brainWindow)) sleep(300) Dim $foldVisible = controlCommand($pokerWindow, "", $foldButton, "isVisible", "") Dim $raiseVisible = controlCommand($pokerWindow, "", $raiseButton, "isVisible", "") if ($foldVisible) then sleep(random(1500, 2500)) Dim $action = _action($brainWindow) 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 func _action($brainWindow) local $counter = 1 while ($counter <= 100) local $id = "WindowsForms10.STATIC.app3" & $counter local $pos = controlGetPos($brainWindow, "", $id) if (isArray($pos) and $pos[0] = 464 and $pos[1] = 96 and $pos[2] = 80 and $pos[3] = 32) then _ return controlGetText($brainWindow, "", $id) $counter = $counter + 1 wEnd return "" endFunc 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...
LxP Posted July 31, 2005 Share Posted July 31, 2005 The problem is that apparently the Poker window's title may not start with 'Play money' -- it could start with anything. Could you please try my code again now Ron? Link to comment Share on other sites More sharing options...
Recommended Posts