By HalvSame. Discussion thread on FlopTurnRiver.com is here, discussion thread on 2p2 is here...
PotOddsHUD
Supported poker sites: PartyPoker, Prima (no miniview), iPoker
Displays pot size and pot odds on the active table when user presses the defined hotkey (default is crtl), press again to remove display.
; Thanks to _dave_ for code borrowed from BetPot
How To Use This Script
Read instructions for AutoHotkey, and make sure you have the latest version installed.
Download and unzip PotOddsHUD-1.5.zip.
Open the script file in a text editor and edit settings
Double-click the file to run the script.
Todo
Add support for other sites.
Version History
1.5 Sep 11th 2008: Changed ipoker code to use chat box instead of OCR for stability and speed. Should work for miniview as well now. Changed hotkey to toggle the display on/off.
1.4 Aug 10th 2007: Added iPoker support, Prima support (no miniview), added hotkey instead of always showing pot odds on the active table, removed FPHG dependency.
1.3 was magically skipped
1.2 May 31st 2007: Option to show as odds instead of probability/%
1.1 May 14th 2007: Support for table resizing.
1.0 May 14th 2007: Initial release, Party support only. Only tested on NL ring games.
Downloads
Script Code
;-------------------------------------------------------------
;------------------- PotOddsHUD v1.5 -------------------------
;-------------------------------------------------------------
; Date: Sep 11th 2008
; Author: HalvSame
; Discussion thread on FlopTurnRiver.com: http://www.flopturnriver.com/phpBB2/viewtopic.php?p=512384
; Old discussion thread on 2p2: http://forumserver.twoplustwo.com/showflat.php?Cat=0&Number=10363108
; New discussion thread on 2p2:
;
; Thanks to _dave_ for the Prima code and for the javascript injection stuff that scrapes the ipoker chat window, borrowed from BetPot
#NoEnv
#Persistent
SetTitleMatchMode 2
SetBatchLines, -1
SetKeyDelay, -1
SetMouseDelay, -1
SetWinDelay, 0
SetTitleMatchMode, 2
SendMode, Input
SysGet, Sb, 7
SysGet, Sc, 4
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
GroupAdd, PartyTables, Good Luck ahk_class #32770,,, : Poker Lobby
GroupAdd, PrimaTables, ahk_class POPUP_INT_DLG_WINDOW
GroupAdd, IpokerTables, ahk_class PTIODEVICE,,, Nickname:
OnOff := 0
#Include include\acc.ahk
#Include include\com.ahk
;-----------------------------------------------------------------------------------------------------------
;----------------START USER SETTINGS (DON'T EDIT ABOVE HERE)------------------------------------------------
;-----------------------------------------------------------------------------------------------------------
; GENERAL SETTINGS
showPotSize := 0
showPotOdds := 1
percentage := 1 ;display as percentage rather than odds
fontSize := 20 ;font size when the table is maximized
adjustFontSize = 1 ;adjust the font size based on table size?
fontColor = red
posX := 50 ;HUD center position as % of the table width
posY := 15 ;HUD center position as % of the table heigth
prefix =
postfix =
F11:: reload
~Ctrl:: ;<---------CHANGE "Ctrl" TO WHATEVER HOTKEY YOU WANT BUT DON'T CHANGE ANYTHING ELSE BELOW HERE (see http://www.autohotkey.com/docs/Hotkeys.htm)
{
if (OnOff == 0)
{
CalculateOdds(getID())
OnOff := 1
}
else
{
Gui, destroy
OnOff := 0
}
return
}
;-----------------------------------------------------------------------------------------------------------
;----------------END USER SETTINGS (DON'T EDIT BELOW HERE)--------------------------------------------------
;-----------------------------------------------------------------------------------------------------------
CalculateOdds(id)
{
global percentage
pot =
call =
IfWinExist, ahk_id%id% ahk_group PartyTables
PotOddsParty(id, call, pot)
else IfWinExist, ahk_id%id% ahk_group PrimaTables
PotOddsPrima(id, call, pot)
else IfWinExist, ahk_id%id% ahk_group IpokerTables
PotOddsIPoker(id, call, pot)
else
return
;msgbox %call% %pot%
if (call AND pot)
{
if percentage
odds := Round((call/(pot+call))*100, 1)
else
{
tmp := Round(pot/call, 2)
odds = %tmp%:1
}
pot := Round(pot, 2)
DrawHUD(id, odds, pot)
}
else
Gui, destroy
sleep, 1000
}
DrawHUD(id, odds, pot)
{
global
str =
if showPotSize
str = %pot%
if ShowPotOdds
str = %str%%a_space%%odds%
CustomColor = EEAA99
WinGetPos, x, y, w, h, ahk_id %id%
size := fontSize
if adjustFontSize
size := ceil(fontSize*h/575)
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s%size%, bold
Gui, Add, Text, c%fontColor% bold, %prefix%%str%%postfix%
WinSet, TransColor, %CustomColor%
GuiControlGet, hudPos, Pos, Static1
x := x + ((posX * w)/100)
x -= hudPosX
x -= hudPosW/2
y := y + ((posY *h)/100)
y -= hudPosY
y -= hudPosH/2
Gui, Show, x%x% y%y% NoActivate
}
;get the pot size and amount to call on Prima from the chat box
PotOddsPrima(id, ByRef call, ByRef pot)
{
global sb, sc
rake := 0
notraked := 0
maxrake := 3
nl_actions = called for $,raised for $,bet for $,went all-in for $,posted small blind,posted big blind
WinGetTitle, title, ahk_id%id%
StringMid, hero, title, InStr(title, " - Blinds ")-1, , L
StringTrimLeft, hero, hero, InStr(hero, " - ", true, 0)+2
Loop, 10
{
ControlGetText, hh, RichEdit20W3, ahk_id%id%
If hh
{
break
}
Sleep, 80
}
StringTrimLeft, hh, hh, InStr(hh, " wins ", true, 0)
Loop, Parse, hh, `n
{
If a_loopfield contains %nl_actions%
{
StringMid, amount, a_loopfield, InStr(a_loopfield, "$")+1
StringReplace, amount, amount, )
StringReplace, amount, amount, `,,, All
StringReplace, amount, amount, `n
StringReplace, amount, amount, `r
pot += amount
IfInString, a_loopfield, raised for $
{
open := 0
}
IfInString, a_loopfield, posted small blind
{
sb := amount
If a_loopfield contains %hero%
{
hero_position := "sb"
}
}
Else IfInString, a_loopfield, posted big blind
{
bb := amount
If a_loopfield contains %hero%
{
hero_position := "bb"
}
}
}
}
street := "pre"
If InStr(hh, "> Dealing the river(")
{
StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the river(", true, 0)
street := "river"
open := 0
}
Else If InStr(hh, "> Dealing the turn(")
{
StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the turn(", true, 0)
street := "turn"
open := 0
}
Else If InStr(hh, "> Dealing the Flop(")
{
StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Flop(", true, 0)
street := "flop"
open := 0
}
Else
{
hh2 := hh
}
Loop, Parse, hh2, `n
{
;Msgbox %hh2%
If a_loopfield contains %nl_actions%
{
StringMid, amount, a_loopfield, InStr(a_loopfield, "$")+1
StringReplace, amount, amount, `)
Stringreplace, amount, amount, `n
Stringreplace, amount, amount, `,,, All
notraked += amount
IfInString, a_loopfield, > %hero%
{
hero_bet += amount
}
Else
{
call := amount
}
}
}
if(hero_bet >= call)
{
call := 0
}
Else
{
call -= hero_bet
}
call := iif( call, call, 0 )
if(street<>"pre")
{
rake := Floor(pot - notraked) * 0.05
If (rake > maxrake)
{
rake := maxrake
}
pot := pot - rake
}
return
}
;get the pot size and amount to call on Party from the Call button text
PotOddsParty(id, ByRef call, ByRef pot)
{
ControlGetText, pot, Total Pot:, ahk_id %id%
StringTrimLeft, pot, pot, InStr(pot, "$")
ControlGet, vis, visible, , Call (, ahk_id %id%
if (vis)
{
ControlGetText, call, Call (
StringTrimLeft, call, call, InStr(call, "$")
StringTrimRight, call, call, 1
}
}
;get the pot size and amount to call on iPoker by reading the chat box
PotOddsIPoker(id, ByRef call, ByRef pot)
{
nl_actions = calls $, raises to $, bets $, All-In $, posts Small Blind $, posts Big Blind $
;Get hero's screen name from the lobby title
WinGetTitle, lobby, Nickname: ahk_class PTIODEVICE
StringTrimLeft, hero, lobby, InStr(lobby, "Nickname:") + 9
StringLeft, hero, hero, InStr(hero, A_space)
;Msgbox %hero%
;grab HH from chat box
hh :=
ControlGet, chat_id, Hwnd,,Internet Explorer_Server3, ahk_id%id%
ahkret1 := IE_InjectJS(chat_id, "ahkret1=document.body.innerHTML", "ahkret1")
ahkret1 := RegExReplace(ahkret1, "i)<(.|\n)+?>", "")
Stringreplace, ahkret1, ahkret1, `r`n`r`n, `r`n, All
;Msgbox, %ahkret1%
; StringGetPos, pos, ahkret1, (#, R
; StringTrimLeft, hh, ahkret1, pos
StringGetPos, pos, ahkret1, Dealer: Winner is, R
StringTrimLeft, hh, ahkret1, pos
IfInString, hh, wins with
{
StringGetPos, pos, hh, wins with, R
StringTrimLeft, hh, hh, pos
}
;Msgbox, %hh%
Loop, Parse, hh, `n
{
If a_loopfield contains %nl_actions%
{
StringTrimLeft, amount, a_loopfield, InStr(a_loopfield, "$")
StringReplace, amount, amount, `r, , all
pot += amount
IfInString, a_loopfield, posts Small Blind $
{
sb := amount
;msgbox, %sb%
If a_loopfield contains %hero%
{
hero_position := "sb"
}
}
Else IfInString, a_loopfield, posts Big Blind $
{
bb := amount
If a_loopfield contains %hero%
{
hero_position := "bb"
}
}
Else If(open = 1 AND InStr(a_loopfield, "raises to $", true, 0))
{
open := 0
;Msgbox "Pre flop Raise"
}
Else If(open = 1 AND InStr(a_loopfield, "All-in $", true, 0))
{
open := 0
;Msgbox "Pre flop All-In"
}
;msgbox, %amount%
}
}
;msgbox, %pot%
hh2 := hh
street := "pre"
If InStr(hh2, "Dealing River")
{
StringTrimLeft, hh2, hh2, InStr(hh, "Dealing River", true, 0)
open := 0
street := "river"
}
Else If InStr(hh2, "Dealing Turn")
{
StringTrimLeft, hh2, hh2, InStr(hh, "Dealing Turn", true, 0)
open := 0
street := "turn"
}
Else If InStr(hh2, "Dealing Flop")
{
StringTrimLeft, hh2, hh2, InStr(hh, "Dealing Flop", true, 0)
open := 0
street := "flop"
}
;msgbox %street%
;Msgbox, %hero%`n`n`n%hh2%
Loop, Parse, hh2, `n
{
;Msgbox %a_loopfield%
If a_loopfield contains %nl_actions%
{
StringTrimLeft, amount, a_loopfield, InStr(a_loopfield, "$")
StringReplace, amount, amount, `r, , all
notraked += amount
;Msgbox %a_loopfield%`n%amount%
If a_loopfield contains %hero%
hero_bet += amount
Else
call := amount
}
}
if(hero_bet >= call)
{
call := 0
}
Else
{
call -= hero_bet
}
call := iif( call, call, 0 )
;Msgbox Pot: %pot%`nrake:%rake%`nhero bet:%hero_bet%`ncall:%call%
return
}
IE_InjectJS(hIESvr, JS_to_Inject, VarNames_to_Return="")
{
;Initialize the COM interface. code modified from SEAN
IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
ACC_Init()
pacc := ACC_AccessibleObjectFromWindow(hIESvr)
pwin := COM_QueryService(pacc,IID_IHTMLWindow2,IID_IHTMLWindow2)
COM_Release(pacc)
;Execute the Javascript (if there is any). Thanks LEXIKOS.
If JS_to_Inject
COM_Invoke(pwin, "execscript", JS_to_Inject)
;Get the value of the variables, if any.
If VarNames_to_Return {
;Split the passed variable names into a psuedo array of ahk variables
StringSplit, Vars_, VarNames_to_Return, `,
;Get the value of each javascript variable in the order it was passed
Loop, %Vars_0%
Ret .= COM_Invoke(pwin,Vars_%A_Index%) . ","
;Remove the trailing comma
StringTrimRight, Ret, Ret, 1
}
; Cleanup
COM_Release(pwin)
ACC_Term()
;Return a comma seperated list of variables in the order they were passed
Return Ret
}
;Juks rocks
PostLeftClick(x, y, table_id, activate=1) {
; ### JUK: Send the down left click, then the mouse-up messages.
; NOTE: This is relative to the top left of the client area and NOT the top left of the
; window (ie: It *doesn't* include the title-bar like AHK's MouseClick does!!!).
If activate and not WinActive("ahk_id" . table_id)
WinActivate, ahk_id%table_id%
PostMessage, 0x201, 0x0001, ((y<<16)^x), , ahk_id%table_id%
PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id%
}
getid()
{
MouseGetPos, , , id
return id
}
IIf(_boolExpr, _exprTrue, _exprFalse) {
If _boolExpr
Return _exprTrue
else
return _exprFalse
}

