Warning: Test on play money!
This script needs RolandsFunctions
; BetPotPokerRoom
; date: 14:11 22 May 2007
; version: 1.05
; AHK version: 1.0.46.13
; author: Roland (roland@overcards.com)
#NoEnv
#SingleInstance force
#Include %a_scriptDir%
#Include Functions.ahk
SetWorkingDir %a_scriptDir%
SetBatchLines -1
version=1.05
; ## settings ##
; set to 1 to not act on active table, not the table under the mouse
act_only_on_active_table := 0
; try changing 'round' to 0 if you are having trouble
; with too large amounts
round:=2
; ## / settings ##
Menu, Tray, NoStandard
Menu, Tray, DeleteAll
Menu, Tray, Add, &Help, Help
Menu, Tray, Default, &Help
Menu, Tray, Add
Menu, Tray, Add, &About, About
Menu, Tray, Add
Menu, Tray, Add, E&xit, Exit
Menu, Tray, Tip, BetPotPokerRoom %version%
Gui, +Lastfound +Toolwindow +alwaysOnTop -Caption
Gui, Margin, 5, 5
Gui, Font, bold, Comic Sans MS
Gui, Color, 800000
Gui, Add, Button, vfold w120 gFold, Fold
Gui, Add, Button, vcall ys w120 gCall, Call
Gui, Add, Button, vraise ys w120 gRaise, Raise
Gui, Font, s30
Gui, Add, Text, vtext x0 y50 w385 h120 center cWhite
Gui, Show, hide
WinSet, Region, w385 h120 0-0 0-385 385-120 0-120 0-0 R10-10
return
; ###### hotkeys ######
; in any of the hotkeys below, change the zero
; to one to auto-bet
~MButton:: ; middle mouse button
handleBetting(1, 1) ; full pot
return
~RButton:: ; right mouse button
handleBetting(1/2, 1) ; 1/2 pot
return
^RButton:: ; Ctrl + right mouse button
handleBetting(1/3, 0) ; 1/3 pot
return
^!MButton:: ; Ctrl+Alt+Middle mouse button
handleBetting("all-in", 0) ; all-in
return
!f:: ; Alt+f - fold in turn
win:=getID() ; get the window handle
If ! isDisabledCtrl("Button46", win) ; is 'check/fold' disabled?
ControlClick, Button46, ahk_id%win% ; if no, click it
else
ControlClick, Button45, ahk_id%win% ; if yes, click 'fold'
return
~WheelUp:: ; scrolling
~WheelDown::
updateGui(mouseGetWin())
return
; ###### / hotkeys ######
; ## tray menu ##
Help:
Run % Web() "http://www.overcards.com/wiki/moin.cgi/BetPotPokerRoom"
return
About:
TrayTip, BetPotPokerRoom %version%
, Author: Roland`nE-mail: Roland@overcards.com,,1
return
Exit:
ExitApp
; ## handle betting ##
handleBetting(frac=1, auto_bet=0) {
win:=getID()
If ! win
return
WinExist("ahk_id" win)
sb:=getSB(win)
pot:=Pot(win) * frac
bet:=frac!="all-in"
? round( ( floor(pot/sb) * sb), round )
: 9999999
bet:=StrRep(bet, ".", ",")
bet(win, bet, auto_bet)
}
; ## bet ##
bet(win, bet, auto_bet=0) {
WinExist("ahk_id" win)
Loop {
If ! isVisCtrl("RichEdit20W3", win)
return
IfWinNotActive
WinActivate
ControlClick, RichEdit20W3
ControlSetText, RichEdit20W3
SendPlay % bet
Sleep 100
If ( CtrlGetTxt("RichEdit20W3", win)=bet )
break
}
If !( auto_bet )
return
SetKeyDelay,, 250
If isVisCtrl("Button25", win)
button:=25
else if isVisCtrl("Button29", win)
button:=29
Sleep 250
Loop {
If ! isVisCtrl("Button" button, win)
break
IfWinNotActive
WinActivate
Send {f3}
}
}
; ## updateGui ##
updateGui(win=0) {
global text,fold,call,raise,currWin
static bet:=0,winP:=0,bb,pot,inc
If !( win ) {
winP:=0
return
}
Gui +LastfoundExist
win:= ( win=WinExist() ) ? winP : win
currWin:=win
If ! isVisCtrl("RichEdit20W3", win)
return
If ! WinActive("ahk_id" win)
WinActivate ahk_id%win%
dir:= a_thisHotkey="~WheelUp" ? 1 : 0
If ( win!=winP ) {
bb:=getBB(win)
pot:=Pot(win)
inc:=floor(max(bb "," pot/bb)/bb)*bb
cost:=CtrlGetTxt("AfxWnd70u58", win)
StringTrimLeft, cost, cost, InStr(cost, "$")
cost:= isVisCtrl("AfxWnd70u58", win) ? cost : 0
GuiControl,, call, % !cost ? "Check" : "Call (" cost ")"
GuiControl, % "disable" (!cost), fold
WinGetPos, x, y,,, ahk_id%win%
Gui, Show, % "x" x+144 "y" y+480 " noActivate"
}
bet:=dir=1 ? bet+inc : ( bet-inc<=0 ? bet : bet-inc )
bet:=round(bet, ( bb<=0.10 ? 2 : ( bb<=1 ? 1 : 0 ) ) )
GuiControl,, text, % bet
winP:=win
}
; ## fold/call/raise ##
Fold:
ControlClick, Button28, ahk_id%currWin%
Gui +Lastfound
DllCall("AnimateWindow","UInt",WinExist(),"Int",250,"UInt","0x90000")
updateGui()
return
Call:
ControlClick, Button27, ahk_id%currWin%
Gui +Lastfound
DllCall("AnimateWindow","UInt",WinExist(),"Int",250,"UInt","0x90000")
updateGui()
return
Raise:
Gui, Submit, noHide
GuiControl, disable, raise
GuiControlGet, bet,, text
bet(currWin, StrRep(bet, ".", ","), 1)
Gui +Lastfound
DllCall("AnimateWindow","UInt",WinExist(),"Int",250,"UInt","0x90000")
updateGui()
GuiControl, enable, raise
return
; ## Pot ##
Pot(id) {
pot := CtrlGetTxt("AfxWnd70u54", id, 3)
StringTrimLeft, pot, pot, InStr(pot, "$")
pot:=StrRep(pot, ".")
call := CtrlGetTxt("AfxWnd70u53", id)
StringTrimLeft, call, call, InStr(call, "$")
pot += call*2
return pot
}
; ## get blinds ##
getBB(win) {
WinGetTitle, title, ahk_id%win%
StringTrimLeft, title, title, InStr(title, "$", 0, 0)
StringLeft, bb, title, InStr(title, a_space) - 1
return bb
}
getSB(win) {
WinGetTitle, title, ahk_id%win%
StringTrimLeft, title, title, InStr(title, "$")
StringLeft, sb, title, InStr(title, "-") - 1
return sb
}
; ## getID ##
getID() {
tn := tableNav()
If ( tn )
return tn
If ( act_only_on_active_table )
return WinExist("a")
return mouseGetWin()
}
