Open Side Menu Go to the Top
Register
Quick Questions & Answers Thread Quick Questions & Answers Thread

08-20-2010 , 06:33 PM
Copy and pasted over it. Loaded the script and...

Error duplicate function definition?
Quick Questions & Answers Thread Quote
08-20-2010 , 06:42 PM
Sounds like you simply added it, not replaced the old functions.

Here is the whole thing edited, copy/paste to a new .ahk file (call it BetPot-LongHud.ahk or something) Or just overwrite everything in BetPot-0.2s.ahk if you like, but with overcards.com down it's not so easy to get it back.

Code:
; GENERAL SETTINGS
debug := 0
act_only_on_active_table := 0
fix_blinds := 1
deduct_rake := 1
fold_to_any := 0

move_cursor := 0 	;move cursor to raise button after writing out bet on party and ipoker

; IPOKER SPECIFIC
Ipoker_miniview := 0

; these are site-specific I think :(
; it is number of TABS to highlight the betbox, while holding shift.
; these work for me on NoblePoker

; MAKE SURE to click (activate) the table before preessing TAB, this resets the count.

miniview_tabstops := 6
fullview_tabstops := 8

ipoker_test_betbox := 0

; PARTY SPECIFIC
party_uses_commas_for_decimals := 0
fphg_party_hh_folder := "C:\FreePHG_HandHistories\"
; **** SET TO 0 (zero) if using old FPHG without "live" folder, else 1 (one)
fphg_uselive = 1

;FTP SPECIFIC
; **** SET TO 0 (zero) if using FTP official client, 1 (one) if using the Beta
; THERE IS NO LONGER AN NEED TO CHANGE THIS... BETA IS THE NEW OFFICIAL
FTP_Beta := 1

;STARS SPECIFIC
use_old_stars_buttons := 0
stars_editbox = PokerStarsSliderEditorClass1
;Uncomment for PokerStars Client version < 2.286
;stars_editbox = Edit7

;AHK STUFF, DO NOT EDIT
#MaxHotkeysPerInterval 300|
#SingleInstance, Force
SendMode Input
SetTitleMatchMode 2
caller_hwnd := ""
SysGet, border, 32
SysGet, caption, 4
caption := border + caption
#NoEnv

SetBatchLines, -1
SetWinDelay, 0
;END OF AHK STUFF

;--------------- Copy / Paste --- Add other Crypto skins here ---------------;
WinGet, interpoker, pid,  InterPoker - Lobby
if (interpoker)
{
  GroupAdd, CryptoTables, ahk_pid%interpoker%,,, Lobby
}

WinGet, sunpoker, pid,  SunPoker.com - Lobby
if (sunpoker)
{
  GroupAdd, CryptoTables, ahk_pid%sunpoker%,,, Lobby
}

WinGet, willhill, pid,  William Hill Poker - Lobby
if (willhill)
{
  GroupAdd, CryptoTables, ahk_pid%willhill%,,, Lobby
}

WinGet, betsafe, pid, Betsafe Poker - Lobby
if (betsafe)
{
  GroupAdd, CryptoTables, ahk_pid%betsafe%,,, Lobby
}

WinGet, parbet, pid, Parbet.com Poker - Lobby
if (parbet)
{
  GroupAdd, CryptoTables, ahk_pid%parbet%,,, Lobby
}

WinGet, lw, pid, Littlewoods Poker - Lobby
if (lw)
{
  GroupAdd, CryptoTables, ahk_pid%lw%,,, Lobby
}

WinGet, dtd, pid, DTD Poker - Lobby
if (dtd)
{
  GroupAdd, CryptoTables, ahk_pid%dtd%,,, Lobby
}

;----------- END OF CRYPTO SKINS --------------


WinGet, uubb, pid, UltimateBet  
if (ub)
{
  GroupAdd, UBTables, ahk_pid%uubb%,,, UltimateBet
}


GroupAdd, StarsTables, Logged In as ,,, PokerStars Lobby
;GroupAdd, PartyTables, Good Luck ahk_class #32770,,, : Poker Lobby
GroupAdd, FullTiltTables, ahk_class FTC_TableViewFull
GroupAdd, PrimaTables, ahk_class POPUP_INT_DLG_WINDOW
GroupAdd, MiniFT, MiniFT ahk_class AutoHotkeyGUI
GroupAdd, iPokerTables, ahk_class PTIODEVICE,,, : Nickname:


PartyGetPid()

return

#include betpot_default_hotkeys.txt

#Include include\acc.ahk
#Include include\com.ahk

  ;--------- IPOKER COORDINATES -------------------
iPokerSetCoords(id)
{
  global border, caption, iPokerRaiseX, iPokerRaiseY, ipokerCallX, ipokerCallY, iPokerFoldX, iPokerFoldY, iPokerLoop, miniview_tabstops, fullview_tabstops

  WinGetPos, ,,w, ahk_id%id%
  ;msgbox, w: %w%
  if (w < 600)
  {
    ;this is miniview
    iPokerLoop := miniview_tabstops
    
    iPokerRaiseX := 358
    iPokerRaiseY := 287
    ipokerCallx := 274
    ipokerCallY:= 287
    iPokerFoldX := 187
    iPokerFoldY := 288
  }
  else
  {
    ;this is normalview
    iPokerLoop := fullview_tabstops
    
    iPokerRaiseX := 554
    iPokerRaiseY := 545
    ipokerCallX := 380
    ipokerCallY := 500
    iPokerFoldX := 253
    iPokerFoldY := 500
  }
}

PartyGetPid()
{
  global
  WinGet, partypid, pid, PartyPoker.com: Poker Lobby
  if (partypid)
  {
    GroupAdd, PartyTables,$ ahk_pid%partypid%,,, Lobby
  }
  WinGet, empirepid, pid, EmpirePoker.com: Poker Lobby
  if (empirepid)
  {
    GroupAdd, PartyTables,$ ahk_pid%empirepid%,,, Lobby
  }
}

Fold(id)
{
  PartyGetPid()
  IfWinExist, ahk_id%id% ahk_group MiniFT
  {
    WinGetTitle, t, ahk_id%id%
    StringTrimLeft, t, t, Instr(t, "hwnd:", true, 0)+4
    id := t
  }

  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    FoldStars(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    FoldFT(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    FoldParty(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    FoldCrypto(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    FoldUB(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group iPokerTables
  {
    FoldIPoker(id)
  }
}
  
Call(id)
{
  PartyGetPid()
  IfWinExist, ahk_id%id% ahk_group MiniFT
  {
    WinGetTitle, t, ahk_id%id%
    StringTrimLeft, t, t, Instr(t, "hwnd:", true, 0)+4
    id := t
  }

  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    CallStars(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    CallFT(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    CallParty(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    CallCrypto(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    CallUB(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group iPokerTables
  {
    CallIPoker(id)
  }
}

Raise(id)
{
  PartyGetPid()
  IfWinExist, ahk_id%id% ahk_group MiniFT
  {
    WinGetTitle, t, ahk_id%id%
    StringTrimLeft, t, t, Instr(t, "hwnd:", true, 0)+4
    id := t
  }

  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    RaiseStars(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    RaiseFT(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    RaiseParty(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    RaiseCrypto(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    RaiseUB(id)
  }
  Else IfWinExist, ahk_id%id% ahk_group IPokerTables
  {
    RaiseIPoker(id)
  }
}

 
AlterAmount(id, dir="", frac=1, unit="")
{
  global party_uses_commas_for_decimals, stars_editbox, move_cursor
  
  PartyGetPid()
  

  IfWinExist, ahk_id%id% ahk_group MiniFT
  {
    WinGetTitle, t, ahk_id%id%
    StringTrimLeft, t, t, Instr(t, "hwnd:", true, 0)+4
    id := t
  }
  
  WinGetTitle, title, ahk_id%id%
  amount := 0
  
  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    If ((InStr(title, "No Limit") OR InStr(title, "Pot Limit")) AND InStr(title, "Tournament") = 0)
    {
      StringMid, bb, title, InStr(title, "/") + 1, InStr(title, a_space,"", InStr(title, "/")) - InStr(title, "/") - 1
    }
    else if (InStr(title, "No Limit") <> 0 AND InStr(title, "Tournament") <> 0)
    {
      StringMid, bb, title, InStr(title, "/", "", InStr(title, "Blinds")) + 1, InStr(title, a_space, "", InStr(title, "Blinds") + 8) - InStr(title, "/", "", InStr(title, "Blinds")) - 1 ;___so we retrieve the big blind instead
    }
    
  }
   
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    If ((InStr(title, "NL") || InStr(title, "PL")) && !InStr(title, "Buy-in"))
    {
      ;StringMid, bb, title, InStr(title, "/")+1, InStr(title, ". ", InStr(title,"/")) - InStr(title, "/") -1
      StringTrimLeft, bb, title, InStr(title, "$", true, 0) 
      ;msgbox, %bb%
    }
    else
    {
      ControlGetText, text, Blinds, ahk_id%id%
      IfNotInString, text, Blinds-Antes
      {
        StringMid, bb, text, InStr(text, "/") + 1, InStr(text, ")") - InStr(text, "/") - 1
      }
      else
      {
        StringMid, bb, text, InStr(text, "/") + 1, InStr(text, "-","",InStr(text, "/")) - InStr(text, "/") - 1
      }
    }
    if (party_uses_commas_for_decimals)
    {
      StringReplace, bb, bb, `,,., All
    }
  }
  
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    StringMid, bb, title, InStr(title, "/") + 1, InStr(title, a_space,"", InStr(title, "/")) - InStr(title, "/") - 1
    
  }
  
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    StringMid, bb, title, InStr(title, "/") + 1, InStr(title, a_space,"", InStr(title, "/")) - InStr(title, "/") - 1
  }
  
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    StringTrimLeft, bb, title, InStr(title, "$", true, 0) 
    StringMid, bb, bb, InStr(bb, " ")-1,, L
  }
  
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    StringTrimLeft, bb, title, InStr(title, "$", true, 0)-1 
    StringTrimRight, bb, bb, Strlen(bb) - InStr(bb, A_Space)
    StringReplace, bb, bb, $., $0., All
    StringReplace, bb, bb, $,, All
    StringReplace, bb, bb, %A_Space%,, All
    
    ;StringMid, bb, bb, InStr(bb, "$")-1,, L
    ;MsgBox, %bb%
  }
  
  Else IfWinExist, ahk_id%id% ahk_group iPokerTables
  {
  	StringTrimLeft, bb, title, InStr(title, "/$")
  }
  
  Else
  {
    Send {%A_ThisHotkey%}
    return
  }
  
  StringReplace,bb,bb,$,,1
  StringReplace,bb,bb,Ł,,1
  StringReplace,bb,bb,€,,1
  
  sb := sb(bb)
  
  If (unit = "" or unit = "bb")
  {
    unit := bb
  }
  Else If (unit = "sb")
  {
    unit := sb
  }
  Else If (unit = "pot")
  {
    pot := 0
    call := 0
    hero_bet := 0
    street := "pre"
    hero_position := ""
    open := 0
    max := 10000000
    IfWinExist, ahk_id%id% ahk_group StarsTables
    {
      PotSizeStars(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
    } 
    Else IfWinExist, ahk_id%id% ahk_group PartyTables
    {
      PotSizeParty(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
      if (party_uses_commas_for_decimals)
      {
        StringReplace, call, call, `,,., All
      }
    }
    Else IfWinExist, ahk_id%id% ahk_group CryptoTables
    {
      PotSizeCrypto(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
    }
    Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
    {
      ControlGet, v, Visible, , Edit1, ahk_id%id%
      if (v)
      {
        PotSizeFullTilt2(id, pot, call, sb, bb, hero_bet, street, hero_position, open, max)
      }
      else
      {
        return
      }
      ;msgbox, %pot%
    }
    Else IfWinExist, ahk_id%id% ahk_group PrimaTables
    {
      PotSizePrima(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
    }
    Else IfWinExist, ahk_id%id% ahk_group iPokerTables
    {
      PotSizeIPoker(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
    }    

    pot := ((pot + call + hero_bet) )+ call
    ;Msgbox, %pot%
    unit := pot
  }
  amount := unit * frac
  
  if (dir="down")
  {
    amount := amount - (2*amount)
  }
  
  
  
  ;Msgbox, %sb%/%bb%
  /*
  IfWinExist, ahk_id%id% ahk_group MiniFT
  {
    ControlGet, v, Visible, , Edit1, ahk_id%id%
    if (v)
    {
      ControlGetText, t, Edit1, ahk_id%id%
      t := t + amount
      if (t < 0)
      {
        t := 0
      }
      t := Round(t, 2)
      ControlSetText, Edit1, %t%, ahk_id%id%
      WinSet, Redraw,, ahk_id%id%
    }
  }
  */
  
  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    ControlGetText, t, %stars_editbox%, ahk_id%id%
    ;Msgbox, %t%
    t := t + amount
    if (t < 0)
    {
      t := 0
    }
    t := Round(t, 2)
    ControlSetText, %stars_editbox%, %t%, ahk_id%id%
    Sleep, -1
    ;ControlGetText, t, %stars_editbox%, ahk_id%id%
    WinSet, Redraw,, ahk_id%id%
  } 
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    ControlGetText, t, Edit2, ahk_id%id%
    if (party_uses_commas_for_decimals)
    {
      StringReplace, t, t, `,,., All
    }
    else
    {
      StringReplace, t, t, `,,, All
    }
    t := t + amount
    if (t < 0)
    {
      t := 0
    }
    t := Round(t, 2)
    if (party_uses_commas_for_decimals)
    {
      StringReplace, t, t, .,`,, All
    }
    ControlSetText, Edit2, %t%, ahk_id%id%
    ;WinSet, Redraw,, ahk_id%id%

    If(move_cursor)
    {
	ControlGet, vis, visible, , AfxWnd42u19, ahk_id%id% 
	if vis
	{
		ControlGetPos, x, y, , , AfxWnd42u19, ahk_id%id%
		MouseMove, x + 40, y + 15
    	}
     }
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    ControlGetText, t, Edit3, ahk_id%id%
    t := t + amount
    if (t < 0)
    {
      t := 0
    }
    t := Round(t, 2)
    ControlSetText, Edit3, %t%, ahk_id%id%
    WinSet, Redraw,, ahk_id%id%
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    ControlGet, v, Visible, , Edit1, ahk_id%id%
    if (v)
    {
      ControlGetText, t, Edit1, ahk_id%id%
      t := t + amount
      if (t < 0)
      {
        t := 0
      }
      t := Round(t, 2)
      ControlSetText, Edit1, %t%, ahk_id%id%
      ;WinSet, Redraw,, ahk_id%id%
    }
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    ControlGetText, t, Edit1, ahk_id%id%
    t := t + amount
    if (t < 0)
    {
      t := 0
    }
    t := Round(t, 2)
    ControlSetText, Edit1, %t%, ahk_id%id%
    WinSet, Redraw,, ahk_id%id%
  }
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    ControlGetText, t, Edit1, ahk_id%id%
    t := t + amount
    if (t < 0)
    {
      t := 0
    }
    t := Round(t, 2)
    ControlSetText, Edit1, %t%, ahk_id%id%
    ;WinSet, Redraw,, ahk_id%id%
  }

  Else IfWinExist, ahk_id%id% ahk_group iPokerTables
  {
  	t := ReadBetBoxIPoker(id)
  	
  	if (t = -1)
  	   return
  
  	t := t + amount
  
  	if (t <= 0)
      	  return
  
  	t := Round(t, 2)
  	;Msgbox, %A_EventInfo%
  	WriteBetBoxIPoker(id, t)
  }
}

Pot(id, frac=1, round_bet=0.2, open_adjust="", autoBet=0)
{
  global debug
  global fix_blinds
  global caller_hwnd
  global party_uses_commas_for_decimals
  global stars_editbox
  global move_cursor

  PartyGetPid()
  

  caller_hwnd := ""
  pot := 0
  call := 0
  sb := 0
  bb := 0
  hero_bet := 0
  street := ""
  hero_position := ""
  open := 1
  max := 10000000
  
  IfWinExist, ahk_id%id% ahk_group MiniFT
  {
    WinGetTitle, t, ahk_id%id%
    caller_hwnd := id
    StringTrimLeft, t, t, Instr(t, "hwnd:", true, 0)+4
    id := t
  }

  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    PotSizeStars(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
  } 
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    PotSizeParty(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
    if (party_uses_commas_for_decimals)
    {
      StringReplace, call, call, `,,., All
    }
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    PotSizeCrypto(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    ControlGet, v, Visible, , Edit1, ahk_id%id%
    if (v)
    {
      PotSizeFullTilt2(id, pot, call, sb, bb, hero_bet, street, hero_position, open, max)
    }
    else
    {
      return
    }
    ;msgbox, %pot%
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    PotSizePrima(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
  }
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    ControlGet, v, Visible, , Edit1, ahk_id%id%
    if (v)
    {
      PotSizeUB(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
    }
    else
    {
      return
    }
  }

  Else IfWinExist, ahk_id%id% ahk_group iPokerTables
  {
    PotSizeIPoker(id, pot, call, sb, bb, hero_bet, street, hero_position, open)
  }

  Else
  {
    return
  }
 
  StringSplit, fr, frac, %A_SPACE%
  if (fr0 < 4)
  {
    times := 4 - fr0
    Loop, %times%
    {
      n := 5 - A_Index
      fr%n% := fr%fr0% 
    }
  }
  
  if (street = "pre")
  {
    frac = %fr1%
  }
  else if (street = "flop")
  {
    frac = %fr2%
  }
  else if (street = "turn")
  {
    frac = %fr3%
  }
  else if (street = "river")
  {
    frac = %fr4%
  }

  if (debug)
  {
    TrayTip, BetPot, Pot:`t`t%pot%`nCall:`t`t%call%`nHero_bet:`t%hero_bet%`n`nBlinds:`t$%sb%/$%bb%`n`nStreet:`t%street%`n`n%fr0%`n%fr1% %fr2% %fr3% %fr4%`n`n%frac%,10,17
  }
    
  if (fix_blinds AND open AND street="pre")
  {
    if (hero_position = "sb" )
    {
      pot := pot - sb
      call := call + sb
    }
    else if (hero_position = "bb")
    {
      pot := pot - bb
      call := call + bb
    }
  }

  ;msgbox, %pot%
  pot := ((pot + call + hero_bet)* (frac) )+ call
  ;msgbox, %pot%
  
  if (open=1 AND open_adjust="ssnl" )
  {
    pot := pot + bb - sb
  }
  else if (open=1 AND open_adjust="tourney" )
  {
    pot := pot - bb
  }
  else if (open=1 AND open_adjust="mix" )
  {
    if (bb=2)
    {
      pot := pot + bb - sb
    }
  }
  
  if(round_bet = "smallblind")
  {
    pot := Round((Floor((pot / sb)) * sb),2)
  }
  else if(round_bet = "bigblind")
  {
    pot := Round((Floor((pot / bb)) * bb),2)
  }
  else if (round_bet < 1)
  {
    places := round_bet*10
    pot := Round(pot, (places))
  }
  else if (round_bet >= 1)
  {
    pot := Floor(pot / round_bet) * round_bet
  }
  ;msgbox, %pot%
  
  
     
  IfWinExist, ahk_id%id% ahk_group StarsTables
  {
    ControlSetText, %stars_editbox%, %pot%, ahk_id%id%
    Sleep, -1
    if (autobet)
    {
      RaiseStars(id)
    }
  }
  Else IfWinExist, ahk_id%id% ahk_group PartyTables
  {
    if (party_uses_commas_for_decimals)
    {
      StringReplace, pot, pot, .,`,, All
    }
    ;Msgbox, %pot%
    ControlSetText, Edit2, %pot%, ahk_id%id%
    Sleep -1
    Sleep, 50
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      ControlClick, AfxWnd42u19, ahk_id%id%
    }

    If(move_cursor)
    {
	    ControlGet, vis, visible, , AfxWnd42u19, ahk_id%id% 
	    if vis
	    {
		    ControlGetPos, x, y, , , AfxWnd42u19, ahk_id%id%
		    MouseMove, x + 40, y + 15
    	}
    }
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    ControlSetText, Edit3, %pot%, ahk_id%id%
    Sleep -1
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      PostLeftClick(730, 540, id)
    } 
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    ControlGet, v, Visible, , Edit1, ahk_id%id%
    if (v)
    {
      ;Msgbox, %pot%
      if (pot > max)
      {
        pot := max
      }
      ControlSetText, Edit1, %pot%, ahk_id%id%
      Sleep -1
      ;WinSet, Redraw,, ahk_id%id%
      If(autobet)
      {
        ab := 0
        Loop, 20
        {
          ControlGetText, t, Edit1, ahk_id%id%
          if (t < pot || t > pot)
          {
            Sleep, 100
          }
          else
          {
            ;TrayTip, ,  %ab% %t% %pot%
            Sleep, 200
            
            RaiseFT(id)
            
            /*
            if (FTP_Beta)
            {
              ControlFocus, FTCButton14, ahk_id%id%
              Sleep, -1
              ControlClick, FTCButton14, ahk_id%id%
            }
            else
            {
              ControlFocus, FTCButton13, ahk_id%id%
              Sleep, -1
              ControlClick, FTCButton13, ahk_id%id%
            }
            */
            
            break
          }
        }
        ;TrayTip, ,  %ab% %t% %pot%
        ;if (ab)
        ;{
        ;  ControlFocus, FTCButton11, ahk_id%id%
        ;  Sleep, -1
        ;  ControlClick, FTCButton11, ahk_id%id%
        ;}
      }
    }
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    ControlFocus, Edit1, ahk_id%id%
    ControlSetText, Edit1, %pot%, ahk_id%id%
    Sleep, -1
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      WinActivate, ahk_id%id%
      WinWaitActive, ahk_id%id%, , 1
      If (errorlevel<>1)
      {
        Send, {ENTER}
      }
      
    } 
  }
  Else IfWinExist, ahk_id%id% ahk_group UBTables
  {
    ControlSetText, Edit1, %pot%, ahk_id%id%
    Sleep -1
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      RaiseUB(id)
    } 
  }

  Else IfWinExist, ahk_id%id% ahk_group iPokerTables
  {
     if pot != 0
     {
	;don't write if bet box not visible
	t:= ReadBetBoxIpoker(id)

	if (t = -1)
	   return

		WriteBetBoxIpoker(id, pot)	
		If(autobet)
		   {
		      readPot := ReadBetBoxIpoker(id)
		      if (readPot = pot)
		      {
		      	WinActivate, ahk_id%id%
		      	WinWaitActive, ahk_id%id%, , 1
		      	If (errorlevel<>1)
		      	{
		      	  Send, {ENTER}
		     	}
		    }
	}
      }
   }
}


PotSizeFullTilt2(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open, ByRef max)
{
  global deduct_rake
  global FTP_Beta
  rake := 0
  notraked := 0
  maxrake := 3
  max := 7654321
  
  ftp_btn_max = FTCSkinButton24
  ftp_btn_max_pl = FTCSkinButton24
  ftp_btn_max_cap = FTCSkinButton28
  ftp_btn_min = FTCSkinButton23
  ftp_btn_pot = FTCSkinButton25
  ftp_btn_pot_pl = FTCSkinButton27
  
  WinGetTitle, title, ahk_id%id%
  StringMid, bb, title, InStr(title, "/") + 1, InStr(title, a_space,"", InStr(title, "/")) - InStr(title, "/") - 1
  StringReplace,bb,bb,$,,1
  sb := sb(bb)
  ;msgbox, %bb%`n%sb%
  ControlGetText, t, Edit1, ahk_id%id%

  min := sb
  

    if (InStr(title, "Pot Limit"))
    {
      ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
      if (v)
      {
        ;TrayTip, BetPot,`nPOT to zero,10,17
        x := ""
        ControlSetText, Edit1,%min%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = min)
          {
            break
            ;Traytip
          }
          sleep, 40
          ;Traytip
        }
        
        
        Loop, 50
        {
         ; TrayTip, BetPot,`nPOT result,10,17
          ControlFocus, %ftp_btn_pot_pl%, ahk_id%id%
          ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
          Sleep, -1
          ControlGetText, pot, Edit1, ahk_id%id%
          if (pot != "")
          {
            break
            ;Traytip
          }
          sleep, 40
         ; TrayTip
        }
      }
    }
    else  ;unlimited betting
    {
      ControlGet, v, Visible, , %ftp_btn_pot%, ahk_id%id%
      if (v)
      {
        ;TrayTip, BetPot,`nPOT to zero,10,17
        x := ""
        ControlSetText, Edit1,%min%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = min)
          {
            break
            ;Traytip
          }
          sleep, 40
          ;Traytip
        }
        
        
        Loop, 50
        {
         ; TrayTip, BetPot,`nPOT result,10,17
          ControlFocus, %ftp_btn_pot%, ahk_id%id%
          ControlClick, %ftp_btn_pot%, ahk_id%id%
          Sleep, -1
          ControlGetText, pot, Edit1, ahk_id%id%
          if (pot != "")
          {
            break
            ;Traytip
          }
          sleep, 40
         ; TrayTip
        }
      }
      
    
    ControlGet, v, Visible, , %ftp_btn_min%, ahk_id%id%
      if (v)
      {
        ;TrayTip, BetPot,`nMIN to zero,10,17
        x := ""
        ControlSetText, Edit1,%pot%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = pot)
          {
            break
            ;Traytip
          }
          sleep, 40
          ;Traytip
        }
        
        
        Loop, 50
        {
          ;TrayTip, BetPot,`nMIN result,10,17
          ControlFocus, %ftp_btn_min%, ahk_id%id%
          ControlClick, %ftp_btn_min%, ahk_id%id%
          Sleep, -1
          ControlGetText, min, Edit1, ahk_id%id%
          if (min != pot)
          {
            break
            ;TrayTip
          }
          sleep, 40
          ;TrayTip
        }
      }
    }
    
    
  
  
  ControlSetText, Edit1, %t%, ahk_id%id%
  
  
  street := "pre"
  
  street := GetStreetFT(id)
  
  
  if (min = bb)
  {
    call := 0
  }
  else if (min > bb)
  {
    call := min / 2
  }
  else if (street != "pre")
  {
    call := bb
  }
  
  if (call != bb || street != "pre")
  {
    open := 0
  }
  
  pot := pot - (2 * call)
  
  
  
  /*
  if (deduct_rake AND street<>"pre")
  {
    rake := Floor(pot - notraked) * 0.05
    if (rake > maxrake)
    {
      rake := maxrake
    }
    pot := pot - rake
  }
  */
  
  ;Msgbox, Pot: %pot%`nRake: %rake%`nNot Raked: %notraked%
  
  
  return
}






PotSizePrima(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global deduct_rake
  rake := 0
  notraked := 0
  maxrake := 3

  
  
  ;Msgbox %title%
  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
  ;Msgbox %hero%
  
  ;ControlGetText, hh, RichEdit20W3, ahk_id%id%
  Loop, 10
  {
    ControlGetText, hh, RichEdit20W3, ahk_id%id%
    If hh
    {
      break
    }
    Sleep, 80
  }
  StringTrimLeft, hh, hh, InStr(hh, " wins ", true, 0)
  
  ;Msgbox, %hh%
  
  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(deduct_rake AND street<>"pre")  
  {
    rake := Floor(pot - notraked) * 0.05
    If (rake > maxrake)
    {
      rake := maxrake
    }
    pot := pot - rake
  }
  return
}


PotSizeCrypto(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global deduct_rake
  rake := 0
  notraked := 0
  maxrake := 3
  
  nl_actions = calls $,raises to $,bets $,posts ante $,posts small blind $,posts big blind $
  WinGetTitle, title, ahk_id%id%
  StringMid, hero, title, InStr(title, "logged in as ") + 13
  
  ControlGetText, hh, RICHEDIT1, ahk_id%id%
  StringTrimLeft, hh, hh, InStr(hh, "Starting new hand: #", true, 0)
  StringReplace, hh, hh, €,$, All
  StringReplace, hh, hh, Ł,$, All
  Loop, Parse, hh, `n
  {
    If a_loopfield contains %nl_actions%
    {
      StringMid, amount, a_loopfield, InStr(a_loopfield, "$") + 1
      StringReplace, amount, amount, `r,, All
      StringReplace, amount, amount, `n,, All
      StringReplace, amount, amount, %A_SPACE%,, All
      StringReplace, amount, amount, %A_TAB%,, All
      
      pot += amount
      
      IfInString, a_loopfield, raises to $
      {
        open := 0  
      }
     
      IfInString, a_loopfield, posts small blind $
      {
        sb := amount
        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"
        }
      }
    }
  }
  ;Msgbox, %sb% %bb%
  hh2 := hh
  street := "pre"
  If InStr(hh2, "Dealer: Dealing River:")
  {
    StringTrimLeft, hh2, hh2, InStr(hh, "Dealer: Dealing River:", true, 0)
    open := 0
    street := "river"
  }
  Else If InStr(hh2, "Dealer: Dealing Turn:")
  {
    StringTrimLeft, hh2, hh2, InStr(hh, "Dealer: Dealing Turn:", true, 0)
    open := 0
    street := "turn"
  }
  Else If InStr(hh2, "Dealer: Dealing Flop:")
  {
    StringTrimLeft, hh2, hh2, InStr(hh, "Dealer: Dealing Flop:", true, 0)
    open := 0
    street := "flop"
  }

  ;Msgbox, %hh2%
  Loop, Parse, hh2, `n
  {
    If a_loopfield contains %nl_actions%
    {
      StringMid, amount, a_loopfield, InStr(a_loopfield, "$") + 1
      StringReplace, amount, amount, `r,, All
      StringReplace, amount, amount, `n,, All
      StringReplace, amount, amount, %A_SPACE%,, All
      StringReplace, amount, amount, %A_TAB%,, All
      notraked += 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 )

  if (deduct_rake AND street<>"pre")
  {
    rake := Floor(pot - notraked) * 0.05
    if (rake > maxrake)
    {
      rake := maxrake
    }
    pot := pot - rake
  }
  
  return
}

FoldParty(id)
{
  ControlGet, v, Visible, , AfxWnd42u22, ahk_id%id%
  if (v)
  {
    ControlFocus, AfxWnd42u22, ahk_id%id%
    Sleep, -1
    ControlClick, AfxWnd42u22, ahk_id%id%
  }
  else
  {
  ControlGet, v, Visible, , AfxWnd42u17, ahk_id%id%
    if (v)
    {
      ControlFocus, AfxWnd42u17, ahk_id%id%
      Sleep, -1
      ControlClick, AfxWnd42u17, ahk_id%id%
    }
  }
}

CallParty(id)
{
  ControlGet, v, Visible, , AfxWnd42u18, ahk_id%id%
  if (v)
  {
    ControlFocus, AfxWnd42u18, ahk_id%id%
    Sleep, -1
    ControlClick, AfxWnd42u18, ahk_id%id%
  }
}

RaiseParty(id)
{
  ControlGet, v, Visible, , AfxWnd42u19, ahk_id%id%
  if (v)
  {
    ControlFocus, AfxWnd42u19, ahk_id%id%
    Sleep, -1
    ControlClick, AfxWnd42u19, ahk_id%id%
  }
}

PotSizeParty(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global deduct_rake
  global fphg_party_hh_folder
  global debug
  global fphg_uselive
  WinGetTitle, title, ahk_id%id%
  
  nl_actions = calls [,raises [,bets [,all-In  [,posts ante [,posts small blind [,posts big blind [, posts big blind + dead [
  
  notraked := 0
  maxrake := 3
  tourney := 0
  
  StringTrimRight, tablename, title, ( StrLen(title) - (InStr(title, " - ")-1) )
  
  
  ;Get hero's screen name from the window title
  StringMid, hero, title, InStr(title, "Luck ") + 5
  StringMid, hero, hero, InStr(hero, "!")-2,, L
  StringReplace, hero, hero, %A_SPACE%,, All
  ;Msgbox %hero%
  hhf := fphg_party_hh_folder . tablename . ".hhf"
  
  if (fphg_uselive)
  {
    ControlGetText, handnum, This hand#, ahk_id%id%
    StringTrimLeft, handnum, handnum, InStr(handnum, "#")
    StringReplace, handnum, handnum, `,,, All
    StringReplace, handnum, handnum, .,, All
    StringReplace, handnum, handnum, %A_SPACE%,, All
    ;Msgbox, %handnum%
    hhf := fphg_party_hh_folder . "live\" . handnum . ".live"
  }
  
  ;Msgbox %hhf%
  FileRead, hh, %hhf%
  if not ErrorLevel
  {
    ControlGetText, currenthand, This Hand, ahk_id%id%
    StringReplace, currenthand, currenthand, `,,, All
    StringTrimLeft, currenthand, currenthand, InStr(currenthand, "#")
    StringReplace, currenthand, currenthand, %A_SPACE%,, All
    currenthand := "Hand History for Game " . currenthand
    ;Msgbox, %currenthand%
    StringTrimLeft, hh, hh, InStr(hh, currenthand, true, 0)-1
    IfNotInString, hh, %currenthand%
    {
      TrayTip, BetPot,`nParty HHF reader`n`n%currenthand% not found in file %hhf%,10,17
      Exit
    }
    ;Msgbox, %hh%
  }
  else
  {
    if (fphg_uselive)
    {
      TrayTip, BetPot,`nParty HHF reader`n`nFPHG live file not found for game# %handnum%,10,17
      Exit
    }
    else
    {
      TrayTip, BetPot,`nParty HHF reader`n`nTable %tablename% hand history not found,10,17
      Exit
    }
  }
  
  ;get hero sn from hhf
  Loop, Parse, hh, `n
   {
    if(InStr(A_LoopField, "Dealt to "))
    {
      StringTrimLeft, hero, a_loopfield, 9
      StringTrimRight, hero, hero, StrLen(hero) - (InStr(hero, " [ ")-1)
      break
    }
  }
  ;msgbox, %hero%
  
  Loop, Parse, hh, `n
   {
    If a_loopfield contains %nl_actions%
     {
      StringMid, amount, a_loopfield, InStr(a_loopfield, "[") + 1, (InStr(a_loopfield, "]")-0) - InStr(a_loopfield, "[") - 1
      StringReplace, amount, amount, €
      StringReplace, amount, amount, Ł
      StringReplace, amount, amount, $
      StringReplace, amount, amount, `,,, All
      StringReplace, amount, amount, A_SPACE
      amount := RegExReplace(amount, "[A-Za-z]")
      pot += amount
      IfInString, a_loopfield, posts Small Blind [
      {
        ;StringMid, amount, a_loopfield, InStr(a_loopfield, "[") + 1, (InStr(a_loopfield, "]")-0) - InStr(a_loopfield, "[") - 1
        ;StringReplace, amount, amount, $
        sb := amount
        If a_loopfield contains %hero%
        {
          hero_position := "sb"
        }  
      }
      Else IfInString, a_loopfield, posts Big Blind [
      {
        ;StringMid, amount, a_loopfield, InStr(a_loopfield, "[") + 1, (InStr(a_loopfield, "]")-0) - InStr(a_loopfield, "[") - 1
        ;StringReplace, amount, amount, $
        bb := amount
        If a_loopfield contains %hero%
        {
          hero_position := "bb"
        }
      }
      Else If(open = 1 AND InStr(a_loopfield, "raises [", 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%
     }
   }

  if(bb = 0)
  {
    tourney := 1
    ControlGetText, text, Blinds, ahk_id%id%
    ;msgbox, %text%
    IfNotInString, text, Blinds-Antes
      StringMid, bb, text, InStr(text, "/") + 1, InStr(text, ")") - InStr(text, "/") - 1 ;___so we retrieve the big blind from the static instead
    else
      StringMid, bb, text, InStr(text, "/") + 1, InStr(text, "-","",InStr(text, "/")) - InStr(text, "/") - 1
    ;msgbox, %bb%
    
    sb := bb / 2
  
  }
  ;Msgbox, %bb%
  ;Msgbox, %sb%
  
  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, %hero%`n`n`n%hh2%
  Loop, Parse, hh2, `n
  {
    If a_loopfield contains %hero%
    {
      ;Msgbox %a_loopfield%
      If a_loopfield contains %nl_actions%
      {
        StringMid, amount, a_loopfield, InStr(a_loopfield, "[") + 1, (InStr(a_loopfield, "]")-0) - InStr(a_loopfield, "[") - 1
        StringReplace, amount, amount, $
        StringReplace, amount, amount, €
        StringReplace, amount, amount, Ł
        StringReplace, amount, amount, A_SPACE
        amount := RegExReplace(amount, "[A-Za-z]")
        hero_bet += amount
      }
    }
  }
  
  
  If (tourney <> 1)
  {
    If(deduct_rake <> 0 AND InStr(hh, "** Dealing Flop"))  
    {
      StringTrimLeft, hh, hh, InStr(hh, "** Dealing ", true, 0)
      c := InStr, hh, "** Dealing "
      ;Msgbox %hh%
      Loop, Parse, hh, `n
      {
        If a_loopfield contains %nl_actions%
        {
          StringMid, amount, a_loopfield, InStr(a_loopfield, "[") + 1, (InStr(a_loopfield, "]")-0) - InStr(a_loopfield, "[") - 1
          StringReplace, amount, amount, $
          StringReplace, amount, amount, €
          StringReplace, amount, amount, Ł
          amount := RegExReplace(amount, "[A-Za-z]")
          notraked += amount
        }
      }

      rake := Floor(pot - notraked) * 0.05
      If rake > %maxrake%
      {
        rake := maxrake
      }

      If(rake >= 0.25 AND InStr(tablename, "Jackpot"))
	rake += 0.5

      ;msgbox, rake = %rake%
      If (tourney <> 1)
      {
        pot := pot - rake
      }
    }
  }
  
  ;Msgbox %pot% 
  
  If (tourney = 1)
  {
    pot := pot + sb + bb
  }
    
  match_mode = %a_titlematchmode%
  SettitleMatchMode 2
  ControlGetText, call, Call, ahk_id%id%
  SettitleMatchMode %match_mode%
  StringMid, call, call, InStr(call, "(") + 1, InStr(call, ")") - InStr(call, "(") - 1
  StringReplace, call, call, $
  StringReplace, call, call, €
  StringReplace, call, call, Ł
  call := iif( call, call, 0 )
    
  ;Msgbox %pot%
  return
}


;******************************************************** IPOKER *******************************************

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
}



PotSizeIPoker(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global deduct_rake, debug

  rake := 0
  notraked := 0
  maxrake := 3
  tourney := 0

  nl_actions = calls $, raises to $, bets $, All-in $, posts Small Blind $, posts Big Blind $
  
  WinGetTitle, title, ahk_id %id%
  StringLeft, tableName, title, InStr(title, "-") -2
  StringTrimLeft, tableName, tableName, InStr(tableName, ":") + 1

  ;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, `n, All
  Stringreplace, ahkret1, ahkret1, `r`n, `n, All
  ;Msgbox, %ahkret1%

  StringGetPos, pos, ahkret1, (#, R
  StringTrimLeft, hh, ahkret1, pos

  ;Msgbox, %hh%
  ;FileAppend, %hh%`n`n, test.txt
  
  Loop, Parse, hh, `n
  {
    If a_loopfield contains %nl_actions%
    {	
    	StringTrimRight, amount, a_loopfield, 0
    	StringGetPos, pos, amount,%a_space%, R	
    	StringRight, amount, amount, StrLen(amount) - pos
    	StringReplace, amount, amount, `,,, All
    	StringReplace, amount, amount, %a_space%
    	StringReplace, amount, amount, $,,All
    	pot += amount
    	;msgbox %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 $", 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%
     }
   }

  IfNotInString, hh, $
    tourney := 1
   
  ;msgbox tourney: %tourney%
 
  ;Msgbox, BB: %bb%
  ;Msgbox, SB: %sb%
  
  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%
      {
      	StringTrimRight, amount, a_loopfield, 0
      	StringGetPos, pos, amount,%a_space%, R	
      	StringRight, amount, amount, StrLen(amount) - pos
      	;StringReplace, amount, amount, `r,,, All
      	StringReplace, amount, amount, `,,, All
      	StringReplace, amount, amount, %a_space%
      	StringReplace, amount, amount, $,,All
      	notraked += amount       
        ;Msgbox %a_loopfield%`n%amount%
      	If a_loopfield contains %hero%
        {
      		hero_bet += amount
        }
      	Else
        {
        	call := amount
        	;Msgbox, %call%
        }
     }
  } 
  
  if(hero_bet >= call)
  {
    call := 0
  }
  Else
  {
    call -= hero_bet
  }

  call := iif( call, call, 0 )

  If (tourney <> 1)
  {
    If(deduct_rake AND street <>"pre")  
    {

      rake := Floor(pot - notraked) * 0.05
      If (rake > maxrake)
      {
        rake := maxrake
      }
      pot := pot - rake
    }
  }
  ;Msgbox Pot: %pot%`nrake:%rake%`nhero bet:%hero_bet%`ncall:%call%

  
   return
}


;returns the amount currently written into the ipoker bet box, or -1 if it can't be read
ReadBetBoxIPoker(id)
{      
	global border, caption, iPokerLoop, ipoker_test_betbox ;, iPokerBetBoxX, iPokerBetBoxY
  iPokerSetCoords(id)
  ;return -1
  
  ;Critical, On
	MouseGetPos, x, y
	PostLeftClick(1, 1, id, 1)
	WinWaitActive, ahk_id %id%

	;move the cursor to the box using tab
	loop, %ipokerLoop%
	  Send +{tab}

	sleep 50
	;MouseGetPos, x2, y2

;msgbox %ipokerbetboxx% %x2% %ipokerbetboxy% %y2%
;	if (x2 = iPokerBetBoxX AND y2 = iPokerBetBoxY)
;	{
		oldClipboard = %clipboard%
		clipboard =

		Send {HOME}+{END}^c
		ClipWait, 0.3
		If !ErrorLevel
	    	  t := clipboard
 		clipboard = %oldClipBoard%
;	}

	MouseMove, x, y, 0
	if t=
	  t = -1

	return t
}

;writes the bet amount into the bet box if it is visible
WriteBetBoxIpoker(id, amount)
{
	global border, caption, ipoker_test_betbox, iPokerLoop, iPokerRaiseX, iPokerRaiseY, move_cursor ;, iPokerBetBoxX, iPokerBetBoxY
  ;Critical, On
  iPokerSetCoords(id)
	
  
  MouseGetPos, x, y
	PostLeftClick(1, 1, id, 1)
	WinWaitActive, ahk_id %id%
	loop, %ipokerLoop%
	  Send +{tab}

;	sleep 50
;	MouseGetPos, x2, y2
;msgbox %ipokerbetboxx% %ipokerbetboxy% %x2% %y2%
	
	;if (x2 = iPokerBetBoxX AND y2 = iPokerBetBoxY)
	;{
	   Send {HOME}
	   Send +{END}
	   Send %amount%
	;}

sleep, 5
	If (move_cursor)
		MouseMove, ipokerRaiseX, (iPokerRaiseY + caption), 0
	else
	  MouseMove, x, y, 0
}


/*

ReadBetBoxIPoker(id)
{
  global border,caption
  Critical, On
  clipboard=
  PostLeftClick(1, 1, id, 1)
	WinWaitActive, ahk_id %id%
  
  foundit := 0
  VarSetCapacity(CurrentCursorStruct, 20, 0)
  InsertInteger(20, CurrentCursorStruct, 0)
  CoordMode, Mouse, Screen
  MouseGetPos, ox, oy
  WinGetPos, x, y, w, h, ahk_id%id%
  Loop, 30
  {
    ;ControlSend,,{TAB},ahk_id%id%
    Send +{TAB}
    Sleep, -1
    MouseGetPos, mx, my
    rx := mx - (x + border)
    ry := my - (y + caption)
    ;TrayTip, mpos, %rx% %ry%
    if (ry > ((h - caption)/2))
    {
      if (rx > ((w - border)/2))
      {
        InsertInteger(20, CurrentCursorStruct, 0)
        result := DllCall("GetCursorInfo", "str", CurrentCursorStruct)
        hcursor := ExtractInteger(CurrentCursorStruct, 8)
        if (hcursor = 65557)
        {
          ;Sleep, 3000
          ;TrayTip, mpos, %rx% %ry%`n`n%hcursor%
          ;msgbox, ding
          foundit := 1
          ;Traytip, dsada,%A_Index%
          
          ;ControlSend,,+{END},ahk_id%id%
          break
        }
      }
    }
  }
  if (foundit)
  {
    ControlSend,,{HOME}+{END}^c,ahk_id%id%
    ClipWait, 0.3
		if (!ErrorLevel)
		{
	    t := clipboard
      if (!t)
      {
        t = -1
      }
    }
	}
	else
	{
    t = -1
  }
	MouseMove, ox, oy
  return t
}

WriteBetBoxIPoker(id, amount)
{
  global border,caption
  Critical, On
  PostLeftClick(1, 1, id, 1)
	WinWaitActive, ahk_id %id%
  
  foundit := 0
  VarSetCapacity(CurrentCursorStruct, 20, 0)
  InsertInteger(20, CurrentCursorStruct, 0)
  CoordMode, Mouse, Screen
  MouseGetPos, ox, oy
  WinGetPos, x, y, w, h, ahk_id%id%
  Loop, 30
  {
    ;ControlSend,,{TAB},ahk_id%id%
    Send +{TAB}
    Sleep, -1
    MouseGetPos, mx, my
    rx := mx - (x + border)
    ry := my - (y + caption)
    ;TrayTip, mpos, %rx% %ry%
    if (ry > ((h - caption)/2))
    {
      if (rx > ((w - border)/2))
      {
        InsertInteger(20, CurrentCursorStruct, 0)
        result := DllCall("GetCursorInfo", "str", CurrentCursorStruct)
        hcursor := ExtractInteger(CurrentCursorStruct, 8)
        if (hcursor = 65557)
        {
          ;Sleep, 3000
          ;TrayTip, mpos, %rx% %ry%`n`n%hcursor%
          ;msgbox, ding
          foundit := 1
          Traytip, dsada,%A_Index%
          
          ;ControlSend,,+{END},ahk_id%id%
          break
        }
      }
    }
  }
  if (foundit)
  {
    ;ControlSend,,{HOME}+{END},ahk_id%id%
    ;ControlSend,,%amount%,ahk_id%id%
    Send {HOME}
	  Send +{END}
	  Send %amount%
  }
	else
	{
    return 0
  }
	MouseMove, ox, oy
  return 1
}
*/

ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process
; (since pSource might contain valid data beyond its first binary zero).
{
	Loop %pSize%  ; Build the integer by adding up its bytes.
		result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1)
	if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
		return result  ; Signed vs. unsigned doesn't matter in these cases.
	; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
	return -(0xFFFFFFFF - result + 1)
}

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
; The caller must ensure that pDest has sufficient capacity.  To preserve any existing contents in pDest,
; only pSize number of bytes starting at pOffset are altered in it.
{
	Loop %pSize%  ; Copy each byte in the integer into the structure as raw binary data.
		DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
}


PotSizeStars(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global use_old_stars_buttons
  CoordMode, Pixel, Screen
  WinGetPos, x, y, w, h, ahk_id%id%

  x1 := 700
  y1 := 440
  x2 := 770
  y2 := 450
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  
  bb := GetBBStars(id, GameTypeStars(WinGetTitle(id)))
  sb := sb(bb)

  col := GetPredominateColor(x1, y1, x2, y2)
  ;Msgbox, %col%
  if (col = "0x00327F")
  {
    ;ThemeDir := "normal"
    PotThemeDir := "classic"
    CallThemeDir := "classic"
  
  }
  else if (col = "0xDDD7CC")
  {
    PotThemeDir := "hypersimple"
    CallThemeDir := "hypersimple"
  
  }
  else
  {
    if (debug)
    {
      Msgbox, Unable to match slider colour: %col% to a known theme
    }
    return
  }
  if (use_old_stars_buttons)
  {
    CallThemeDir := CallThemeDir . "\old"
  }
 
  street := GetStreetStars(id)

  if (w <= 526)
  {
    SizeDir := 0
  }
  else if (w <= 621)
  {
    SizeDir := 1
  }
  else if (w <= 736)
  {
    SizeDir := 2
  }
  else if (w <= 875)
  {
    SizeDir := 3
  }
  else if (w <= 1037)
  {
    SizeDir := 4
  }
  else if (w <= 1227)
  {
    SizeDir := 5
  }
  else
  {
    SizeDir := 6
  } 

 
  PicDir := "StarsPics"
  potPicDir := PicDir . "\" . PotThemeDir . "\pot\" . SizeDir
  buttonPicDir := PicDir . "\" . CallThemeDir . "\call\" . SizeDir
  ;Msgbox, %potPicDir%`n%buttonPicDir%

  pot_x1 := 380
  pot_y1 := 8
  pot_x2 := 460
  pot_y2 := 32
  relStarsWindowPoint(id, pot_x1, pot_y1)
  relStarsWindowPoint(id, pot_x2, pot_y2)
  pot := DigitSearch(pot_x1, pot_y1, pot_x2, pot_y2, id, potPicDir, "", 50)

  pot := pot * bb
  
  call_x1 := 550
  call_y1 := 510
  call_x2 := 645
  call_y2 := 533
  relStarsWindowPoint(id, call_x1, call_y1)
  relStarsWindowPoint(id, call_x2, call_y2)
  call := DigitSearch(call_x1, call_y1, call_x2, call_y2, id, buttonPicDir, "", 50)
  call := iif( call, call, 0 )

  call := call * bb
  
  
  if (street = "pre")
  {
    ControlGetText, t, %stars_editbox%, ahk_id%id%
    ControlSetText, %stars_editbox%, 0, ahk_id%id%
    raise_x1 := 675
    raise_y1 := 510
    raise_x2 := 770
    raise_y2 := 533
    relStarsWindowPoint(id, raise_x1, raise_y1)
    relStarsWindowPoint(id, raise_x2, raise_y2)
    minraise := DigitSearch(raise_x1, raise_y1, raise_x2, raise_y2, id, buttonPicDir, "", 50)
    
    minraise := minraise * bb

    t := Round(t, 2)
    ControlSetText, %stars_editbox%, %t%, ahk_id%id%
    Sleep, -1
    
    if (minraise > (2*bb))
    {
      ;pot has been raised
      if (call = bb)
      {
        ;pot was minraised, and we are the BB
        hero_bet := bb
        hero_position := "bb"
      }
      else if (call < (bb*2))
      {
        ;pot was minraised, and we are the SB
        hero_bet := sb
        hero_position := "sb"
      }
    }
    else if (call = bb)
    {
      ;hero is not a blind, unraised pot, do nothing
    }
    else if (call = 0)
    {
      ;unraised pot, hero is the BB
      hero_bet := bb
      hero_position := "bb"
    }
    else if (call < bb)
    {
      ;unraised pot, hero is the SB
      hero_bet := sb
      hero_position := "sb"
    }
    else
    {
      ;pot has been raised, we are not opening
      open := 0
    }
  }
  else
  {
    ;not pre-flop, no need for open adjustment
    open := 0
  }
 
  return
}

PotSizeUB(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  
  
  CoordMode, Pixel, Screen
  WinGetPos, x, y, w, h, ahk_id%id%

  
  street := GetStreetStars(id)

 
 
  PicDir := "UBPics"
  potPicDir := PicDir  ;. "\" . PotThemeDir . "\pot\" . SizeDir
  buttonPicDir := PicDir ;. "\" . CallThemeDir . "\call\" . SizeDir
  ;Msgbox, %potPicDir%`n%buttonPicDir%

  pot_x1 := 580
  pot_y1 := 460
  pot_x2 := 700
  pot_y2 := 480
  relStarsWindowPoint(id, pot_x1, pot_y1)
  relStarsWindowPoint(id, pot_x2, pot_y2)
  pot := DigitSearch(pot_x1, pot_y1, pot_x2, pot_y2, id, potPicDir, "", 50)
  
  call_x1 := 350
  call_y1 := 460
  call_x2 := 460
  call_y2 := 480
  relStarsWindowPoint(id, call_x1, call_y1)
  relStarsWindowPoint(id, call_x2, call_y2)
  call := DigitSearch(call_x1, call_y1, call_x2, call_y2, id, buttonPicDir, "", 50)
  call := iif( call, call, 0 )


  WinGetTitle, title, ahk_id%id%
  
  StringTrimLeft, bb, title, InStr(title, "$", true, 0)-1 
  StringTrimRight, bb, bb, Strlen(bb) - InStr(bb, A_Space)
  StringReplace, bb, bb, $., $0., All
  StringReplace, bb, bb, $,, All
  StringReplace, bb, bb, %A_Space%,, All

  ;bb := GetBBStars(id, GameTypeStars(WinGetTitle(id)))
  sb := sb(bb)
  
  
  if (street = "pre")
  {
    ControlGetText, t, Edit1, ahk_id%id%
    ControlSetText, Edit1, 0, ahk_id%id%
    raise_x1 := 460
    raise_y1 := 460
    raise_x2 := 580
    raise_y2 := 480
    relStarsWindowPoint(id, raise_x1, raise_y1)
    relStarsWindowPoint(id, raise_x2, raise_y2)
    minraise := DigitSearch(raise_x1, raise_y1, raise_x2, raise_y2, id, buttonPicDir, "", 50)
    t := Round(t, 2)
    ControlSetText, Edit1, %t%, ahk_id%id%
    Sleep, -1
    
    if (minraise > (2*bb))
    {
      ;pot has been raised
      if (call = bb)
      {
        ;pot was minraised, and we are the BB
        hero_bet := bb
        hero_position := "bb"
      }
      else if (call < (bb*2))
      {
        ;pot was minraised, and we are the SB
        hero_bet := sb
        hero_position := "sb"
      }
    }
    else if (call = bb)
    {
      ;hero is not a blind, unraised pot, do nothing
    }
    else if (call = 0)
    {
      ;unraised pot, hero is the BB
      hero_bet := bb
      hero_position := "bb"
    }
    else if (call < bb)
    {
      ;unraised pot, hero is the SB
      hero_bet := sb
      hero_position := "sb"
    }
    else
    {
      ;pot has been raised, we are not opening
      open := 0
    }
  }
  else
  {
    ;not pre-flop, no need for open adjustment
    open := 0
  }
  ;pot := pot - (2*hero_bet)
  pot := pot - (2 * call) - hero_bet
  return
}



DigitSearch(startX,startY,endX,endY,win,dir,ex="",shades=1) {

global debug

If ex =
 ex = bmp
batchlines = %A_BatchLines%
SetBatchLines -1
;WinGetPos,Xwin,Ywin,,,ahk_id%win%
WinGetPos,Xwin,Ywin,w,h,ahk_id%win%

;Msgbox, %startX%,%startY%`n%endX% %endY%


CoordMode, Pixel, Screen
Loop, 11 {
  i = %a_index%
  If i = 10
    i = 0
  else if i = 11
    i = -1
  lastXpos := startX + Xwin
  Loop {
    
    
    
    
    x1 := lastXpos + 1
    y1 := startY + Ywin
    x2 :=  endX + Xwin
    y2 := endY + Ywin
    
    if (debug)
    {
      debug_gui(id, x1, y1, x2, y2, 50)
    }
    
    ImageSearch, lastXpos,, x1, y1, x2, y2, *%shades% %dir%\%i%.%ex%
    
    
    If ( errorLevel )
    {
      break
    }
    p++
    p%p% = %lastXpos%
    If i = -1
      t = .
    else
      t = %i%
    StringReplace, xpos, lastXpos, -, _
    c%xpos% = %t%
   }
 }

Loop, %p%
 p_all := p_all "," p%a_index%

Sort, p_all, N D, U
;Msgbox %p_all%
Loop, Parse, p_all, `,
{
 StringReplace, xpos, a_loopfield, -, _
    
 amount := amount "" c%xpos%
 ;Msgbox,%amount%
} 
CoordMode, Pixel, Relative
SetBatchLines %batchlines%
return amount
}



;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
 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%
}

PostStarsClick(x, y, id)
{
  relStarsClientPoint(id, x, y)
  PostLeftClick(x, y, id)
}




GetBBStars(id, game_type) {
WinGetTitle, title, ahk_id%id%
game_type = NL Ring
If (game_type = "NL Ring")
 return StrRep(StrMid(title,"/",a_space), "$")
else if (game_type = "NL Tourney")
 return StrRep(StrMid(title,"/",a_space,InStr(title," - Blinds")),"$")
}


GameTypeStars(title) {
If InStr(title, " - Limit Stud")
 return "Stud"
else if ((InStr(title, " - No Limit Hold'em") || InStr(title, " - Pot Limit Hold'em"))
  && InStr(title, "Tournament"))
 return "NL Tourney"
else if (InStr(title, " - No Limit Hold'em") || InStr(title, " - Pot Limit Hold'em"))
 return "NL Ring"
else
 return "Limit"
}

sb(bb) {
If bb = .25
 sb := .10
else if bb = 15
 sb = 10
else if bb = 0.05
 sb = 0.02
else
 sb := bb/2
 
if (sb > 1)
{
  sb := Round(sb, 0)
}
else
{
  sb := Round(sb, 2)
}
return sb
}






GetStreetStars(id)
{
  global debug
  CoordMode, Pixel, Screen

  street := "pre"
  
  x1 := 490
  y1 := 155
  x2 := 525
  y2 := 205
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  
  
  
  
  if (debug)
    {
      debug_gui(id, x1, y1, x2, y2)
    }
  If ( GetPixelCount(x1, y1, x2, y2, 0xffffff) > 5 )
  {
    street := "river"
    return street
  }
  
  x1 := 435
  y1 := 155
  x2 := 470
  y2 := 205
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  if (debug)
    {
      debug_gui(id, x1, y1, x2, y2)
    }
  If ( GetPixelCount(x1, y1, x2, y2, 0xffffff) > 5 )
  {
    street := "turn"
    return street
  }



  x1 := 382
  y1 := 155
  x2 := 415
  y2 := 205
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  if (debug)
    {
      debug_gui(id, x1, y1, x2, y2)
    }
  If ( GetPixelCount(x1, y1, x2, y2, 0xffffff) > 5 )
  {
    street := "flop"
  }

  return street
}

GetStreetFT(id)
{
  global debug
  global caller_hwnd
  if (caller_hwnd != "")
  {
    id := caller_hwnd
  }
  CoordMode, Pixel, Screen

  street := "pre"
  
  x1 := 485
  y1 := 214
  x2 := 520
  y2 := 260
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  
  
  
  
  if (debug)
    {
      debug_gui(id, x1, y1, x2, y2)
    }
  If ( GetPixelCount(x1, y1, x2, y2, 0xffffff) > 5 )
  {
    street := "river"
    return street
  }
  
  x1 := 431
  y1 := 214
  x2 := 461
  y2 := 260
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  if (debug)
    {
      debug_gui(id, x1, y1, x2, y2)
    }
  If ( GetPixelCount(x1, y1, x2, y2, 0xffffff) > 5 )
  {
    street := "turn"
    return street
  }



  x1 := 378
  y1 := 214
  x2 := 414
  y2 := 260
  relStarsScreenPoint(id, x1, y1)
  relStarsScreenPoint(id, x2, y2)
  if (debug)
    {
      debug_gui(id, x1, y1, x2, y2)
    }
  If ( GetPixelCount(x1, y1, x2, y2, 0xffffff) > 5 )
  {
    street := "flop"
  }

  return street
}





StrRep(str,char,rep_char="",all=1)
{
  StringReplace,str,str,%char%,%rep_char%,%all%
  return str
}

StrMid(str,str1,str2,startPos1=1,startPos2=1,caseSense=0){
If startPos1 =
 startPos1 = 1
If startPos2 =
 startPos2 = 1
StringTrimLeft,o,str,InStr(str,str1,cS,startPos1) + StrLen(str1) - 1
StringLeft,o,o,InStr(o,str2,caseSense,startPos2)-1
return o
}

IIf(_boolExpr, _exprTrue, _exprFalse) {
If _boolExpr
 Return _exprTrue
else
 return _exprFalse
}


WinGetTitle(win) {
WinGetTitle, title, ahk_id%win%
return title
}

; finds number of specified pixels in a region
GetPixelCount(x1, y1, x2, y2, color, options="")
{
  CoordMode, Pixel, Screen
  pixels := (x2 - x1 + 1)*(y2 - y1 + 1)
  If ( pixels <= 0 )
  {
    ErrorLevel = 1
    return
  }
  count = 0
  x = %x1%
  Loop
  {
    If ( x > x2 )
    {
      break
    }
    y = %y1%
    Loop
    {
      If ( y > y2 )
      {
        break
      }
      PixelGetColor, c, x, y, %options%
      If ( c = color )
      {
        count++
      }
      y++
    }
    x++
  }
  return count
}
; finds the predomatinate color in a region
GetPredominateColor(x1,y1,x2,y2,options="") {
global debug

if (debug)
  {
    debug_gui(id, x1, y1, x2, y2)
  }  
pixels := (x2 - x1 + 1)*(y2 - y1 + 1)
If ( pixels <= 0 ) {
        ErrorLevel = -1
        return
 }
x = %x1%
Loop {
        If ( x > x2 )
                break
        y = %y1%
        Loop {
                        If ( y > y2 )
                                break
                        PixelGetColor, c, x, y, %options%
                        num%c%++
                        all_colors = %all_colors%|%c%
                        y++
                        ;done++
                        ;Tooltip % Floor((done/pixels)*100) "%"
         }
        x++
 }
StringTrimLeft, all_colors, all_colors, 1
num%pred_c% = 0
Loop, Parse, all_colors, |
 {
        If ( num%a_loopfield% > num%pred_c% )
                pred_c = %a_loopfield%
 }
ErrorLevel := num%pred_c%
return pred_c
}



getid()
{
  global act_only_on_active_table
  ;ut := UrgentTable()
  ;if (ut)
  ;{
  ;  id := ut
  ;}
  ;else
  ;{
    tn := TableNav()
    if (tn)
    {
      id := tn
    }
    else
    {
      id := ""
      if (act_only_on_active_table = 1)
      {
        ;MsgBox, Active Table Mode
        WinGet,id,,A
      }
      else
      {
        ;MsgBox, Table Under Cursor Mode
        MouseGetPos, , , id
      }
    }
  ;}
  return id
}

TableNav()
{
  If ! WinExist("blue_bar ahk_class AutoHotkeyGUI")
    return 0
  SendMessage, 0x5555
  return WinExist("ahk_id" errorLevel )
}

UrgentTable()
{
  If ! WinExist("urgent_table ahk_class AutoHotkeyGUI")
    return 0
  SendMessage, 0x5555
  return WinExist("ahk_id" errorLevel )
}


relStarsClientPoint(id, ByRef x, ByRef y)
{
  global border
  global caption
  rw := 792
  rh := 546
  WinGetPos, , , w, h, ahk_id%id%
  w := w - (2*border)
  h := h - (2*border) - caption
  
  x := Floor( (x / rw ) * w )
  y := Floor( (y / rh) * h  )
  
}

relStarsWindowPoint(id, ByRef x, ByRef y)
{
  global border
  global caption
  relStarsClientPoint(id, x, y)
  x := x + border
  y := y + border + caption
}

relStarsScreenPoint(id, ByRef x, ByRef y)
{
  relStarsWindowPoint(id, x, y)
  WinGetPos, x1, y1, , , ahk_id%id%
  x += x1
  y += y1
}


reverse_calc_stars_client_area(cw, ByRef w, ByRef h)
{
  global border
  global caption
  w := cw + (2*border) 
  h := Floor(cw / 1.45) + (2*border) + caption
}

client_area(id, ByRef x, Byref y, ByRef w, Byref h)
{
  WinGetPos, x, y, w, h, ahk_id%id%
  global border
  global caption
  x := x + border
  y := y + border + caption
  w := w - (2*border)
  h := h - (2*border) - caption
  return
}


debug_gui(id, x1, y1, x2, y2, delay=500)
{
  Gui, 2: +Alwaysontop +Lastfound +Owner
  Gui, 2: Color, ffffff
  WinSet, Transparent, 200
  Gui, 2: -Caption
  w1 := x2 - x1
  h1 := y2 - y1
  Gui, 2: Show, w%w1% h%h1% x%x1% y%y1% NoActivate
  Sleep, %delay%
  Gui,2: Destroy
}

FoldUB(id)
{
  ControlGet, v, Visible, , Button29, ahk_id%id%
  if (v)
  {
    ControlFocus, Button29, ahk_id%id%
    Sleep, -1
    ControlClick, Button29, ahk_id%id%
  }
  else
  {
    ControlGet, v, Visible, , Button16, ahk_id%id%
    if (v)
    {
      ControlFocus, Button16, ahk_id%id%
      Sleep, -1
      ControlClick, Button16, ahk_id%id%
    }
    else
    {
      ControlGet, v, Visible, , Button18, ahk_id%id%
      if (v)
      {
        ControlFocus, Button18, ahk_id%id%
        Sleep, -1
        ControlClick, Button18, ahk_id%id%
      }
      else
      {
        ControlGet, v, Visible, , Button13, ahk_id%id%
        if (v)
        {
          ControlFocus, Button13, ahk_id%id%
          Sleep, -1
          ControlClick, Button13, ahk_id%id%
        }
      }
    }
  }
}

CallUB(id)
{
  ControlGet, v, Visible, , Button19, ahk_id%id%
  if (v)
  {
    ControlFocus, Button19, ahk_id%id%
    Sleep, -1
    ControlClick, Button19, ahk_id%id%
  }
}

RaiseUB(id)
{
  ControlGet, v, Visible, , Button51, ahk_id%id%
  if (v)
  {
    ControlFocus, Button51, ahk_id%id%
    Sleep, -1
    ControlClick, Button51, ahk_id%id%
  }
}

FoldStars(id)
{
  PostStarsClick(416,501,id)
  Sleep, 20
  PostStarsClick(416,478,id)
 
}

CallStars(id)
{
  PostStarsClick(600,533,id)
}
RaiseStars(id)
{
  PostStarsClick(730,520,id)
}

FoldIPoker(id)
{
  ;msgbox, sdad
  global iPokerFoldX, iPokerFoldY
  ;Click, %iPokerFoldx%, %iPokerFoldY%
  iPokerSetCoords(id)
  PostLeftClick(iPokerFoldx,(iPokerFoldY+10),id)
  PostLeftClick(iPokerFoldx,iPokerFoldY,id)
  ;PostLeftClick(378,(522),id)
  
}

CallIPoker(id)
{
  global iPokerCallx, ipokerCally
  Click, %iPokerCallX%, %iPokerCallY%
}

RaiseIPoker(id)
{
  global iPokerRaiseX, ipokerRaiseY
  Click, %ipokerRaiseX%, %iPokerRaiseY%
}

FoldCrypto(id)
{
  PostStarsClick(480,500,id)
}

CallCrypto(id)
{
  PostStarsClick(602,534,id)
}
RaiseCrypto(id)
{
  PostStarsClick(726,534,id)
}


FoldFT(id)
{
  global FTP_Beta
  global fold_to_any
  
  if (FTP_Beta)
  {
    if (fold_to_any)
    {
      ControlGet, v, Visible, , FTCSkinButton35, ahk_id%id%
      if (v)
      {
        ControlFocus, FTCSkinButton35, ahk_id%id%
        Sleep, -1
        ControlClick, FTCSkinButton35, ahk_id%id%
      }
    }
    
    else
    {
      ControlGet, v, Visible, , FTCSkinButton29, ahk_id%id%
      if (v)
      {
        ControlFocus, FTCSkinButton29, ahk_id%id%
        Sleep, -1
        ControlClick, FTCSkinButton29, ahk_id%id%
      }
      else
      {
        ControlGet, v, Visible, , FTCSkinButton11, ahk_id%id%
        if (v)
        {
          ControlFocus, FTCSkinButton11, ahk_id%id%
          Sleep, -1
          ControlClick, FTCSkinButton11, ahk_id%id%
        }
      }
    }
  }
  else
  {
    /*
    ControlGet, v, Visible, , FTCButton31, ahk_id%id%
    if (v)
    {
      ControlFocus, FTCButton31, ahk_id%id%
      Sleep, -1
      ControlClick, FTCButton31, ahk_id%id%
    }
    */
  }
}

CallFT(id)
{
  global FTP_Beta
  if (FTP_Beta)
  {
    ControlGet, v, Visible, , FTCSkinButton12, ahk_id%id%
    if (v)
    {
      ControlFocus, FTCSkinButton12, ahk_id%id%
      Sleep, -1
      ControlClick, FTCSkinButton12, ahk_id%id%
    }
  }
  /*
  else
  {
    ControlGet, v, Visible, , FTCButton11, ahk_id%id%
    if (v)
    {
      ControlFocus, FTCButton11, ahk_id%id%
      Sleep, -1
      ControlClick, FTCButton11, ahk_id%id%
    }
    else
    {
      ControlGet, v, Visible, , FTCButton11, ahk_id%id%
      if (v)
      {
        ControlFocus, FTCButton11, ahk_id%id%
        Sleep, -1
        ControlClick, FTCButton11, ahk_id%id%
      }
    }
  }
  */
}

RaiseFT(id)
{
  global FTP_Beta
  if (FTP_Beta)
  {
    ControlGet, v, Visible, , FTCSkinButton13, ahk_id%id%
    if (v)
    {
      ControlFocus, FTCSkinButton13, ahk_id%id%
      Sleep, -1
      ControlClick, FTCSkinButton13, ahk_id%id%
    }
  }
  /*
  else
  {
    ControlGet, v, Visible, , FTCButton13, ahk_id%id%
    if (v)
    {
      ControlFocus, FTCButton13, ahk_id%id%
      Sleep, -1
      ControlClick, FTCButton13, ahk_id%id%
    }
  }
  */
}



/*

ControlClick, AfxWnd42u19, ahk_id%id%
    } 
  }
  Else IfWinExist, ahk_id%id% ahk_group CryptoTables
  {
    ControlSetText, Edit3, %pot%, ahk_id%id%
    Sleep -1
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      PostLeftClick(730, 540, id)
    } 
  }
  Else IfWinExist, ahk_id%id% ahk_group FullTiltTables
  {
    ControlGet, v, Visible, , Edit1, ahk_id%id%
    if (v)
    {
      ;Msgbox, %pot%
      if (pot > max)
      {
        pot := max
      }
      ControlSetText, Edit1, %pot%, ahk_id%id%
      Sleep -1
      ;WinSet, Redraw,, ahk_id%id%
      If(autobet)
      {
        ab := 0
        Loop, 20
        {
          ControlGetText, t, Edit1, ahk_id%id%
          if (t < pot || t > pot)
          {
            Sleep, 100
          }
          else
          {
            ;TrayTip, ,  %ab% %t% %pot%
            Sleep, 200
            ControlFocus, FTCButton11, ahk_id%id%
            Sleep, -1
            ControlClick, FTCButton11, ahk_id%id%
            ;ab := 1
            break
          }
        }
        ;TrayTip, ,  %ab% %t% %pot%
        ;if (ab)
        ;{
        ;  ControlFocus, FTCButton11, ahk_id%id%
        ;  Sleep, -1
        ;  ControlClick, FTCButton11, ahk_id%id%
        ;}
      }
    }
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    ControlFocus, Edit1, ahk_id%id%
    ControlSetText, Edit1, %pot%, ahk_id%id%
    Sleep, -1
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      WinActivate, ahk_id%id%
      WinWaitActive, ahk_id%id%, , 1
      If (errorlevel<>1)
      {
        Send, {ENTER}
      }   
    } 
  }
}

Last edited by _dave_; 08-20-2010 at 07:42 PM.
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 06:54 PM
I did that it says error at line 105

line text ahk_pid%
error this parameter contains a variable name missing its ending percent sign
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 06:58 PM
fixed, try again.

no idea how that error got in there, it's not in your original paste!
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 07:04 PM
I re copied and pasted the new edit and the same error prob arises.
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 07:14 PM
pureklas, replace that line with
Code:
GroupAdd, UBTables, ahk_pid%ub%,,, UltimateBet
_dave_, i can't see why you are refering to Edit7 control instead of PokerStarsSliderEditorClass1 in PotSizeStars function.
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 07:20 PM
Ok I did that and now it says:

include file betpot default hotkeys.txt cannot be opened
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 07:28 PM
So put that ahk file into the folder with betpot_default_hotkeys.txt file, starspics folder etc
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 07:38 PM
No more error messages, but the pot button = 5.5 bb
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 07:45 PM
Quote:
Originally Posted by Max1mums
pureklas, replace that line with
Code:
GroupAdd, UBTables, ahk_pid%ub%,,, UltimateBet
_dave_, i can't see why you are refering to Edit7 control instead of PokerStarsSliderEditorClass1 in PotSizeStars function.
Well spotted TY, fixed / edited again for future reference. I was going off an old version on my desktop since overcards is down and I'm not on my main "poker computer" right now. I'll have to check if the same error is in the latest versions too

WTF WTF WTF... ahk_pid% simply would not "stick" in my post, i just re-edited it like 5 times changed to %uubb% and it saves fine lol.

^^^ I typed % u b % (no spaces) there too wtf. maybe UB is censored? that shouldn't even be in BetPot any more really, it hasn't worked since they dropped the old superfast client software.

Quote:
Originally Posted by pureklas
No more error messages, but the pot button = 5.5 bb
is that an ante table?
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 08:05 PM
I just tried it again same stakes 100bb no antes and pot is a min raise?
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 08:19 PM
Off to bed now guys. Thanks for all your help tonight. I will check this thread in the morning.
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 08:22 PM
turn on debug mode and see what's wrong. I don't see what could be causing these wildly different amounts. maybe easiest to check it out over teamviewer
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 08:46 PM
Quote:
Originally Posted by Neko
I've said it before, but man AHK is an ugly ass language.
indeed, but its more a scripting language than programming language. i learned it entirely from looking at dave's and other's old scripts on overcards. unfortunately, the AHK author doesnt seem too keen on updating things, so it will probably remain how it is currently. i've run into a few limitations, but i'm so reluctant to move StackAndTile to a new langauge because it would just take so damn long to learn everything

plus there is already a decent AHK community here for poker related scripts that its just easier to keep things going. and open source is really important for all these small programs that poker players use. its just too risky for a poker player to run untrusted executables, as contradictory as that sounds re: SaT
Quick Questions &amp; Answers Thread Quote
08-20-2010 , 09:07 PM
Yeah, I'm not really knocking it, I think AHK may be the best tool of its kind. It has also become ubiquitous within the poker community which makes distributing scripts easy..it's just the syntax is pretty ugly (IMO) and makes me not want to write scripts in it.

It's possible to do the same stuff in Python (for example) but not really as easily.
Quick Questions &amp; Answers Thread Quote
08-21-2010 , 06:10 AM
Not sure if this is the problem or not, but it doesn't appear to be reading the pot size when I put debug on. The half pot isn't working post flop either, so I guess this is the issue.

Last edited by pureklas; 08-21-2010 at 06:20 AM.
Quick Questions &amp; Answers Thread Quote
08-21-2010 , 08:15 AM
Do you know what kind of tournament clock does the WSOP use? Is it available to the public?
Quick Questions &amp; Answers Thread Quote
08-22-2010 , 01:16 AM
Is the Pokerstove website still dangerous?
Quick Questions &amp; Answers Thread Quote
08-22-2010 , 01:23 AM
I don't think so, but obv. no guarantees! if you're worried, use holdem ranger instead? it's domain is jacked (lol no luck with these equity calculator websites!), but there's a thread in this forum with the IP address link to site that works good.
Quick Questions &amp; Answers Thread Quote
08-24-2010 , 01:08 PM
been reading up on source control and just started using GIT

hopefully my life will be easier than constantly clicking save as revisionnumber+1
Quick Questions &amp; Answers Thread Quote
08-24-2010 , 01:24 PM
haha, once you get the hang of it, you will be wondering how you got along without it before!

git is a bit of a pain to learn, but it's what I use right now and like it well enough.
Quick Questions &amp; Answers Thread Quote
08-24-2010 , 01:30 PM
do you just edit/modify/commit new work? or branch/merge?
Quick Questions &amp; Answers Thread Quote
08-24-2010 , 01:37 PM
I started out just editing then commiting, but now use branches a lot.

I leave the master branch as a stable/release branch and then for every new feature I create a new branch (and sometimes sub-branches ) and then once it is stable I merge it back into master.

I am not very proficient with git yet, so I'm not sure if this is the best way to use it or not, but it works for my one man team!
Quick Questions &amp; Answers Thread Quote
08-24-2010 , 01:46 PM
Also, I use github which allows you to backup all your stuff online very quickly.

git push origin <branch>

and you're done.
Quick Questions &amp; Answers Thread Quote
08-24-2010 , 04:03 PM
Quote:
Originally Posted by Neko
I started out just editing then commiting, but now use branches a lot.

I leave the master branch as a stable/release branch and then for every new feature I create a new branch (and sometimes sub-branches ) and then once it is stable I merge it back into master.

I am not very proficient with git yet, so I'm not sure if this is the best way to use it or not, but it works for my one man team!
yea after reading some tutorials i think the branching/merge is the way to go. as for github, i thought it was only for open source projects
Quick Questions &amp; Answers Thread Quote

      
m