hi, everyone. The script is great, but seems there are no updates
I tried to simplify it and add couple of functions
I think a simpler version might encourage users to look into it and improve it.
here goes my approach... I welcome any comments
; a simplified poker stars auto register script
; based on/inspired by SFSO_4.01b.ahk
; Thaks go to: Everlong@2p2, _dave_, chris228, finnisher, Max1mums
; ================================================== ========
; Need to have the "Show registering/upcoming only" activated in lobby
; Do not minimize PokerStars Lobby, just move it out of the way
; ================================================== ========
#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
SetTitleMatchMode, 2
StringTrimRight, thisahk, A_ScriptName, 4
regButton:="PokerStarsButtonClass10"
unregButton:="PokerStarsButtonClass8"
AutoRegister:=0
AutoSittingOut:=0
AutoWindowMaximize:=0
; ================================================== ========
; User defined variables
; ================================================== ========
MaxTablesInit:=3 ; Maximum number of Tables to keep open, Initial value
RegisterInterval:=30*1000 ; Register every X millisec
SittingOut:=1*60*1000 ; check and rejoin if Sitting Out every X millisec
WindowMaximize:=2*1000 ; check and Maximize all table Windows every X millisec
IdleCheck:=1*60*1000 ; Check if Idle every X millisec
IdleTime:=10*60*1000 ; PauseScript and UnRegisterAll, if Idle for X millisec
; ================================================== =========
; User defined variables
; ================================================== =========
if (IdleCheck>0)
SetTimer, Safeguard, %IdleCheck%
Gosub, BuildGui
Return
QuitScript:
ExitApp
Return
BuildGui:
Gui, Color, White
Gui, Font, cOlive
Gui, Add, Text,, Maximum Number of Open Tables
Gui, Add, Edit
Gui, Add, UpDown, vMaxTables, %MaxTablesInit%
Gui, Add, Button, w190 gSittingOut, &Check if Sitting [O]ut and Go Back
Gui, Add, Checkbox, vAutoSittingOut, &Auto
Gui, Add, Button, w190 gWindowMaximize, &Maximize all Table [W]indows
Gui, Add, Checkbox, vAutoWindowMaximize, &Auto
Gui, Add, Button, w190 gStartScript, &[S]ubmit and Start/Continue Script
Gui, Add, Button, w190 gLobbyRestore, &Restore [L]obby
Gui, Add, Button, w190 gUnRegisterAll, &[U]n-Register All
Gui, Add, Button, w190 gPauseScript, &[P]ause Script
Gui, Add, Button, w190 gQuitScript, &[Q]uit Script
Gui, Add, Text, w250 cBlue, hotkeys: Ctl + Alt + letter_in_brackets
Gui, Add, Text, w250 cRed vStatus, Status: Idle
Gui, Show, w260, %thisahk%
Gui, Show, x0 y0, %thisahk%
Sleep, -1
Gosub, PauseScript
Return
Safeguard:
if (A_TimeIdle > IdleTime)
{
Gosub, PauseScript
Gosub, UnRegisterAll
GuiControl,, Status, Status: Stopped due to inactivity
}
Return
PauseScript:
Critical
AutoRegister:=0
AutoSittingOut:=0
AutoWindowMaximize:=0
SetTimer, Register, off
SetTimer, AutoClose, off
SetTimer, WindowMaximize, off
SetTimer, SittingOut, off
SetTimer, SafeGuard, off
GuiControl,, Status, Status: Script Paused
Return
StartScript:
Gui, Submit, NoHide
SetTimer, AutoClose, 100
if (SittingOut>0 AND AutoSittingOut=1)
SetTimer, SittingOut, %SittingOut%
else
SetTimer, SittingOut, off
if (WindowMaximize>0 AND AutoWindowMaximize=1)
SetTimer, WindowMaximize, %WindowMaximize%
else
SetTimer, WindowMaximize, off
if (RegisterInterval>0) {
Gosub, Register
SetTimer, Register, %RegisterInterval%
}
Sleep, -1
Return
Register:
AutoRegister:=1
SetTitleMatchMode, 2
WinGet, LobbyId, Id, PokerStars Lobby - ahk_class #32770
if !LobbyId
{
GuiControl,, Status, Status: PokerStars Lobby not found
Return
}
ControlSend, PokerStarsListClass3, {NumpadUp 20}, ahk_id%LobbyId%
WinGet, PhysicalTables, list, Table ahk_class PokerStarsTableFrameClass
if PhysicalTables is not Number
PhysicalTables:=0
if (PhysicalTables >= MaxTables)
{
GuiControl,, Status, Status: Set Full at %PhysicalTables% tables _ Waiting
Return
}
timestoReg := MaxTables - PhysicalTables
RegSNGexec(LobbyID, timestoReg)
Return
RegSNGexec(id, times) {
global AutoRegister
global regButton
global unregButton
Loop %times% {
GuiControl,, Status, Status: Registering %times% times
if (AutoRegister = 0) {
GuiControl,, Status, Status: Idle
Exit
}
ControlGet, regBtnVis, Visible,, %regButton%, ahk_id%id%
if (regBtnVis = 1) {
ControlSend, %regButton%, {Space}, ahk_id%id%
ControlSend, %regButton%, {Space}, ahk_id%id%
Sleep, 30
ControlSend, PokerStarsListClass3, {NumpadDown}, ahk_id%id%
Sleep, 30
GuiControl,, Status, Status: Waiting
} else {
ControlGet, unregBtnVis, Visible,, %unregButton%, ahk_id%id%
if (unregBtnVis = 1) {
GuiControl,, Status, Status: Already registered game found _ Waiting
Sleep, 30
ControlSend, PokerStarsListClass3, {NumpadDown}, ahk_id%id%
Sleep, 30
} else {
GuiControl,, Status, Status: No games found _ Waiting
Return
}
}
Sleep, -1
}
}
Return
UnRegisterAll:
WinGet, LobbyId, id, PokerStars Lobby - ahk_class #32770
if !LobbyId
{
GuiControl,, Status, Status: PokerStars Lobby not found
Return
}
ControlSend, PokerStarsListClass3, ^r, ahk_id%lobbyid%
WinWait, Registered In Tournaments ahk_class #32770,, 1
{
WinGet, regid, id, Registered In Tournaments ahk_class #32770
ControlGet, vis, Visible,, Button1, ahk_id%regid%
if vis {
ControlSend, Button1, {Space}, ahk_id%regid%
Sleep, 30
ControlSend, PokerStarsButtonClass2, {Space}, ahk_id%regid%
Sleep, 30
WinClose, ahk_id%regid%
}
}
Return
LobbyRestore:
WinGet, LobbyId, id, PokerStars Lobby - ahk_class #32770
if !LobbyId
{
GuiControl,, Status, Status: PokerStars Lobby not found
Return
}
WinShow, ahk_id%LobbyId%
WinMove, ahk_id%LobbyId%,, 0, 0
Return
AutoClose:
AutoClose()
Return
AutoClose()
{
SetTitleMatchMode,2
ifWinExist, Tournament Registration ahk_class #32770
{
WinGet, id1, id,
Sleep 30
WinClose, ahk_id%id1%
}
ifWinExist, PokerStars ahk_class #32770,, Lobby
{
WinGet, id2, id,
Sleep 30
WinClose, ahk_id%id2%
}
}
Return
SittingOut:
SittingOut()
Return
SittingOut()
{
activeid := WinExist("A")
SetTitleMatchMode,2
WinGet, TableWindows, List, Table ahk_class PokerStarsTableFrameClass
if TableWindows=0
Exit
Loop %TableWindows% {
id:=TableWindows%A_Index%
WinActivate, ahk_id%id%
WinGetPos,,, w, h, ahk_id%id%
x1:=0.82*w
y1:=0.85*h
Round(x1)
Round(y1)
x2:=x1+2
y2:=y1+2
ColorID:=0x141414
PixelSearch,,, x1, y1, x2, y2, ColorID, 20, ahk_id%id%, Fast
if (ErrorLevel=0)
Click %x1%, %y2%
Sleep, -1
}
WinActivate, ahk_id%activeid%
Sleep, 30
Sleep, -1
}
Return
WindowMaximize:
WindowMaximize()
Return
WindowMaximize()
{
SetTitleMatchMode,2
WinGet, TableWindows, List, Table ahk_class PokerStarsTableFrameClass
if TableWindows=0
Exit
Loop %TableWindows% {
id:=TableWindows%A_Index%
WinGetPos,,, w, h, ahk_id%id%
if (w<A_ScreenWidth AND w<1328)
PostMessage, 0x112, 0xF030,,, ahk_id%id%
Sleep, 30
Sleep, -1
}
}
Return
; hotkeys
^!o::
Gosub, SittingOut
Return
^!w::
Gosub, WindowMaximize
Return
^!s::
Gosub, StartScript
Return
^!l::
Gosub, LobbyRestore
Return
^!u::
Gosub, UnRegisterAll
Return
^!p::
Gosub, PauseScript
Return
^!h::
WinHide, %thisahk%
Return
^!r::
WinShow, %thisahk%
Return
~^!q::
ExitApp