By Adde @ 2+2 forums (HstreamPoker at gmail dot com). The corresponding thread on 2+2 is here.
Poker Seat Taker
Get seated and bought in at one or more poker tables automatically.
By default there are three hotkeys that will join and get you seated at 1, 5 or 10 tables, but you can change this to your own preferences. For instance, you can assign the F1 to F10 keys to join 1-10 tables.
It is based on the former Party Seat Taker code, but since it might be future additions that work for other sites as well, I renamed it to a more generic name. The code is also rewritten to work better than before.
Currently this only works for Partypoker, but anyone: feel free to add support for other sites too.
This script has Scriptpad support. Scriptpad is a tool where you can connect any number of scripts to a Scriptpad, a small pop-up window with buttons for all available commands in these scripts. You access the Scriptpad by clicking a hotkey, for instance the middle mouse button.
How To Use This Script
Read instructions for AutoHotkey, and make sure you have the latest version installed.
Read all instructions on this page.
Save the script code below in a file named "PokerSeatTaker.ahk"
Open script file in a text editor and edit settings.
Run the script (double-click the file).
Default settings will join 1, 5 and 10 tables when you press F1, F2 and F3 on your keyboard.
A green AHK icon will show in the system tray as long as the script is running. Right-click this icon and choose "Exit" to exit the script. If the script seems to have gone wild, choose "Reload this script".
How To Join Only 6-Max Tables?
By default PST will join waitlists for ANY table (with min players N). Even though you set the Seats setting to 6, this will make you join full tables because of Partypoker not offering full or short table options in their waitlist feature.
The solution is to configure PST to join each FULL table in the lobby list that has got the preferred number of seats. To join only 6-max tables you should configure PST settings like this:
pst_method_is_any_table = 0 pst_seats = 6
With this method, PST will join every full table in the lobby, starting with the one selected right now, and stepping down until end of table list is reached.
For better result, filter the table list to only include 6-max tables, sort by name, select the first table and then click the hotkey for joining tables.
Since Partypoker lobby can be slow to update, many of the tables that is shown to be full actually is not when you open the waitlist dialog. In this case you can choose to open the table and try to take the empty seat. If tables are sorted by name you might end up alone on a table. If you instead sort tables by Players/Seats, this should be less of a problem. You need to configure settings like this:
pst_join_nonfull = 1
The Stop Hotkey
If you want to cancel the table joining at any time, click the Stop hotkey. This is especially useful when using the FULL method (see above). In that case, you might have joined waitlists for 30 full tables, and after max tables are joined, the script will automatically unjoin every seat dialog that pops up.
Troubleshooting
Partypoker software can at times be less reliable, which might affect this script.
If a dialog seems to get stuck, try to click it manually and see if the script continues as it should. If not, close all open dialogs and restart the script from the system tray.
When taking a seat and sitting out (clicking Deal Me Out checkbox), the Partypoker client can be slow to update the sitout status to their servers. In these cases a Sit Out button may still pop-up. Either click it yourself, or let the short timer run out.
Script Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Code begins here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;------------------------------------------------------------------------------------------------
; Poker Seat Taker v0.20
;------------------------------------------------------------------------------------------------
; Date: 2006-09-15
; AHK version: 1.0.44.09
;------------------------------------------------------------------------------------------------
; Author(s): Adde @ 2+2 forums
; Contact: HstreamPoker at gmail dot com
;------------------------------------------------------------------------------------------------
; Get seated and bought in at one or more poker tables automatically.
; See web page for more details.
;
; http://overcards.com/wiki/moin.cgi/PokerSeatTaker
;
; All rights reserved. Use at your own risk.
;------------------------------------------------------------------------------------------------
;________________________________________________________________________________________________
;
; EDIT THESE SETTINGS
;________________________________________________________________________________________________
; Set what hotkeys should join tables.
; Leave empty (=) if you don't want to use a hotkey for a specific function.
; List of available hotkeys: http://www.autohotkey.com/docs/KeyList.htm
pst_hotkey_join_min = F1
pst_hotkey_join_mid = F2
pst_hotkey_join_max = F3
; Set what hotkey should stop the script.
pst_hotkey_stop = F4
; Set if ANY table (with min players) should be joined (1) or not (0).
; If not, all full tables in current table list in lobby will be joined.
; Use this method to join only 6-max tables.
pst_method_is_any_table = 0
; Set how many tables should be joined for min/mid/max.
pst_min_tables = 1
pst_mid_tables = 6
pst_max_tables = 12
; THESE SETTINGS ONLY AFFECT JOINING "ANY" TABLE (NOT "FULL")
; Set what game type to join. MUST be exactly as shown in Partypoker lobby!
; Set blinds for level to join. MUST be exactly as shown in lobby table list.
; Set min players for tables to join.
pst_game_type = Limit Hold'em
pst_game_blinds = $5/$10
pst_min_players = 7
; Set num of seats for table to join. Should be 10 (full), 6 (short) or 2 (headsup).
pst_seats = 6
; Set how much, in percent, of default amount (as shown in Buy-in dialog) you should byuin for.
; If percentage buyin doesn't work, you can set an absoulte amount to buyin with instead.
; pst_buyin_amount is is used if greater than 0, otherwise percentage buyin will be used.
pst_buyin_percent = 100
pst_buyin_amount =
; Set if you should sitout (1) or not (0) when you join a new table.
pst_sitout = 1
; Set position where new tables should be moved to. Leave blank for no move.
; To position each new table at a different position, use setting (pst_dynamic_position) below.
pst_abs_position_x = 2395
pst_abs_position_y = 0
; Set if each new table should be positioned at a new location.
; Default setting below will position tables evenly across two monitors.
; NOTE: If you join 5 tables, they will be positioned according to the setting below, but if
; you later choose to join 5 new tables, the positioning will start over from the first
; coordinate given in this setting.
; pst_dynamic_position = 0.0/0.575/795.0/795.575/1600.0/1600.575/2395.0/2395.575/397.288/1997.288
; Set if tables should be joined from the current table list in lobby (1) or not (0).
; If not, script will navigate to tables according to game type and blinds settings.
; If script fails to navigate to chosen game type, set this to (1) and navigate
; to game type yourself before starting to join tables.
pst_current_table_list = 1
; Set how many full table waitlists that should be joined.
; This setting only tells how many waitlists should be joined for full tables, and not how
; many actual tables that will be joined.
pst_max_waitlists = 999
; Set if nonfull tables should be joined (1) or not (0) when joining waitlists for full tables.
pst_join_nonfull = 1
; This should be the name of Party's Join Waitlist button in the lobby, as shown by using AHK Window Spy.
; For some reason, Party software can change this name between logins. If you experience problems,
; try setting this name to any of these, or even better, use the Spy utility and find it out:
; "AfxWnd4217"
; "AfxWnd4218"
; "AfxWnd4219"
pst_join_button_name := "AfxWnd4218"
;________________________________________________________________________________________________
;
; DO NOT EDIT BELOW HERE
;________________________________________________________________________________________________
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; auto-execute ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#NoEnv
#SingleInstance Ignore
#Persistent
pst_scriptpad_command_header = Seat Taker|Seat Taker|Seat Taker|Seat Taker
pst_scriptpad_command_name = Join Min Tables|Join Mid Tables|Join Max Tables|Stop
pst_scriptpad_command_label = PST_JoinMin_Label|PST_JoinMid_Label|PST_JoinMax_Label|PST_Stop_Label
pst_scriptpad_command_enabled = 1|1|1|1
ahk_version = 1.0.44.01
if A_AhkVersion < %ahk_version%
{
msgbox, 4, , This script needs AutoHotkey version %ahk_version% or newer (you are using version %A_AhkVersion%). Script will exit`n`nGo to web page and download new version now?
IfMsgBox, Yes
Run, http://www.autohotkey.com
ExitApp
}
pst_is_running = false
pst_do_stop = false
pst_tables_to_join = 0
PST_InitData()
Hotkey, %pst_hotkey_join_min%, PST_JoinMin_Label, UseErrorLevel
Hotkey, %pst_hotkey_join_mid%, PST_JoinMid_Label, UseErrorLevel
Hotkey, %pst_hotkey_join_max%, PST_JoinMax_Label, UseErrorLevel
Hotkey, %pst_hotkey_stop%, PST_Stop_Label, UseErrorLevel
goto PST_Scriptpad_End
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; labels ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PST_JoinMin_Label:
pst_tables_to_join := pst_min_tables
if (pst_method_is_any_table)
SetTimer, PST_JoinAnyTableThread_Label, 1
else
SetTimer, PST_JoinFullTableThread_Label, 1
return
PST_JoinMid_Label:
pst_tables_to_join := pst_mid_tables
if (pst_method_is_any_table)
SetTimer, PST_JoinAnyTableThread_Label, 1
else
SetTimer, PST_JoinFullTableThread_Label, 1
return
PST_JoinMax_Label:
pst_tables_to_join := pst_max_tables
if (pst_method_is_any_table)
SetTimer, PST_JoinAnyTableThread_Label, 1
else
SetTimer, PST_JoinFullTableThread_Label, 1
return
PST_Stop_Label:
pst_do_stop := 1
pst_scriptpad_command_enabled = 1|1|1|1
SoundBeep, , 50
return
PST_JoinAnyTableThread_Label:
SetTimer, PST_JoinAnyTableThread_Label, Off
PST_JoinAnyTableThread()
SoundBeep, , 50
return
PST_JoinFullTableThread_Label:
SetTimer, PST_JoinFullTableThread_Label, Off
PST_JoinFullTableThread()
SoundBeep, , 50
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PST_InitData()
{
global
local idx, thisItem
StringSplit, pst_dynamic_position, pst_dynamic_position, /
Loop, %pst_dynamic_position0%
{
idx := a_index
thisItem := pst_dynamic_position%idx%
StringSplit, thisItem, thisItem, .
pst_dynamic_position_x%idx% := thisItem1
pst_dynamic_position_y%idx% := thisItem2
}
}
PST_JoinOneTable(gameType, gameBlinds, seats, minPlayers, buyinPercent, sitout, x="", y="")
{
global pst_do_stop, pst_error_tables, pst_buyin_amount
global pst_join_button_name
if (gameType <> "")
{
result := Lib_PST_Partypoker_NavigateToGame(gameType, gameBlinds, seats)
if (result = false)
return (-1)
}
result := Lib_PST_Partypoker_ClickJoinWaitlistButton()
if (result = false)
return (-1)
winID := Lib_PST_WinGetID(1,"Join Wait List", "First Available", "#32770", "")
if (winID = "")
return (-1)
if (minPlayers > 0)
{
Lib_PST_ClickButton(winID, 3, "Button2")
ControlGet, nlist , List , Count, ComboBox1 , ahk_id %winID%
Loop, Parse, nlist, `n
maxPlayers = %A_LoopField%
if (maxPlayers < minPlayers)
minPlayers := maxPlayers
Control, Choose , %minPlayers% , ComboBox1 , ahk_id %winID%
Sleep , 100
}
Lib_PST_ClickButton(winID, 3, "Button3")
Loop
{
seatID := Lib_PST_WinGetID(1,"Seat Available", "A seat has been reserved for you on", "#32770", 1)
if (seatID <> "" or pst_do_stop)
break
sleep, 200
}
if (pst_do_stop)
return (0)
tableID := Lib_PST_Partypoker_JoinFirstAvailableSeat(tableName, pst_error_tables)
if Lib_PST_Partypoker_CheckMaxTablesDialog(true)
{
sleep, 1000
Lib_PST_Partypoker_CloseAllSeats()
return (2)
}
if (tableID = "")
return (0)
Lib_PST_WinMoveID(tableID, x, y)
result := Lib_PST_Partypoker_TakeFirstAvailableSeat(tableID)
if (result = false)
{
pst_error_tables = %pst_error_tables% xxx%tableName%xxx
return (0)
}
result := Lib_PST_Partypoker_ClickRebuy("", false, true, buyinPercent, 5, pst_buyin_amount)
if (result = false)
return (0)
if (sitout = 1)
{
result := Lib_PST_ClickCheckbox(tableID, 3, "Button5", true)
sleep, 100
result := Lib_PST_ClickButton(tableID, 3, pst_join_button_name, false)
}
Lib_PST_Partypoker_CloseAllSeats()
if Lib_PST_Partypoker_CheckMaxTablesDialog(true)
return (2)
return (1)
}
PST_JoinAnyTableThread()
{
global
local label, done, gameTypeTemp, idx, x2, y2, x, y, n, tries
winID := Lib_PST_Partypoker_GetLobbyWinID(1)
if (WinID = "")
{
MsgBox Partypoker lobby can not be found. No tables will be joined.
return
}
pst_is_running := true
pst_scriptpad_command_enabled = 0|0|0|1
pst_do_unjoin := false
pst_do_stop := false
pst_tables_joined := 0
pst_error_tables := ""
label = WG_DisableJoinTables
if IsLabel(label)
Gosub %label%
done := 0
tries := 0
Loop
{
if (pst_do_stop)
break
if (tries > 0 or pst_current_table_list)
gameTypeTemp := ""
else
gameTypeTemp := pst_game_type
idx := done+1
if (idx > 0)
{
x := pst_dynamic_position_x%idx%
y := pst_dynamic_position_y%idx%
}
if (x = "")
{
x := pst_abs_position_x
y := pst_abs_position_y
}
n := PST_JoinOneTable(gameTypeTemp, pst_game_blinds, pst_seats, pst_min_players, pst_buyin_percent, pst_sitout, x, y)
if (n > 1)
{
Lib_PST_Partypoker_CloseAllSeats()
sleep, 3000
Lib_PST_Partypoker_CloseAllSeats()
break
}
done := done + n
if (done >= pst_tables_to_join)
break
tries++
}
label = WG_EnableJoinTables
if IsLabel(label)
Gosub %label%
pst_is_running := false
pst_scriptpad_command_enabled = 1|1|1|1
}
PST_StepDownOneTable(winID)
{
WinActivate, ahk_id %winID%
ControlFocus, SysListView321, ahk_id %winID%
ControlGet, result1, List, Count, SysListView321, ahk_id %winID%
ControlGet, result2, List, Count Focused, SysListView321, ahk_id %winID%
if (result1 = result2)
return (false)
Send {DOWN}
return (true)
}
PST_UnjoinFullSeats()
{
Loop
{
WinGet, winID, IDLast, Seat Available ahk_class #32770, A seat has been reserved for you on
if (winID = "")
break
Lib_PST_ClickButton(winID, 1, "Button2")
sleep, 100
}
return (0)
}
PST_TakeFullSeatPoll()
{
global pst_tables_joined, pst_tables_to_join
n := 1
Loop
{
sleep, 100
if (n < 1)
break
n := PST_TakeFullSeat()
if (n = -2)
return (-1)
if (n = 1)
pst_tables_joined++
if (pst_tables_joined >= pst_tables_to_join)
return (-1)
}
return (0)
}
PST_TakeFullSeat(tablename="")
{
global
local tableID, result, x, y, idx
if (tablename = "")
tableID := Lib_PST_Partypoker_JoinFirstAvailableSeat(tableName, pst_error_tables)
else
tableID := Lib_PST_WinGetID(2, tablename, "", "", 4)
if Lib_PST_Partypoker_CheckMaxTablesDialog(true)
return (-2)
if (tableID = "")
return (-1)
sleep, 200
idx := pst_tables_joined + 1
if (idx > 0)
{
x := pst_dynamic_position_x%idx%
y := pst_dynamic_position_y%idx%
}
if (x = "")
{
x := pst_abs_position_x
y := pst_abs_position_y
}
Lib_PST_WinMoveID(tableID, x, y)
result := Lib_PST_Partypoker_TakeFirstAvailableSeat(tableID)
if (result = false)
{
pst_error_tables = %pst_error_tables% xxx%tableName%xxx
return (0)
}
sleep, 100
result := Lib_PST_Partypoker_ClickRebuy("", false, true, pst_buyin_percent, 5, pst_buyin_amount)
if (result = false)
return (0)
sleep, 100
if (pst_sitout = 1)
{
result := Lib_PST_ClickCheckbox(tableID, 3, "Button5", true)
sleep, 100
result := Lib_PST_ClickButton(tableID, 3, pst_join_button_name, false)
}
return (1)
}
PST_JoinOneFullTable(winID)
{
global pst_last_table, pst_join_nonfull
global pst_tables_joined, pst_tables_to_join, pst_do_unjoin
global pst_join_button_name
Lib_PST_Partypoker_ClickJoinWaitlistButton(1, false)
id := Lib_PST_WinGetID(1,"Join Wait List", "First Available", "#32770", 0)
ControlGetText, tableName, Button1, Join Wait List ahk_class #32770, First Available
/*
if (tableName = "")
{
if (pst_join_button_name = "xxxxxx")
pst_join_button_name := "xxxxxx"
else
pst_join_button_name := "xxxxxx"
Lib_PST_Partypoker_ClickJoinWaitlistButton(1, false)
id := Lib_PST_WinGetID(1,"Join Wait List", "First Available", "#32770", 0)
ControlGetText, tableName, Button1, Join Wait List ahk_class #32770, First Available
}
*/
if (tableName = "")
{
msgbox Table name can't be found in dialog. Restart script and try again.
Lib_PST_ClickButton(id, 1, "Button4")
return (-1)
}
pst_last_table := str
ControlGet, result, Enabled, , Button1, Join Wait List ahk_class #32770, First Available
if (result <> 1)
{
Lib_PST_ClickButton(id, 1, "Button4")
if (pst_join_nonfull = false)
return (0)
sleep, 200
Lib_PST_ClickButton(winID, 1, "AfxWnd4214")
sleep, 200
n := PST_TakeFullSeat(tablename)
if (n = -2)
pst_do_unjoin := true
if (n = 1)
pst_tables_joined++
if (pst_tables_joined >= pst_tables_to_join)
pst_do_unjoin := true
if (n = 1)
return (1)
else
return (0)
}
else
Lib_PST_ClickButton(id, 1, "Button3")
return (1)
}
PST_JoinFullTableThread()
{
global pst_do_unjoin, pst_do_stop, pst_seats, pst_max_waitlists, pst_tables_joined, pst_tables_to_join
winID := Lib_PST_Partypoker_GetLobbyWinID(1)
if (WinID = "")
{
MsgBox Partypoker lobby can not be found. No tables will be joined.
return
}
pst_is_running := true
pst_scriptpad_command_enabled = 0|0|0|1
pst_do_unjoin := false
pst_do_stop := false
pst_tables_joined := 0
pst_error_tables := ""
label = WG_DisableJoinTables
if IsLabel(label)
Gosub %label%
ControlFocus , SysListView321 , ahk_id %winID%
waitlistsJoined := 0
seatsToken1 = /%pst_seats%
Loop
{
if (pst_do_stop)
break
ControlGet, row, List, Selected, SysListView321, ahk_id %winID%
IfNotInString, row, %seatsToken1%
{
if not PST_StepDownOneTable(winID)
break
continue
}
result := PST_JoinOneFullTable(winID)
if (pst_do_unjoin)
break
waitlistsJoined := waitlistsJoined + result
if (waitlistsJoined >= pst_max_waitlists)
break
if not PST_StepDownOneTable(winID)
break
n := PST_TakeFullSeatPoll()
if (n < 0)
{
pst_do_unjoin := 1
break
}
}
Loop
{
if (pst_do_stop)
break
if (pst_do_unjoin)
n := PST_UnjoinFullSeats()
else
{
n := PST_TakeFullSeatPoll()
if (n < 0)
pst_do_unjoin := 1
}
Sleep, 500
}
label = WG_EnableJoinTables
if IsLabel(label)
Gosub %label%
pst_is_running := false
pst_scriptpad_command_enabled = 1|1|1|1
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; library (partypoker) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Lib_PST_Partypoker_Open(path, login=true, x="", y="", timeoutSeconds=20, silentMode=false)
{
Process, Exist, PartyGaming.exe
if (ErrorLevel <> 0)
return (true)
IfNotExist, %path%
return (false)
Run, %path% -P=PartyPoker
winID := Lib_PST_Partypoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
{
if (silentMode = false)
msgbox "Can't open connection to PartyPoker."
return (false)
}
if (x <> "" and y <> "")
Lib_PST_WinMoveID(winID, x, y, "", "", 5)
winLoginID := Lib_PST_WinGetID(1, "PartyAccount Login", "", "#32770", timeoutSeconds)
if (winLoginID = "")
{
if (silentMode = false)
msgbox "Can't find PartyPoker login window."
return (false)
}
result := Lib_PST_WinCloseID(winLoginID)
if (login = true)
{
WinActivate, ahk_id %winID%
Lib_PST_ClickButton(winID, 1, "Button3")
}
return (true)
}
Lib_PST_Partypoker_Close()
{
Process, Close, PartyGaming.exe
return (true)
}
Lib_PST_Partypoker_ShowLobby()
{
winID := Lib_PST_Partypoker_GetLobbyWinID()
if (winID = "")
return (false)
WinActivate, ahk_id %winID%
return (true)
}
Lib_PST_Partypoker_HideLobby()
{
winID := Lib_PST_Partypoker_GetLobbyWinID()
if (winID = "")
return (false)
WinMinimize, ahk_id %winID%
return (true)
}
Lib_PST_Partypoker_GetLobbyWinID(timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(1, "PartyPoker.com: Poker Lobby", "", "#32770", timeoutSeconds)
return (winID)
}
Lib_PST_Partypoker_ToggleBuddyList(hideLobby=true, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(3, "Buddy List", "", "#32770")
if (winID = "")
result := Lib_PST_Partypoker_OpenBuddyList(timeoutSeconds, x, y, timeoutSeconds)
else
result := Lib_PST_Partypoker_CloseBuddyList(hideLobby, timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_OpenBuddyList(hideLobby=true, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_Partypoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
return (false)
WinActivate, ahk_id %winID%
PostMessage, 0x111, 3084, 0, , ahk_id %winID%
if (ErrorLevel = 1)
return (false)
if (x <> "" and y <> "")
{
winID := Lib_PST_WinGetID(3, "Buddy List", "", "#32770", timeoutSeconds)
if (winID <> "")
Lib_PST_WinMoveID(winID, x, y)
}
;if (hideLobby)
; Lib_PST_Partypoker_HideLobby()
return (true)
}
Lib_PST_Partypoker_CloseBuddyList(hideLobby=true, timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(3, "Buddy List", "", "#32770")
if (winID = "")
return (true)
result := Lib_PST_WinCloseID(winID, timeoutSeconds)
if (hideLobby)
Lib_PST_Partypoker_HideLobby()
return (result)
}
Lib_PST_Partypoker_ToggleCashier(hideLobby=true, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(3, "PartyPoker.com", "", "#32770")
if (winID = "")
result := Lib_PST_Partypoker_OpenCashier(hideLobby, x, y, timeoutSeconds)
else
result := Lib_PST_Partypoker_CloseCashier(hideLobby, timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_OpenCashier(hideLobby=true, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_Partypoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
return (false)
result := Lib_PST_ClickButton(winID, 1, "AfxWnd427")
if (hideLobby)
Lib_PST_Partypoker_HideLobby()
if (result = true and x <> "" and y <> "")
{
winID := Lib_PST_WinGetID(3, "PartyPoker.com", "", "#32770", timeoutSeconds)
if (winID = "")
return (false)
if (winID <> "")
{
Lib_PST_WinMoveID(winID, x, y)
Loop
{
WinGetPos, x2, y2, , , ahk_id %winID%
if (x2 <> x and y2 <> y)
{
Lib_PST_WinMoveID(winID, x, y)
break
}
}
}
}
return (result)
}
Lib_PST_Partypoker_CloseCashier(hideLobby=true, timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(3, "PartyPoker.com", "", "#32770")
if (winID = "")
return (false)
result := Lib_PST_WinCloseID(winID, timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_ToggleStatistics(tableID, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(3, "Statistics", "", "#32770")
if (winID = "")
result := Lib_PST_Partypoker_OpenStatistics(tableID, x, y, timeoutSeconds)
else
result := Lib_PST_Partypoker_CloseStatistics(timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_OpenStatistics(tableID, x="", y="", timeoutSeconds=5)
{
if (tableID = "")
return (false)
PostMessage, 0x111, 1016, 0, , ahk_id %tableID%
if (ErrorLevel = 1)
return (false)
if (x <> "" and y <> "")
{
winID := Lib_PST_WinGetID(3, "Statistics", "", "#32770", timeoutSeconds)
if (winID <> "")
Lib_PST_WinMoveID(winID, x, y, "", "", timeoutSeconds)
}
return (true)
}
Lib_PST_Partypoker_CloseStatistics(timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(3, "Statistics", "", "#32770")
if (winID = "")
return (false)
result := Lib_PST_WinCloseID(winID, timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_TogglePlayerSearch(hideLobby=true, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(1, "Search your selected players", "", "#32770")
if (winID = "")
result := Lib_PST_Partypoker_OpenPlayerSearch(hideLobby, x, y, timeoutSeconds)
else
result := Lib_PST_Partypoker_ClosePlayerSearch(hideLobby, timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_OpenPlayerSearch(hideLobby=true, x="", y="", timeoutSeconds=5)
{
winID := Lib_PST_Partypoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
return (false)
WinActivate, ahk_id %winID%
PostMessage, 0x111, 3082, 0, , ahk_id %winID%
if (ErrorLevel = 1)
return (false)
if (x <> "" and y <> "")
{
winID := Lib_PST_WinGetID(1, "Search your selected players", "", "#32770", timeoutSeconds)
if (winID <> "")
Lib_PST_WinMoveID(winID, x, y, "", "", timeoutSeconds)
}
return (true)
}
Lib_PST_Partypoker_ClosePlayerSearch(hideLobby=true, timeoutSeconds=5)
{
winID := Lib_PST_WinGetID(1, "Search your selected players", "", "#32770")
if (winID = "")
return (false)
result := Lib_PST_WinCloseID(winID, timeoutSeconds)
if (hideLobby)
Lib_PST_Partypoker_HideLobby()
return (result)
}
Lib_PST_Partypoker_NavigateToGameHome()
{
winID := Lib_PST_Partypoker_GetLobbyWinID()
if (winID = "")
return (false)
winactivate, ahk_id %winID%
ControlFocus, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
send {HOME}
sleep, 300
return (true)
}
Lib_PST_Partypoker_NavigateToGame(gameType, gameBlinds, seats)
{
winID := Lib_PST_Partypoker_GetLobbyWinID()
if (winID = "")
return (false)
winactivate, ahk_id %winID%
ControlFocus, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
ControlClick, SysTreeView321, ahk_id %winID%
send {HOME}
sleep, 300
ControlFocus, SysTreeView321, ahk_id %winID%
if (gameType <> "Limit Hold'em")
{
send %gameType%
sleep, 300
}
ControlFocus, SysTreeView321, ahk_id %winID%
IfInString, gameType, Pot-Limit Omaha
{
sleep, 300
send %gameType%
sleep, 300
}
ControlFocus, SysTreeView321, ahk_id %winID%
send {right}
sleep, 300
send {right}
sleep, 300
Loop, 20
{
Loop
{
ControlGet, result, List, , SysListView321, ahk_id %winID%
IfInString, result, $
break
sleep, 50
}
IfInString, result, %gameBlinds%
break
send {DOWN}
sleep, 10
}
IfNotInString, result, %gameBlinds%
return (false)
seatsToken1 = /%seats%
seatsToken2 = %seats%/%seats%
ControlGet, result, List, , SysListView321, ahk_id %winID%
Loop, parse, result, `n, `r
{
row := a_loopfield
IfInString, row, %seatsToken1%
{
Loop, parse, row, %A_Tab%
{
col := a_loopfield
if (a_index = 1)
firstCol := col
IfNotInString, col, %seatsToken1%
continue
StringReplace, pl, col, %seatsToken1%, ,
if (pl > 0)
{
tablename := firstCol
break
}
}
}
if (tablename <> "")
break
/*
IfInString, row, %seatsToken2%
{
pos := InStr(row, "`t")
if (pos < 1)
continue
StringLeft, tableName, row, pos-1
break
}
*/
}
if (tablename = "")
return (false)
ControlFocus, SysListView321, ahk_id %winID%
ControlClick, SysListView321, ahk_id %winID%
send %tablename%
sleep, 200
return (true)
}
Lib_PST_Partypoker_JoinOneTable(gameType, gameBlinds, seats, minPlayers, buyinPercent, sitout, x="", y="")
{
global pst_buyin_amount
global pst_join_button_name
if (gameType <> "")
{
result := Lib_PST_Partypoker_NavigateToGame(gameType, gameBlinds, seats)
if (result = false)
return (-1)
}
result := Lib_PST_Partypoker_ClickJoinWaitlistButton()
if (result = false)
return (-1)
winID := Lib_PST_WinGetID(1,"Join Wait List", "First Available", "#32770", "")
if (winID = "")
return (-1)
if (minPlayers > 0)
{
Lib_PST_ClickButton(winID, 3, "Button2")
ControlGet, nlist , List , Count, ComboBox1 , ahk_id %winID%
Loop, Parse, nlist, `n
maxPlayers = %A_LoopField%
if (maxPlayers < minPlayers)
minPlayers := maxPlayers
Control, Choose , %minPlayers% , ComboBox1 , ahk_id %winID%
Sleep , 100
}
Lib_PST_ClickButton(winID, 3, "Button3")
Lib_PST_WinWait(1, "Seat Available", "A seat has been reserved for you on", "#32770")
tableID := Lib_PST_Partypoker_JoinFirstAvailableSeat(temp, "")
if Lib_PST_Partypoker_CheckMaxTablesDialog(true)
{
sleep, 1000
Lib_PST_Partypoker_CloseAllSeats()
return (2)
}
if (tableID = "")
return (0)
Lib_PST_WinMoveID(tableID, x, y)
result := Lib_PST_Partypoker_TakeFirstAvailableSeat(tableID)
if (result = false)
return (0)
result := Lib_PST_Partypoker_ClickRebuy("", false, true, buyinPercent, 5, pst_buyin_amount)
if (result = false)
return (0)
if (sitout = 1)
{
result := Lib_PST_ClickCheckbox(tableID, 3, "Button5", true)
sleep, 100
result := Lib_PST_ClickButton(tableID, 3, pst_join_button_name, false)
}
Lib_PST_Partypoker_CloseAllSeats()
if Lib_PST_Partypoker_CheckMaxTablesDialog(true)
return (2)
return (1)
}
Lib_PST_Partypoker_ClickJoinWaitlistButton(timeoutSeconds=5, reactivateList=true)
{
global pst_join_button_name
winID := Lib_PST_Partypoker_GetLobbyWinID(timeoutSeconds)
if (winID = "")
return (false)
ControlGet, result, List, Count Focused, SysListView321, ahk_id %winID%
ControlFocus, SysListView321, ahk_id %winID%
if (reactivateList)
{
if (result > 1)
{
Send {UP}
sleep, 100
Send {DOWN}
sleep, 100
}
else
{
Send {DOWN}
sleep, 100
Send {UP}
sleep, 100
}
}
stopTimer := Lib_PST_CreateStopTimer(timeoutSeconds)
Loop
{
;ControlFocus, %pst_join_button_name%, ahk_id %winID%
Lib_PST_ClickButton(winID, 1, pst_join_button_name)
result := Lib_PST_WinWait(1,"Join Wait List", "First Available", "#32770", 1)
if (result = true)
break
if (A_Now > stopTimer)
return (false)
}
return (true)
}
Lib_PST_Partypoker_TakeFirstAvailableSeat(tableID, closeOnFailure=true)
{
ControlGet, result, Visible, , Button5, ahk_id %tableID%
if (result = true)
return (false)
matchList = 3|3|3|3|3|3|3|3|3|3
stringList = AfxWnd424|AfxWnd425|AfxWnd426|AfxWnd427|AfxWnd428|AfxWnd429|AfxWnd4210|AfxWnd4211|AfxWnd4212|AfxWnd4213
result := Lib_PST_ClickButtonList(tableID, matchList, stringList)
if (result = FALSE and closeOnFailure)
WinClose, ahk_id %tableID%
return (result)
}
Lib_PST_Partypoker_JoinFirstAvailableSeat(byref tableName, errorTables, timeoutSeconds=5)
{
SetTitleMatchMode, 1
WinGet, winID, IDLast, Seat Available ahk_class #32770, A seat has been reserved for you on
if (winID = "")
return ("")
WinGetText, winText, ahk_id %winID%
tablename := Lib_PST_Partypoker_GetTablenameFromSeat(winText)
token = xxx%tableName%xxx
if InStr(errorTables, token)
{
Lib_PST_ClickButton(winID, 3, "Button2")
return ("")
}
Lib_PST_ClickButton(winID, 3, "Button1")
stopTimer := Lib_PST_CreateStopTimer(timeoutSeconds)
loop
{
if Lib_PST_Partypoker_CheckMaxTablesDialog()
return ("")
SetTitleMatchMode, 1
IfWinExist, %tablename% ahk_class #32770
break
if (A_Now > stopTimer)
break
}
winID := Lib_PST_WinGetID(1, tablename, "", "#32770")
return (winID)
}
Lib_PST_Partypoker_CloseAllSeats()
{
Lib_PST_Partypoker_ShowLobby()
SetTitleMatchMode, 1
WinGet, idLIst, List, Seat Available ahk_class #32770, A seat has been reserved for you on
Loop, %idList%
Lib_PST_ClickButton(idList%a_index%, 3, "Button2")
return (true)
}
Lib_PST_Partypoker_CheckMaxTablesDialog(close=false)
{
SetTitleMatchMode, 1
IfWinExist, PartyPoker.com ahk_class #32770, If you would like to open a new table
{
if (close)
WinClose, PartyPoker.com ahk_class #32770, If you would like to open a new table
return (true)
}
return (false)
}
Lib_PST_Partypoker_GetTablenameFromSeat(seatText)
{
str := seatText
token := "A seat has been reserved for you on"
StringLen, len, token
StringMid, str, str, len+2, 9999
StringGetPos, pos, str, (
StringMid, str, str, 1, pos
return (str)
}
Lib_PST_Partypoker_CloseTables()
{
SetTitleMatchMode, 2
WinGet, pid, PID, PartyPoker.com:
WinGet, idList, List, Good Luck ahk_pid%pid% ahk_class #32770, , PartyPoker.com:
Loop, %idList%
{
id := idList%a_index%
WinClose , ahk_id %id%
}
return (true)
}
Lib_PST_Partypoker_CountTables()
{
SetTitleMatchMode, 2
WinGet, pid, PID, PartyPoker.com:
WinGet, idList, List, Good Luck ahk_pid%pid% ahk_class #32770, , PartyPoker.com:
return (idList)
}
Lib_PST_Partypoker_ClickLeaveTable(tableID, clickButton=true, timeoutSeconds=5)
{
if (clickButton)
{
Lib_PST_ClickButton(tableID, 3, "AfxWnd423")
sleep, 100
}
if NOT Lib_PST_WinExistID(tableID)
return (true)
Loop, %timeoutSeconds%
{
result := Lib_PST_WinWait(1, "", "Do you really want to stand-up and leave the table", "#32770", 1)
if (result = true)
break
if NOT Lib_PST_WinExistID(tableID)
return (true)
}
winID := Lib_PST_WinGetID(1, "", "Do you really want to stand-up and leave the table", "#32770")
if (winID = "")
return (true)
Lib_PST_ClickButton(winID, 3, "Button1")
result := Lib_PST_WinWaitCloseID(winID, timeoutSeconds)
return (result)
}
Lib_PST_Partypoker_ClickRebuy(tableID, clickButton=true, checkDialogs=false, buyinPercent=100, timeoutSeconds=5, buyinAmount=0)
{
if (clickButton)
{
Lib_PST_ClickButton(tableID, 3, "AfxWnd421")
sleep, 100
}
if (checkDialogs)
{
if Lib_PST_WinExist(1, "PartyPoker.com", "You can have maximum", "#32770")
{
Lib_PST_WinClose(1, "PartyPoker.com", "You can have maximum", "#32770")
return (false)
}
}
winID := Lib_PST_WinGetID(1, "Buy-In", "Decide the amount", "#32770", timeoutSeconds)
if (winID = "")
return (false)
amount := 0
if (buyinAmount > 0)
amount := buyinAmount
else
{
if (buyinPercent = "" or buyinPercent = 0)
buyinPercent := 100
if (buyinPercent <> 100)
{
ControlGetText , amount, Edit1, ahk_id %winID%
amount := Round(amount * (buyinPercent / 100) , 1)
}
}
if (amount > 0)
ControlSetText , Edit1, %amount%, ahk_id %winID%
result := Lib_PST_ClickButton(winID, 3, "Button1")
if (result = false)
{
WinClose, ahk_id %winID%
return (false)
}
sleep, 100
if (checkDialogs)
{
dialogs = Please enter an amount|You can bring a maximum|You do not have sufficient funds|The Minimum Buy-in required to sit at this table
StringSplit, dialogs, dialogs, |,
Loop, %dialogs0%
{
thisDialog := dialogs%a_index%
if Lib_PST_WinExist(1, "PartyPoker.com", thisDialog, "#32770")
{
Lib_PST_WinClose(1, "PartyPoker.com", thisDialog, "#32770")
Lib_PST_WinCloseID(winID)
return (false)
}
}
}
if NOT Lib_PST_WinWaitCloseID(winID, timeoutSeconds)
return (false)
if (checkDialogs)
{
sleep, 100
if Lib_PST_WinExist(1, "PartyPoker.com", "Additional chips", "#32770")
Lib_PST_WinClose(1, "PartyPoker.com", "Additional chips", "#32770")
}
return (true)
}
Lib_PST_Partypoker_PostChatMessage(tableID, message)
{
ControlSendRaw, Edit1, %message%, ahk_id %tableID%
sleep, 1200
;ControlSend, Edit1, {Enter}, ahk_id %tableID%
ControlClick, Edit1, ahk_id %tableID%
controlgetpos, x, y, w, h, Edit1, ahk_id %tableID%
mouseclick, left, x, y
sleep, 1200
SendInput {enter}
return (ErrorLevel = 0)
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; library (general) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Lib_PST_WinActivateID(winID)
{
WinActivate, ahk_id %winID%
}
Lib_PST_WinExist(matchMode, title, text, class="", titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
{
IfWinExist, %title% ahk_class %class%, %text%, %titleEx%, %textEx%
return (true)
else
return (false)
}
else
{
IfWinExist, %title%, %text%, %titleEx%, %textEx%
return (true)
else
return (false)
}
}
Lib_PST_WinExistID(winID)
{
IfWinExist, ahk_id %winID%
return (true)
else
return (false)
}
Lib_PST_WinClose(matchMode, title, text, class="", timeoutSeconds=5, titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
WinClose, %title% ahk_class %class%, %text%, %titleEx%, %textEx%
else
WinClose, %title%, %text%, %titleEx%, %textEx%
result := Lib_PST_WinWaitClose(matchMode, title, text, class, timeoutSeconds, titleEx, textEx)
return (result)
}
Lib_PST_WinCloseID(winID, timeoutSeconds=5)
{
WinClose, ahk_id %winID%
result := Lib_PST_WinWaitCloseID(winID, timeoutSeconds)
return (result)
}
Lib_PST_WinWait(matchMode, title, text, class="", timeoutSeconds="", titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
WinWait, %title% ahk_class %class%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
else
WinWait, %title%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
return (ErrorLevel = 0)
}
Lib_PST_WinWaitClose(matchMode, title, text, class="", timeoutSeconds="", titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
if (class <> "")
WinWaitClose, %title% ahk_class %class%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
else
WinWaitClose, %title%, %text%, %timeoutSeconds%, %titleEx%, %textEx%
return (ErrorLevel = 0)
}
Lib_PST_WinWaitCloseID(winID, timeoutSeconds="")
{
WinWaitClose, ahk_id %winID%, , %timeoutSeconds%
if (ErrorLevel = 1)
return (false)
else
return (true)
}
Lib_PST_WinMoveID(winID, x, y, w="", h="", timeoutSeconds=0)
{
stopTimer := Lib_PST_CreateStopTimer(timeoutSeconds)
isMoved := false
Loop
{
WinGetPos, x0, y0, w0, h0, ahk_id %winID%
if (x0 = x AND y0 = y)
{
isMoved := true
break
}
WinMove, ahk_id %winID%, , x, y, w, h
Sleep, 25
if (A_Now > stopTimer)
break
}
return (isMoved)
}
Lib_PST_WinGetID(matchMode, title, text, class="", timeoutSeconds=0, titleEx="", textEx="")
{
SetTitleMatchMode, %matchMode%
stopTimer := Lib_PST_CreateStopTimer(timeoutSeconds)
winID := ""
Loop
{
if (winID = "")
if (class <> "")
WinGet, winID, ID, %title% ahk_class %class%, %text%, %titleEx%, %textEx%
else
WinGet, winID, ID, %title%, %text%, %titleEx%, %textEx%
else
break
if (A_Now > stopTimer)
break
sleep, 100
}
return (winID)
}
Lib_PST_ClickButton(winID, matchMode, buttonName, clickByKey="")
{
if (clickByKey = "")
{
StringUpper, str, buttonName
StringLeft, str, str, 6
if (str = "BUTTON")
clickByKey := true
else
clickByKey := false
}
SetTitleMatchMode, %matchMode%
WinActivate, ahk_id %winID%
ControlGet, result, Visible, , %buttonName%, ahk_id %winID%
if (result = false)
return (false)
if (clickByKey)
{
ControlFocus, %buttonName%, ahk_id %winID%
Send {SPACE}
}
else
ControlClick, %buttonName%, ahk_id %winID%
return (ErrorLevel = 0)
}
Lib_PST_ClickButtonList(winID, matchList, buttonList, clickByKey=false)
{
StringSplit, buttonList, buttonList, |
StringSplit, matchList, matchList, |
Loop, %buttonList0%
{
thisButton := buttonList%a_index%
thisMatch := matchList%a_index%
SetTitleMatchMode, %thisMatch%
ControlGet, result1, Visible, , %thisButton%, ahk_id %winID%
ControlGet, result2, Enabled, , %thisButton%, ahk_id %winID%
If (result1 AND result2)
{
if (clickByKey)
{
ControlFocus, %thisButton%, ahk_id %winID%
Send {SPACE}
}
else
ControlClick, %thisButton%, ahk_id %winID%
return (ErrorLevel = 0)
}
}
return (false)
}
Lib_PST_ClickCheckbox(winID, matchMode, checkboxName, checked, timeoutSeconds=5)
{
stopTimer := Lib_PST_CreateStopTimer(timeoutSeconds)
SetTitleMatchMode, %matchMode%
Loop
{
ControlGet, result, Visible, , %checkboxName%, ahk_id %winID%
if (result = true)
break
sleep, 50
if (A_Now > stopTimer)
break
}
if (result = false)
return (false)
stopTimer := Lib_PST_CreateStopTimer(timeoutSeconds)
WinActivate, ahk_id %winID%
ControlGet, result, Checked, , %checkboxName%, ahk_id %winID%
if (result = checked)
return (true)
Loop {
if (checked)
Control, Check, , %checkboxName%, ahk_id %winID%
else
Control, Uncheck, , %checkboxName%, ahk_id %winID%
sleep, 50
ControlGet, result, Checked, , %checkboxName%, ahk_id %winID%
if (result = checked)
return (true)
if (A_Now > stopTimer)
break
}
return (false)
}
Lib_PST_CreateStopTimer(seconds)
{
stopTime := A_Now
EnvAdd, stopTime, %seconds%, seconds
return (stopTime)
}
Lib_PST_SaveMousePosition()
{
global Lib_PST_mouse_pos_x, Lib_PST_mouse_pos_y
CoordMode, Mouse, Screen
MouseGetPos, Lib_PST_mouse_pos_x, Lib_PST_mouse_pos_y
CoordMode, Mouse, Relative
}
Lib_PST_RestoreMousePosition()
{
global Lib_PST_mouse_pos_x, Lib_PST_mouse_pos_y
CoordMode, Mouse, Screen
MouseMove, Lib_PST_mouse_pos_x, Lib_PST_mouse_pos_y, 0
CoordMode, Mouse, Relative
}
Lib_PST_LongestListItem(list)
{
longest = 0
Loop, Parse, list, |
{
If (longest < StrLen(A_LoopField))
{
longest := StrLen(A_loopfield)
}
}
return (longest)
}
Lib_PST_Beep(times, length, frequency="")
{
Loop, %times%
SoundBeep, %frequency%, %length%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; scriptpad ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PST_Scriptpad_End:
; Do nothing. This is needed to work with Scriptpad.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Code ends here ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
