Open Side Menu Go to the Top
Register
$$$Eurolinx betpot not working anymore - $reward$ $$$Eurolinx betpot not working anymore - $reward$

04-30-2009 , 08:08 AM
Since last update the betpot is not working anymore.

I'll pay 20$ to someone who can fix this, i bet there is more Eurolinx players out there that would pay for this too.



I tried to fix it and this is where iam at: the wheel does increase/decrease the bet correctly, middle/right buttons too, but once you have the amount that you want to bet... there is no way to actually bet that amount.


As you can see in the screenshot below, i changed the value in the box to 100$ with the wheel but the bet button doesn't change the amount, even if i click enter, same thing happens when i right click mouse to a 3/4 pot size bet. The only way the bet button change is when i manually type the value i want to bet with the keyboard.



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

; PRIMA SECIFIC
enable_prima_actions := 0
prima_miniview := 1

; IPOKER SPECIFIC
Ipoker_miniview := 0
Ipoker_BetBoxColor = 0xFFFFFF  ;most of the iPoker skins use a white background for the bet box, if yours doesn't then you need to change this value
Ipoker_ShowBetBoxColor := 0  ;set this to 1 to pop up a message box with the bet box color when you bet pot, replace 0xFFFFFF with this.

; 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
;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, ub, pid, UltimateBet  
if (ub)
{
  GroupAdd, UBTables, ahk_pid%ub%,,, 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:

;--------- IPOKER COORDINATES -------------------
iPokerX := 557 + border
iPokerY := 462 + caption

iPokerChat := 550
iPokerRaiseX := 554
iPokerRaiseY := 545
ipokerCallx := 445
ipokerCallY:= 550
iPokerFoldX := 300
iPokerFoldY := 550

if iPoker_miniview
{
  iPokerX := 400 + border
  iPokerY := 265 + caption

  iPokerChat := 300
  iPokerRaiseX := 400
  iPokerRaiseY := 325
  ipokerCallx := 310
  ipokerCallY:= 325
  iPokerFoldX := 220
  iPokerFoldY := 325
}

return

#include betpot_default_hotkeys.ahk

Fold(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      FoldPrima(id)
    }
  }
}
  
Call(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      CallPrima(id)
    }
  }
}

Raise(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      RaisePrima(id)
    }
  }
}

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

  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") <> 0 AND InStr(title, "Buy-in") = 0)
    {
      StringMid, bb, title, InStr(title, "/")+1, InStr(title, ". ", InStr(title,"/")) - InStr(title, "/") -1
      
    }
    else if (InStr(title, "NL") <> 0 AND InStr(title, "Buy-in") <> 0)
    {
      ControlGetText, text, Static6, 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
  {
    StringReplace,title,title,€,$,1
    StringTrimLeft, bb, title, InStr(title, "/", true, 0) 
    StringMid, bb, bb, InStr(bb, " ")-1,, L
    ;MsgBox, %bb%
    
  }
  
  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, Edit3, ahk_id%id%
    if (party_uses_commas_for_decimals)
    {
      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, Edit3, %t%, ahk_id%id%
    ;WinSet, Redraw,, ahk_id%id%
  }
  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
  {
    if (prima_miniview)
    {
      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
    {
      ControlGetText, t, Edit5, ahk_id%id%
      t := t + amount
      if (t < 0)
      {
        t := 0
      }
      t := Round(t, 2)
      ControlSetText, Edit5, %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)
  	t := t + amount
  
  	if (t <= 0)
      	  return
  
  	t := Round(t, 2)
  	
  	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 ipokerchat, iPokerRaiseX, iPokerRaiseY
  global stars_editbox, prima_miniview
  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, Edit3, %pot%, ahk_id%id%
    Sleep -1
    Sleep, 50
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      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
            
            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
  {
    if (prima_miniview)
    {
      ControlFocus, edit3, ahk_id%id%
      ControlSetText, edit3, %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
    {
      ControlFocus, Edit5, ahk_id%id%
      ControlSetText, Edit5, %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
     {
	;try to write the bet five times
	attempts := 0

	loop
	{
        	if (readPot = pot OR attempts > 5)
		  break

		WriteBetBoxIpoker(id, pot)
		readPot := ReadBetBoxIpoker(id)
		attempts++
	}

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

	Click, 75, %ipokerchat%
	MouseMove, %ipokerraisex%, %ipokerraisey%
      }
   }
}


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
}



PotSizeFullTilt2_old(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
  
  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 (FTP_Beta)
  {    
    ControlGet, v, Visible, , %ftp_btn_max%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nMAX,10,17
      x := ""
      ControlSetText, Edit1,, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = "")
        {
          break
        }
        else
        {
          sleep, 40
        }
      }
      /*  ;NOT SURE WE NEED MAX ANYMORE
      ControlClick, %ftp_btn_max%, ahk_id%id%
      Loop, 50
      {
        ControlGetText, max, Edit1, ahk_id%id%
        if (max != "")
        {
          
          break
        }
        else
        {
          sleep, 40
        }
      }
      ;ControlGetText, max, Edit1, ahk_id%id%
      */
    }
    else if (InStr(title, "Cap No Limit") || InStr(title, "Pot Limit"))
    {
      ControlGet, v, Visible, , %ftp_btn_max_cap%, ahk_id%id%  ; CAP
      if (v)
      {
        ;TrayTip, BetPot,`nCAP MAX,10,17
        x := ""
        ControlSetText, Edit1,, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = "")
          {
            break
          }
          else
          {
            sleep, 40
          }
        }
        ControlClick, %ftp_btn_max_cap%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, max, Edit1, ahk_id%id%
          if (max != "")
          {
            ;if (max = "")
            ;{
            ;  continue
            ;}
            break
          }
          else
          {
            sleep, 40
          }
        }
        
      ;ControlClick, FTCButton24, ahk_id%id%
      ;  Sleep, -1
      ;  ControlGetText, max, Edit1, ahk_id%id%
      }
      else
      {
        ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
        if (v)
        {
          ;TrayTip, BetPot,`nPL MAX,10,17
          x := ""
          ControlSetText, Edit1,, ahk_id%id%
          Loop, 50
          {
            ControlGetText, x, Edit1, ahk_id%id%
            if (x = "")
            {
              break
            }
            else
            {
              sleep, 40
            }
          }
          ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
          Loop, 50
          {
            ControlGetText, max, Edit1, ahk_id%id%
            if (max != "")
            {
              ;if (max = "")
              ;{
              ;  continue
              ;}
              break
            }
            else
            {
              sleep, 40
            }
          }
        }
      }
    }
    /*
  
    ControlGet, v, Visible, , %ftp_btn_pot%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nPOT,10,17
      x := ""
      ControlSetText, Edit1,, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = "")
        {
          break
        }
        else
        {
          sleep, 40
        }
      }
      
      ControlClick, %ftp_btn_pot%, ahk_id%id%
      
      Loop, 50
      {
        ControlGetText, pot, Edit1, ahk_id%id%
        if (pot != "")
        {
          
          ;MsgBox, %A_Index%
          break
        }
        else
        {
          sleep, 40
        }
      }
      ;ControlClick, FTCButton22, ahk_id%id%
      ;Sleep, -1
      ;ControlGetText, pot, Edit1, ahk_id%id%
    }
    
    /*
    else if (InStr(title, "Pot Limit"))
    {
      ;TrayTip, BetPot,`nPL POT,10,17
      ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
      if (v)
      {
        x := ""
        ControlSetText, Edit1,, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = "")
          {
            break
          }
          else
          {
            sleep, 40
          }
        }
        ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, pot, Edit1, ahk_id%id%
          if (pot != "")
          {
            ;if (pot = "")
            ;{
            ;  continue
            ;}
            break
          }
          else
          {
            sleep, 40
          }
        }
      }
    }
    */
    
    ; AGAIN NOT SURE
    ;else
    ;{
    ;  pot := max
    ;}
    
    ControlGet, v, Visible, , %ftp_btn_min%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nMIN,10,17
      x := ""
      ControlSetText, Edit1,%pot%, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = pot)
        {
          ;MsgBox, %A_Index%
          break
        }
        else
        {
          sleep, 40
        }
      }
      
      ControlFocus, %ftp_btn_min%, ahk_id%id%
      ControlClick, %ftp_btn_min%, ahk_id%id%
      ;TrayTip, BetPot,`nWAITING MIN,10,17
      Sleep, -1
      Sleep, 40
      ;Msgbox, %min%
      min := ""
      Loop, 50
      {
        ControlGetText, min, Edit1, ahk_id%id%
        if (min != pot)
        {
          break
        }
        else
        {
          ControlFocus, %ftp_btn_min%, ahk_id%id%
          ControlClick, %ftp_btn_min%, ahk_id%id%
          sleep, 40
          ;TrayTip, BetPot,`nMIN %A_Index%,10,17
          
        }
      }
      ;TrayTip, BetPot,`n%min%,10,17
          
      ;ControlClick, FTCButton20, ahk_id%id%
      ;Sleep, -1
      ;ControlGetText, min, Edit1, ahk_id%id%
    }
    if (!min)
    {
      min := bb
    }
    ;TrayTip, BetPot,`nDONE,10,17
          
  
  }
  else  ; FTP OFFICIAL
  {
    /*
    ControlGet, v, Visible, , FTCButton20, ahk_id%id%
    if (v)
    {
      ControlClick, FTCButton20, ahk_id%id%
      Sleep, -1
      ControlGetText, max, Edit1, ahk_id%id%
    }
    else
    {
      ControlGet, v, Visible, , FTCButton24, ahk_id%id%
      if (v)
      {
        ControlClick, FTCButton24, ahk_id%id%
        Sleep, -1
        ControlGetText, max, Edit1, ahk_id%id%
      }
    }
  
  
    ControlClick, FTCButton21, ahk_id%id%
    Sleep, -1
    ControlGetText, pot, Edit1, ahk_id%id%
    
    ControlClick, FTCButton19, ahk_id%id%
    Sleep, -1
    ControlGetText, min, Edit1, ahk_id%id%
    */
  }
  
  ;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%
  ;StringReplace,title,title,€,$,1
  StringMid, hero, title, InStr(title, " - ")-1, , L
  StringTrimLeft, hero, hero, InStr(hero, " - ", true, 0)+2
  ;Msgbox %hero%
  
  ;ControlGetText, hh, RichEdit20W3, ahk_id%id%
  VarSetCapacity(hh, 2048)
  Loop, 10
  {
    ControlGetText, hh, RichEdit20W1, ahk_id%id%
    If hh
    {
      break
    }
    Sleep, 100
  }
  StringTrimLeft, hh, hh, InStr(hh, " wins  ", true, 0)
  
  ;added by Nysos to reinit the pokerclient chat log
  ControlSetText, RichEdit20W1, %hh%, ahk_id%id%


  StringReplace,hh,hh,€,$,1
  
  ;Msgbox, %hh%
  prev_bet := 0
  call := 0
  hero_bet := 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
      
      
      IfInString, a_loopfield, raised for  $
      {
        open := 0
        amount += prev_bet
        ;pot += prev_bet
      }
      pot += amount
      prev_bet := amount
      
      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(")
    street := "river"
    open := 0
  }
  Else If InStr(hh, "> Dealing the turn(")
  {
    StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Turn(")
    street := "turn"
    open := 0
  }
  Else If InStr(hh, "> Dealing the Flop(")
  {
    StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Flop(")
    street := "flop"
    open := 0
  }
  Else
  {
    hh2 := hh
  }
  call := 0
  hero_bet := 0
  prev_bet := 0
  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
      
      IfInString, a_loopfield, raised for  $
      {
        amount += prev_bet
      }
      notraked += amount
      
      prev_bet := 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
}


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, Static11, 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, Static11, 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
    }
  }
   
  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, Static6, 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
}

PotSizeIPoker(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global deduct_rake, IPokerX, IPokerY, IPokerChat, IPoker_BetBoxColor, IPoker_ShowBetBoxColor

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

  WinActivate, ahk_id %id%
  WinWaitActive, ahk_id %id%

  CoordMode, pixel, screen
  WinGetPos, x, y, , , ahk_id %id%
  X += iPokerX
  y += iPokerY

  PixelGetColor, col, x,  y

  if IPoker_ShowBetBoxColor
	Msgbox Ipoker bet box color: %col%

  if (col != iPoker_BetBoxColor)
    return

  nl_actions = calls $, raises $, bets $, All-In $, posts Small Blind $, posts Big Blind $
  
  StringMid, tablename, title, (InStr(title, ": ")+2), (InStr(title, " - ")-(InStr(title, ": ")+2))
  
  ;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 :=
  oldClipboard = %clipboard%
  clipboard =

  attempts := 0

  loop
  {
  	WinActivate, ahk_id %id%
  	WinWaitActive, ahk_id %id%

	Click, 75, %ipokerchat%
 	sleep, 150
	SendInput, ^a^c
	ClipWait, 0.5
	if !errorlevel or attempts > 3
		break
	attempts++
  }

  hh := clipboard
  ;msgbox %hh%
  clipboard = %oldClipBoard%

  if hh =
  {
    TrayTip, BetPot,`nError reading chat box on iPoker table: %tableName%, 10, 17
    return
  }

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

  Loop, Parse, hh, `n
  {
    If a_loopfield contains %nl_actions%
     {	
	StringTrimRight, amount, a_loopfield, 2
	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
        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, 2
	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
	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 (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
ReadBetBoxIPoker(id)
{
	global ipokerx, ipokery
	oldClipboard = %clipboard%
	clipboard =

	WinActivate, ahk_id %id%
	WinWaitActive, ahk_id %id%
   	Click, %ipokerx%, %ipokery%
	;Sleep 50
	Send {HOME}+{END}^c

	ClipWait, 0.3
	If !ErrorLevel
	    t := clipboard

        clipboard = %oldClipBoard%
	return t
}

;writes the bet amount into the bet box then moves the cursor to the raise button
WriteBetBoxIpoker(id, amount)
{
	global iPokerX, iPokerY, iPokerRaiseX, iPokerRaiseY
	
	WinActivate ahk_id %id%
	WinWaitActive ahk_id %id%
	Click, %iPokerX%, %iPokerY%
	;sleep 50
	Send {HOME}+{END}%amount%
	MouseMove, iPokerRaiseX, iPokerRaiseY
}

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, stars_editbox
  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)  

  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)
  
  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 )

  bb := GetBBStars(id, GameTypeStars(WinGetTitle(id)))
  sb := sb(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)
    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)
}

PostPrimaClick(x, y, id)
{
  relPrimaClientPoint(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 )
}

relPrimaClientPoint(id, ByRef x, ByRef y)
{
  global border
  global caption
  rw := 800
  rh := 600
  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  )
  
}

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(415,501,id)
}

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


FoldPrima(id)
{
  
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(91, 329, id)
  }
  else
  {
    ;PostPrimaClick(247,523,id)      ; <-- adv. fold
    PostPrimaClick(247,563,id)       ; <-- adv. check/fold
  }
}

CallPrima(id)
{
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(180, 329, id)
  }
  else
  {
    PostPrimaClick(398,493,id)
  }
}
RaisePrima(id)
{
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(251, 329, id)
  }
  else
  {
    PostPrimaClick(514,493,id)
  }
}


FoldIPoker(id)
{
  global iPokerFoldX, iPokerFoldY
  Click, %iPokerFoldx%, %iPokerFoldY%
}

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%
    }
  }
  */
}


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

/*

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}
      }   
    } 
  }
}
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 09:53 AM
bump I will pay for this as well.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 10:49 AM
Is Eurolinx Prima?

If so, this may be worth a try:

At the very bottom at the script (about line 3398), under "Else IfWinExist, ahk_id%id% ahk_group PrimaTables", replace

Code:
ControlSetText, Edit1, %pot%, ahk_id%id%
with

Code:
SendInput {raw}%pot%
or also try

Code:
ControlSendRaw, Edit1, %pot%, ahk_id%id%
Wild guess, but worth a shot.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 11:27 AM
Quote:
Originally Posted by Roland
Is Eurolinx Prima?

If so, this may be worth a try:

At the very bottom at the script (about line 3398), under "Else IfWinExist, ahk_id%id% ahk_group PrimaTables", replace

Code:
ControlSetText, Edit1, %pot%, ahk_id%id%
with

Code:
SendInput {raw}%pot%
or also try

Code:
ControlSendRaw, Edit1, %pot%, ahk_id%id%
Wild guess, but worth a shot.

Ty very much Roland.


One problem but its almost there!


Now i already can bet the value i chose with the betpot, but the previous value in the box isn't erased.

For example if i want to bet 3/4 pot on flop, 0.8c in the ss, but i change my mind and want to bet full pot, 0.12c, both values will appear.

Se the screeshot please, i can't explain my self better.

$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 11:33 AM
Uh, bizarre! Which one works for you, SendInput or ControlSendRaw?
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 11:56 AM
Quote:
Originally Posted by Roland
Uh, bizarre! Which one works for you, SendInput or ControlSendRaw?

ControlSendRaw
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 12:18 PM
Alright, once again wild guess, but try this: After "Send, {ENTER}" (right at the end), insert

Code:
ControlSetText, Edit1,, ahk_id%id%
or

Code:
ControlSendRaw, Edit1, %pot%, ahk_id%id%
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 12:36 PM
When i made the changes that you told me in the first post i did it here, because they didn't work on where you told me (im using miniview):

Code:
Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (prima_miniview)
    {
      ControlFocus, edit3, ahk_id%id%
      ControlSendRaw, Edit3, %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}
        }
      }
    }

If i put:

Code:
ControlSetText, Edit1,, ahk_id%id%
after the send nothing happens, i imagine thats because i don't have the autobet on.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 12:51 PM
Ah, ok, try this then: Put

Code:
ControlSendRaw, Edit3,, ahk_id%id%
before

Code:
ControlSendRaw, Edit3, %pot%, ahk_id%id%
(Idea is that it will clear the text field before entering the new value, so we don't get the strange duplicates).
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 12:56 PM
I tried both:

ControlSetText, Edit1,, ahk_id%id%

and

ControlSendRaw, Edit1, %pot%, ahk_id%id%

Neither worked any differently from the old version of the script. It will adjust the PF sizing correct for an initial open, but cannot calculate the pot for any other street or action. Also, as the OP mentioned the bet sizes will appear in the box, but when you click bet it simply bets the amount listed on the bet button. See OP for a screen shot.

Any other ideas?
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 12:58 PM
Quote:
Originally Posted by Kyle
I tried both:

ControlSetText, Edit1,, ahk_id%id%

and

ControlSendRaw, Edit1, %pot%, ahk_id%id%

Neither worked any differently from the old version of the script. It will adjust the PF sizing correct for an initial open, but cannot calculate the pot for any other street or action. Also, as the OP mentioned the bet sizes will appear in the box, but when you click bet it simply bets the amount listed on the bet button. See OP for a screen shot.

Any other ideas?
You have to change edit1 to edit3 (miniview)
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:00 PM
Quote:
Originally Posted by Hilips
You have to change edit1 to edit3 (miniview)
I do not use mini-view. Does this still apply?

I am obv ******ed about this stuff

Last edited by Kyle; 05-01-2009 at 01:07 PM.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:07 PM
Quote:
Originally Posted by Kyle
I do not use mini-view. Does this still apply?

Edit1 is the chat box in mini and normal view, i think you have to change that to edit5.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:16 PM
Quote:
Originally Posted by Roland
Ah, ok, try this then: Put

Code:
ControlSendRaw, Edit3,, ahk_id%id%
before

Code:
ControlSendRaw, Edit3, %pot%, ahk_id%id%
(Idea is that it will clear the text field before entering the new value, so we don't get the strange duplicates).

It doesn't work, ahk give an error when i put ",," and with only one it shows the right value but then insta changes to all in.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:22 PM
Alright I am frustrated with this since I am a computer noob. 50$ to whoever gets the script working on the new prima update and on normal view.

PM me if you get it working or post in this thread.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:31 PM
Its working!

Give me one second!


Just testing with normal view...

Last edited by Hilips; 05-01-2009 at 01:36 PM.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:35 PM
Quote:
Originally Posted by Roland
Ah, ok, try this then: Put

Code:
ControlSendRaw, Edit3,, ahk_id%id%
before

Code:
ControlSendRaw, Edit3, %pot%, ahk_id%id%
(Idea is that it will clear the text field before entering the new value, so we don't get the strange duplicates).
Worked with
Code:
ControlSetText, Edit3
instead of
Code:
ControlSendRaw, Edit3,, ahk_id%id%
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:43 PM
You have to change "prima_miniview := 1" to "0" to work with normal view.


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

; PRIMA SECIFIC
enable_prima_actions := 0
prima_miniview := 1

; IPOKER SPECIFIC
Ipoker_miniview := 0
Ipoker_BetBoxColor = 0xFFFFFF  ;most of the iPoker skins use a white background for the bet box, if yours doesn't 

then you need to change this value
Ipoker_ShowBetBoxColor := 0  ;set this to 1 to pop up a message box with the bet box color when you bet pot, replace 

0xFFFFFF with this.

; 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
;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, ub, pid, UltimateBet  
if (ub)
{
  GroupAdd, UBTables, ahk_pid%,,, 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:

;--------- IPOKER COORDINATES -------------------
iPokerX := 557 + border
iPokerY := 462 + caption

iPokerChat := 550
iPokerRaiseX := 554
iPokerRaiseY := 545
ipokerCallx := 445
ipokerCallY:= 550
iPokerFoldX := 300
iPokerFoldY := 550

if iPoker_miniview
{
  iPokerX := 400 + border
  iPokerY := 265 + caption

  iPokerChat := 300
  iPokerRaiseX := 400
  iPokerRaiseY := 325
  ipokerCallx := 310
  ipokerCallY:= 325
  iPokerFoldX := 220
  iPokerFoldY := 325
}

return

#include betpot_default_hotkeys.ahk

Fold(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      FoldPrima(id)
    }
  }
}
  
Call(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      CallPrima(id)
    }
  }
}

Raise(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      RaisePrima(id)
    }
  }
}

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

  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") <> 0 AND InStr(title, "Buy-in") = 0)
    {
      StringMid, bb, title, InStr(title, "/")+1, InStr(title, ". ", InStr(title,"/")) - InStr(title, "/") -1
      
    }
    else if (InStr(title, "NL") <> 0 AND InStr(title, "Buy-in") <> 0)
    {
      ControlGetText, text, Static6, 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
  {
    StringReplace,title,title,€,$,1
    StringTrimLeft, bb, title, InStr(title, "/", true, 0) 
    StringMid, bb, bb, InStr(bb, " ")-1,, L
    ;MsgBox, %bb%
    
  }
  
  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, Edit3, ahk_id%id%
    if (party_uses_commas_for_decimals)
    {
      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, Edit3, %t%, ahk_id%id%
    ;WinSet, Redraw,, ahk_id%id%
  }
  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
  {
    if (prima_miniview)
    {
      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
    {
      ControlGetText, t, Edit5, ahk_id%id%
      t := t + amount
      if (t < 0)
      {
        t := 0
      }
      t := Round(t, 2)
      ControlSetText, Edit5, %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)
  	t := t + amount
  
  	if (t <= 0)
      	  return
  
  	t := Round(t, 2)
  	
  	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 ipokerchat, iPokerRaiseX, iPokerRaiseY
  global stars_editbox, prima_miniview
  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, Edit3, %pot%, ahk_id%id%
    Sleep -1
    Sleep, 50
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      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
            
            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
  {
    if (prima_miniview)
    {
      ControlFocus, edit3, ahk_id%id%
      ControlSetText, Edit3
      ControlSendRaw, Edit3, %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
    {
      ControlFocus, Edit5, ahk_id%id%
      ControlSetText, Edit5
      ControlSendRaw, Edit5, %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
     {
	;try to write the bet five times
	attempts := 0

	loop
	{
        	if (readPot = pot OR attempts > 5)
		  break

		WriteBetBoxIpoker(id, pot)
		readPot := ReadBetBoxIpoker(id)
		attempts++
	}

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

	Click, 75, %ipokerchat%
	MouseMove, %ipokerraisex%, %ipokerraisey%
      }
   }
}


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
}



PotSizeFullTilt2_old(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
  
  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 (FTP_Beta)
  {    
    ControlGet, v, Visible, , %ftp_btn_max%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nMAX,10,17
      x := ""
      ControlSetText, Edit1,, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = "")
        {
          break
        }
        else
        {
          sleep, 40
        }
      }
      /*  ;NOT SURE WE NEED MAX ANYMORE
      ControlClick, %ftp_btn_max%, ahk_id%id%
      Loop, 50
      {
        ControlGetText, max, Edit1, ahk_id%id%
        if (max != "")
        {
          
          break
        }
        else
        {
          sleep, 40
        }
      }
      ;ControlGetText, max, Edit1, ahk_id%id%
      */
    }
    else if (InStr(title, "Cap No Limit") || InStr(title, "Pot Limit"))
    {
      ControlGet, v, Visible, , %ftp_btn_max_cap%, ahk_id%id%  ; CAP
      if (v)
      {
        ;TrayTip, BetPot,`nCAP MAX,10,17
        x := ""
        ControlSetText, Edit1,, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = "")
          {
            break
          }
          else
          {
            sleep, 40
          }
        }
        ControlClick, %ftp_btn_max_cap%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, max, Edit1, ahk_id%id%
          if (max != "")
          {
            ;if (max = "")
            ;{
            ;  continue
            ;}
            break
          }
          else
          {
            sleep, 40
          }
        }
        
      ;ControlClick, FTCButton24, ahk_id%id%
      ;  Sleep, -1
      ;  ControlGetText, max, Edit1, ahk_id%id%
      }
      else
      {
        ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
        if (v)
        {
          ;TrayTip, BetPot,`nPL MAX,10,17
          x := ""
          ControlSetText, Edit1,, ahk_id%id%
          Loop, 50
          {
            ControlGetText, x, Edit1, ahk_id%id%
            if (x = "")
            {
              break
            }
            else
            {
              sleep, 40
            }
          }
          ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
          Loop, 50
          {
            ControlGetText, max, Edit1, ahk_id%id%
            if (max != "")
            {
              ;if (max = "")
              ;{
              ;  continue
              ;}
              break
            }
            else
            {
              sleep, 40
            }
          }
        }
      }
    }
    /*
  
    ControlGet, v, Visible, , %ftp_btn_pot%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nPOT,10,17
      x := ""
      ControlSetText, Edit1,, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = "")
        {
          break
        }
        else
        {
          sleep, 40
        }
      }
      
      ControlClick, %ftp_btn_pot%, ahk_id%id%
      
      Loop, 50
      {
        ControlGetText, pot, Edit1, ahk_id%id%
        if (pot != "")
        {
          
          ;MsgBox, %A_Index%
          break
        }
        else
        {
          sleep, 40
        }
      }
      ;ControlClick, FTCButton22, ahk_id%id%
      ;Sleep, -1
      ;ControlGetText, pot, Edit1, ahk_id%id%
    }
    
    /*
    else if (InStr(title, "Pot Limit"))
    {
      ;TrayTip, BetPot,`nPL POT,10,17
      ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
      if (v)
      {
        x := ""
        ControlSetText, Edit1,, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = "")
          {
            break
          }
          else
          {
            sleep, 40
          }
        }
        ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, pot, Edit1, ahk_id%id%
          if (pot != "")
          {
            ;if (pot = "")
            ;{
            ;  continue
            ;}
            break
          }
          else
          {
            sleep, 40
          }
        }
      }
    }
    */
    
    ; AGAIN NOT SURE
    ;else
    ;{
    ;  pot := max
    ;}
    
    ControlGet, v, Visible, , %ftp_btn_min%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nMIN,10,17
      x := ""
      ControlSetText, Edit1,%pot%, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = pot)
        {
          ;MsgBox, %A_Index%
          break
        }
        else
        {
          sleep, 40
        }
      }
      
      ControlFocus, %ftp_btn_min%, ahk_id%id%
      ControlClick, %ftp_btn_min%, ahk_id%id%
      ;TrayTip, BetPot,`nWAITING MIN,10,17
      Sleep, -1
      Sleep, 40
      ;Msgbox, %min%
      min := ""
      Loop, 50
      {
        ControlGetText, min, Edit1, ahk_id%id%
        if (min != pot)
        {
          break
        }
        else
        {
          ControlFocus, %ftp_btn_min%, ahk_id%id%
          ControlClick, %ftp_btn_min%, ahk_id%id%
          sleep, 40
          ;TrayTip, BetPot,`nMIN %A_Index%,10,17
          
        }
      }
      ;TrayTip, BetPot,`n%min%,10,17
          
      ;ControlClick, FTCButton20, ahk_id%id%
      ;Sleep, -1
      ;ControlGetText, min, Edit1, ahk_id%id%
    }
    if (!min)
    {
      min := bb
    }
    ;TrayTip, BetPot,`nDONE,10,17
          
  
  }
  else  ; FTP OFFICIAL
  {
    /*
    ControlGet, v, Visible, , FTCButton20, ahk_id%id%
    if (v)
    {
      ControlClick, FTCButton20, ahk_id%id%
      Sleep, -1
      ControlGetText, max, Edit1, ahk_id%id%
    }
    else
    {
      ControlGet, v, Visible, , FTCButton24, ahk_id%id%
      if (v)
      {
        ControlClick, FTCButton24, ahk_id%id%
        Sleep, -1
        ControlGetText, max, Edit1, ahk_id%id%
      }
    }
  
  
    ControlClick, FTCButton21, ahk_id%id%
    Sleep, -1
    ControlGetText, pot, Edit1, ahk_id%id%
    
    ControlClick, FTCButton19, ahk_id%id%
    Sleep, -1
    ControlGetText, min, Edit1, ahk_id%id%
    */
  }
  
  ;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%
  ;StringReplace,title,title,€,$,1
  StringMid, hero, title, InStr(title, " -  ")-1, , L
  StringTrimLeft, hero, hero, InStr(hero, " - ", true, 0)+2
  ;Msgbox %hero%
  
  ;ControlGetText, hh, RichEdit20W1, ahk_id%id%
  VarSetCapacity(hh, 2048)
  Loop, 10
  {
    ControlGetText, hh, RichEdit20W1, ahk_id%id%
    If hh
    {
      break
    }
    Sleep, 100
  }
  StringTrimLeft, hh, hh, InStr(hh, " wins  ", true, 0)
  
  ;added by Nysos to reinit the pokerclient chat log
  ControlSetText, RichEdit20W1, %hh%, ahk_id%id%


  StringReplace,hh,hh,€,$,1
  
  ;Msgbox, %hh%
  prev_bet := 0
  call := 0
  hero_bet := 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
      
      
      IfInString, a_loopfield, raised for  $
      {
        open := 0
        amount += prev_bet
        ;pot += prev_bet
      }
      pot += amount
      prev_bet := amount
      
      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(")
    street := "river"
    open := 0
  }
  Else If InStr(hh, "> Dealing the Turn(")
  {
    StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Turn(")
    street := "turn"
    open := 0
  }
  Else If InStr(hh, "> Dealing the Flop(")
  {
    StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Flop(")
    street := "flop"
    open := 0
  }
  Else
  {
    hh2 := hh
  }
  call := 0
  hero_bet := 0
  prev_bet := 0
  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
      
      IfInString, a_loopfield, raised for  $
      {
        amount += prev_bet
      }
      notraked += amount
      
      prev_bet := 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
}


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, Static11, 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, Static11, 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
    }
  }
   
  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, Static6, 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
}

PotSizeIPoker(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, 

ByRef open)
{
  global deduct_rake, IPokerX, IPokerY, IPokerChat, IPoker_BetBoxColor, IPoker_ShowBetBoxColor

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

  WinActivate, ahk_id %id%
  WinWaitActive, ahk_id %id%

  CoordMode, pixel, screen
  WinGetPos, x, y, , , ahk_id %id%
  X += iPokerX
  y += iPokerY

  PixelGetColor, col, x,  y

  if IPoker_ShowBetBoxColor
	Msgbox Ipoker bet box color: %col%

  if (col != iPoker_BetBoxColor)
    return

  nl_actions = calls $, raises $, bets $, All-In $, posts Small Blind $, posts Big Blind $
  
  StringMid, tablename, title, (InStr(title, ": ")+2), (InStr(title, " - ")-(InStr(title, ": ")+2))
  
  ;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 :=
  oldClipboard = %clipboard%
  clipboard =

  attempts := 0

  loop
  {
  	WinActivate, ahk_id %id%
  	WinWaitActive, ahk_id %id%

	Click, 75, %ipokerchat%
 	sleep, 150
	SendInput, ^a^c
	ClipWait, 0.5
	if !errorlevel or attempts > 3
		break
	attempts++
  }

  hh := clipboard
  ;msgbox %hh%
  clipboard = %oldClipBoard%

  if hh =
  {
    TrayTip, BetPot,`nError reading chat box on iPoker table: %tableName%, 10, 17
    return
  }

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

  Loop, Parse, hh, `n
  {
    If a_loopfield contains %nl_actions%
     {	
	StringTrimRight, amount, a_loopfield, 2
	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
        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, 2
	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
	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 (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
ReadBetBoxIPoker(id)
{
	global ipokerx, ipokery
	oldClipboard = %clipboard%
	clipboard =

	WinActivate, ahk_id %id%
	WinWaitActive, ahk_id %id%
   	Click, %ipokerx%, %ipokery%
	;Sleep 50
	Send {HOME}+{END}^c

	ClipWait, 0.3
	If !ErrorLevel
	    t := clipboard

        clipboard = %oldClipBoard%
	return t
}

;writes the bet amount into the bet box then moves the cursor to the raise button
WriteBetBoxIpoker(id, amount)
{
	global iPokerX, iPokerY, iPokerRaiseX, iPokerRaiseY
	
	WinActivate ahk_id %id%
	WinWaitActive ahk_id %id%
	Click, %iPokerX%, %iPokerY%
	;sleep 50
	Send {HOME}+{END}%amount%
	MouseMove, iPokerRaiseX, iPokerRaiseY
}

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, stars_editbox
  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)  

  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)
  
  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 )

  bb := GetBBStars(id, GameTypeStars(WinGetTitle(id)))
  sb := sb(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)
    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)
}

PostPrimaClick(x, y, id)
{
  relPrimaClientPoint(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 )
}

relPrimaClientPoint(id, ByRef x, ByRef y)
{
  global border
  global caption
  rw := 800
  rh := 600
  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  )
  
}

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(415,501,id)
}

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


FoldPrima(id)
{
  
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(91, 329, id)
  }
  else
  {
    ;PostPrimaClick(247,523,id)      ; <-- adv. fold
    PostPrimaClick(247,563,id)       ; <-- adv. check/fold
  }
}

CallPrima(id)
{
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(180, 329, id)
  }
  else
  {
    PostPrimaClick(398,493,id)
  }
}
RaisePrima(id)
{
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(251, 329, id)
  }
  else
  {
    PostPrimaClick(514,493,id)
  }
}


FoldIPoker(id)
{
  global iPokerFoldX, iPokerFoldY
  Click, %iPokerFoldx%, %iPokerFoldY%
}

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%
    }
  }
  */
}


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

/*

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, Edit5, ahk_id%id%
    ControlSetText, Edit5
    ControlSendRaw, Edit5, %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}
      }   
    } 
  }
}
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:47 PM
Quote:
Originally Posted by Kyle
Ok I am confused. Standard

In order to get it working in normal view, I need to replace the following:

ControlSetText, Edit1, %pot%, ahk_id%id%

with

ControlSetText, Edit1

??

Just copy all the code i posted before your post.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:49 PM
Quote:
Originally Posted by Hilips
Just copy all the code i posted before your post.
I am getting an error at line 16.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:53 PM
Hilips, you've somehow got linebreaks in the code you posted... thus the error at line 16.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:55 PM
Quote:
Originally Posted by Kyle
I am getting an error at line 16.

Are using the code i just posted in post #18? It's working for me in mini and normal view.
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:57 PM
Quote:
Originally Posted by Roland
Hilips, you've somehow got linebreaks in the code you posted... thus the error at line 16.

Well, i have no ideia how i did that. I just copy paste the code.

How about now?

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

; PRIMA SECIFIC
enable_prima_actions := 0
prima_miniview := 1

; IPOKER SPECIFIC
Ipoker_miniview := 0
Ipoker_BetBoxColor = 0xFFFFFF  ;most of the iPoker skins use a white background for the bet box, if yours doesn't then you need to change this value
Ipoker_ShowBetBoxColor := 0  ;set this to 1 to pop up a message box with the bet box color when you bet pot, replace 0xFFFFFF with this.

; 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
;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, ub, pid, UltimateBet  
if (ub)
{
  GroupAdd, UBTables, ahk_pid%ub%,,, 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:

;--------- IPOKER COORDINATES -------------------
iPokerX := 557 + border
iPokerY := 462 + caption

iPokerChat := 550
iPokerRaiseX := 554
iPokerRaiseY := 545
ipokerCallx := 445
ipokerCallY:= 550
iPokerFoldX := 300
iPokerFoldY := 550

if iPoker_miniview
{
  iPokerX := 400 + border
  iPokerY := 265 + caption

  iPokerChat := 300
  iPokerRaiseX := 400
  iPokerRaiseY := 325
  ipokerCallx := 310
  ipokerCallY:= 325
  iPokerFoldX := 220
  iPokerFoldY := 325
}

return

#include betpot_default_hotkeys.ahk

Fold(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      FoldPrima(id)
    }
  }
}
  
Call(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      CallPrima(id)
    }
  }
}

Raise(id)
{
  global enable_prima_actions
  
  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)
  }
  Else IfWinExist, ahk_id%id% ahk_group PrimaTables
  {
    if (enable_prima_actions)
    {
      RaisePrima(id)
    }
  }
}

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

  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") <> 0 AND InStr(title, "Buy-in") = 0)
    {
      StringMid, bb, title, InStr(title, "/")+1, InStr(title, ". ", InStr(title,"/")) - InStr(title, "/") -1
      
    }
    else if (InStr(title, "NL") <> 0 AND InStr(title, "Buy-in") <> 0)
    {
      ControlGetText, text, Static6, 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
  {
    StringReplace,title,title,€,$,1
    StringTrimLeft, bb, title, InStr(title, "/", true, 0) 
    StringMid, bb, bb, InStr(bb, " ")-1,, L
    ;MsgBox, %bb%
    
  }
  
  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, Edit3, ahk_id%id%
    if (party_uses_commas_for_decimals)
    {
      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, Edit3, %t%, ahk_id%id%
    ;WinSet, Redraw,, ahk_id%id%
  }
  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
  {
    if (prima_miniview)
    {
      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
    {
      ControlGetText, t, Edit5, ahk_id%id%
      t := t + amount
      if (t < 0)
      {
        t := 0
      }
      t := Round(t, 2)
      ControlSetText, Edit5, %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)
  	t := t + amount
  
  	if (t <= 0)
      	  return
  
  	t := Round(t, 2)
  	
  	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 ipokerchat, iPokerRaiseX, iPokerRaiseY
  global stars_editbox, prima_miniview
  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, Edit3, %pot%, ahk_id%id%
    Sleep -1
    Sleep, 50
    WinSet, Redraw,, ahk_id%id%
    If(autobet)
    {
      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
            
            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
  {
    if (prima_miniview)
    {
      ControlFocus, edit3, ahk_id%id%
      ControlSetText, Edit3
      ControlSendRaw, Edit3, %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
    {
      ControlFocus, Edit5, ahk_id%id%
      ControlSetText, Edit5
      ControlSendRaw, Edit5, %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
     {
	;try to write the bet five times
	attempts := 0

	loop
	{
        	if (readPot = pot OR attempts > 5)
		  break

		WriteBetBoxIpoker(id, pot)
		readPot := ReadBetBoxIpoker(id)
		attempts++
	}

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

	Click, 75, %ipokerchat%
	MouseMove, %ipokerraisex%, %ipokerraisey%
      }
   }
}


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
}



PotSizeFullTilt2_old(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
  
  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 (FTP_Beta)
  {    
    ControlGet, v, Visible, , %ftp_btn_max%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nMAX,10,17
      x := ""
      ControlSetText, Edit1,, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = "")
        {
          break
        }
        else
        {
          sleep, 40
        }
      }
      /*  ;NOT SURE WE NEED MAX ANYMORE
      ControlClick, %ftp_btn_max%, ahk_id%id%
      Loop, 50
      {
        ControlGetText, max, Edit1, ahk_id%id%
        if (max != "")
        {
          
          break
        }
        else
        {
          sleep, 40
        }
      }
      ;ControlGetText, max, Edit1, ahk_id%id%
      */
    }
    else if (InStr(title, "Cap No Limit") || InStr(title, "Pot Limit"))
    {
      ControlGet, v, Visible, , %ftp_btn_max_cap%, ahk_id%id%  ; CAP
      if (v)
      {
        ;TrayTip, BetPot,`nCAP MAX,10,17
        x := ""
        ControlSetText, Edit1,, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = "")
          {
            break
          }
          else
          {
            sleep, 40
          }
        }
        ControlClick, %ftp_btn_max_cap%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, max, Edit1, ahk_id%id%
          if (max != "")
          {
            ;if (max = "")
            ;{
            ;  continue
            ;}
            break
          }
          else
          {
            sleep, 40
          }
        }
        
      ;ControlClick, FTCButton24, ahk_id%id%
      ;  Sleep, -1
      ;  ControlGetText, max, Edit1, ahk_id%id%
      }
      else
      {
        ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
        if (v)
        {
          ;TrayTip, BetPot,`nPL MAX,10,17
          x := ""
          ControlSetText, Edit1,, ahk_id%id%
          Loop, 50
          {
            ControlGetText, x, Edit1, ahk_id%id%
            if (x = "")
            {
              break
            }
            else
            {
              sleep, 40
            }
          }
          ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
          Loop, 50
          {
            ControlGetText, max, Edit1, ahk_id%id%
            if (max != "")
            {
              ;if (max = "")
              ;{
              ;  continue
              ;}
              break
            }
            else
            {
              sleep, 40
            }
          }
        }
      }
    }
    /*
  
    ControlGet, v, Visible, , %ftp_btn_pot%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nPOT,10,17
      x := ""
      ControlSetText, Edit1,, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = "")
        {
          break
        }
        else
        {
          sleep, 40
        }
      }
      
      ControlClick, %ftp_btn_pot%, ahk_id%id%
      
      Loop, 50
      {
        ControlGetText, pot, Edit1, ahk_id%id%
        if (pot != "")
        {
          
          ;MsgBox, %A_Index%
          break
        }
        else
        {
          sleep, 40
        }
      }
      ;ControlClick, FTCButton22, ahk_id%id%
      ;Sleep, -1
      ;ControlGetText, pot, Edit1, ahk_id%id%
    }
    
    /*
    else if (InStr(title, "Pot Limit"))
    {
      ;TrayTip, BetPot,`nPL POT,10,17
      ControlGet, v, Visible, , %ftp_btn_pot_pl%, ahk_id%id% 
      if (v)
      {
        x := ""
        ControlSetText, Edit1,, ahk_id%id%
        Loop, 50
        {
          ControlGetText, x, Edit1, ahk_id%id%
          if (x = "")
          {
            break
          }
          else
          {
            sleep, 40
          }
        }
        ControlClick, %ftp_btn_pot_pl%, ahk_id%id%
        Loop, 50
        {
          ControlGetText, pot, Edit1, ahk_id%id%
          if (pot != "")
          {
            ;if (pot = "")
            ;{
            ;  continue
            ;}
            break
          }
          else
          {
            sleep, 40
          }
        }
      }
    }
    */
    
    ; AGAIN NOT SURE
    ;else
    ;{
    ;  pot := max
    ;}
    
    ControlGet, v, Visible, , %ftp_btn_min%, ahk_id%id%
    if (v)
    {
      ;TrayTip, BetPot,`nMIN,10,17
      x := ""
      ControlSetText, Edit1,%pot%, ahk_id%id%
      Loop, 50
      {
        ControlGetText, x, Edit1, ahk_id%id%
        if (x = pot)
        {
          ;MsgBox, %A_Index%
          break
        }
        else
        {
          sleep, 40
        }
      }
      
      ControlFocus, %ftp_btn_min%, ahk_id%id%
      ControlClick, %ftp_btn_min%, ahk_id%id%
      ;TrayTip, BetPot,`nWAITING MIN,10,17
      Sleep, -1
      Sleep, 40
      ;Msgbox, %min%
      min := ""
      Loop, 50
      {
        ControlGetText, min, Edit1, ahk_id%id%
        if (min != pot)
        {
          break
        }
        else
        {
          ControlFocus, %ftp_btn_min%, ahk_id%id%
          ControlClick, %ftp_btn_min%, ahk_id%id%
          sleep, 40
          ;TrayTip, BetPot,`nMIN %A_Index%,10,17
          
        }
      }
      ;TrayTip, BetPot,`n%min%,10,17
          
      ;ControlClick, FTCButton20, ahk_id%id%
      ;Sleep, -1
      ;ControlGetText, min, Edit1, ahk_id%id%
    }
    if (!min)
    {
      min := bb
    }
    ;TrayTip, BetPot,`nDONE,10,17
          
  
  }
  else  ; FTP OFFICIAL
  {
    /*
    ControlGet, v, Visible, , FTCButton20, ahk_id%id%
    if (v)
    {
      ControlClick, FTCButton20, ahk_id%id%
      Sleep, -1
      ControlGetText, max, Edit1, ahk_id%id%
    }
    else
    {
      ControlGet, v, Visible, , FTCButton24, ahk_id%id%
      if (v)
      {
        ControlClick, FTCButton24, ahk_id%id%
        Sleep, -1
        ControlGetText, max, Edit1, ahk_id%id%
      }
    }
  
  
    ControlClick, FTCButton21, ahk_id%id%
    Sleep, -1
    ControlGetText, pot, Edit1, ahk_id%id%
    
    ControlClick, FTCButton19, ahk_id%id%
    Sleep, -1
    ControlGetText, min, Edit1, ahk_id%id%
    */
  }
  
  ;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%
  ;StringReplace,title,title,€,$,1
  StringMid, hero, title, InStr(title, " -  ")-1, , L
  StringTrimLeft, hero, hero, InStr(hero, " - ", true, 0)+2
  ;Msgbox %hero%
  
  ;ControlGetText, hh, RichEdit20W1, ahk_id%id%
  VarSetCapacity(hh, 2048)
  Loop, 10
  {
    ControlGetText, hh, RichEdit20W1, ahk_id%id%
    If hh
    {
      break
    }
    Sleep, 100
  }
  StringTrimLeft, hh, hh, InStr(hh, " wins  ", true, 0)
  
  ;added by Nysos to reinit the pokerclient chat log
  ControlSetText, RichEdit20W1, %hh%, ahk_id%id%


  StringReplace,hh,hh,€,$,1
  
  ;Msgbox, %hh%
  prev_bet := 0
  call := 0
  hero_bet := 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
      
      
      IfInString, a_loopfield, raised for  $
      {
        open := 0
        amount += prev_bet
        ;pot += prev_bet
      }
      pot += amount
      prev_bet := amount
      
      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(")
    street := "river"
    open := 0
  }
  Else If InStr(hh, "> Dealing the Turn(")
  {
    StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Turn(")
    street := "turn"
    open := 0
  }
  Else If InStr(hh, "> Dealing the Flop(")
  {
    StringTrimLeft, hh2, hh, InStr(hh, "> Dealing the Flop(")
    street := "flop"
    open := 0
  }
  Else
  {
    hh2 := hh
  }
  call := 0
  hero_bet := 0
  prev_bet := 0
  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
      
      IfInString, a_loopfield, raised for  $
      {
        amount += prev_bet
      }
      notraked += amount
      
      prev_bet := 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
}


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, Static11, 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, Static11, 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
    }
  }
   
  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, Static6, 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
}

PotSizeIPoker(id, ByRef pot, ByRef call, ByRef sb, ByRef bb, ByRef hero_bet, ByRef street, ByRef hero_position, ByRef open)
{
  global deduct_rake, IPokerX, IPokerY, IPokerChat, IPoker_BetBoxColor, IPoker_ShowBetBoxColor

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

  WinActivate, ahk_id %id%
  WinWaitActive, ahk_id %id%

  CoordMode, pixel, screen
  WinGetPos, x, y, , , ahk_id %id%
  X += iPokerX
  y += iPokerY

  PixelGetColor, col, x,  y

  if IPoker_ShowBetBoxColor
	Msgbox Ipoker bet box color: %col%

  if (col != iPoker_BetBoxColor)
    return

  nl_actions = calls $, raises $, bets $, All-In $, posts Small Blind $, posts Big Blind $
  
  StringMid, tablename, title, (InStr(title, ": ")+2), (InStr(title, " - ")-(InStr(title, ": ")+2))
  
  ;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 :=
  oldClipboard = %clipboard%
  clipboard =

  attempts := 0

  loop
  {
  	WinActivate, ahk_id %id%
  	WinWaitActive, ahk_id %id%

	Click, 75, %ipokerchat%
 	sleep, 150
	SendInput, ^a^c
	ClipWait, 0.5
	if !errorlevel or attempts > 3
		break
	attempts++
  }

  hh := clipboard
  ;msgbox %hh%
  clipboard = %oldClipBoard%

  if hh =
  {
    TrayTip, BetPot,`nError reading chat box on iPoker table: %tableName%, 10, 17
    return
  }

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

  Loop, Parse, hh, `n
  {
    If a_loopfield contains %nl_actions%
     {	
	StringTrimRight, amount, a_loopfield, 2
	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
        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, 2
	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
	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 (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
ReadBetBoxIPoker(id)
{
	global ipokerx, ipokery
	oldClipboard = %clipboard%
	clipboard =

	WinActivate, ahk_id %id%
	WinWaitActive, ahk_id %id%
   	Click, %ipokerx%, %ipokery%
	;Sleep 50
	Send {HOME}+{END}^c

	ClipWait, 0.3
	If !ErrorLevel
	    t := clipboard

        clipboard = %oldClipBoard%
	return t
}

;writes the bet amount into the bet box then moves the cursor to the raise button
WriteBetBoxIpoker(id, amount)
{
	global iPokerX, iPokerY, iPokerRaiseX, iPokerRaiseY
	
	WinActivate ahk_id %id%
	WinWaitActive ahk_id %id%
	Click, %iPokerX%, %iPokerY%
	;sleep 50
	Send {HOME}+{END}%amount%
	MouseMove, iPokerRaiseX, iPokerRaiseY
}

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, stars_editbox
  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)  

  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)
  
  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 )

  bb := GetBBStars(id, GameTypeStars(WinGetTitle(id)))
  sb := sb(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)
    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)
}

PostPrimaClick(x, y, id)
{
  relPrimaClientPoint(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 )
}

relPrimaClientPoint(id, ByRef x, ByRef y)
{
  global border
  global caption
  rw := 800
  rh := 600
  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  )
  
}

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(415,501,id)
}

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


FoldPrima(id)
{
  
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(91, 329, id)
  }
  else
  {
    ;PostPrimaClick(247,523,id)      ; <-- adv. fold
    PostPrimaClick(247,563,id)       ; <-- adv. check/fold
  }
}

CallPrima(id)
{
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(180, 329, id)
  }
  else
  {
    PostPrimaClick(398,493,id)
  }
}
RaisePrima(id)
{
  global prima_miniview
  if (prima_miniview)
  {
     PostLeftClick(251, 329, id)
  }
  else
  {
    PostPrimaClick(514,493,id)
  }
}


FoldIPoker(id)
{
  global iPokerFoldX, iPokerFoldY
  Click, %iPokerFoldx%, %iPokerFoldY%
}

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%
    }
  }
  */
}


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

/*

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, Edit5, ahk_id%id%
    ControlSetText, Edit5
    ControlSendRaw, Edit5, %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}
      }   
    } 
  }
}
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 01:57 PM
Quote:
Originally Posted by Hilips
Are using the code i just posted in post #18? It's working for me in mini and normal view.
Yes when I cut and paste and hit run I get the error message. Am I doing something wrong here?
$$$Eurolinx betpot not working anymore - $reward$ Quote
05-01-2009 , 02:03 PM
BOOM!

It is working now. PM me your SN and what site you want $50 and I will happily send it your way.

Thanks a ton.
$$$Eurolinx betpot not working anymore - $reward$ Quote

      
m