Jump to content

Need Help With Code


Recommended Posts

  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

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

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

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

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

  • Moderators

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

Try this on for size:

Edit: was missing a bracket.

Edit: should detect all windows automatically now.

Edit: debugging message boxes.

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

  • Moderators

This works on mine:

; 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

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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