Open Side Menu Go to the Top
Register
AHK script:Stars Filtered SNG Opener AHK script:Stars Filtered SNG Opener

04-06-2015 , 02:08 PM
@rysf

Short one:
- download autohotkey
- download script (link above - v 4.01.c)
- run script and set parameters in GUI as you wish
- filter pokerstars lobby to have visible all SNGs that you would like to auto register
- click "submit + run" when you are ready
AHK script:Stars Filtered SNG Opener Quote
04-15-2015 , 03:56 PM
"Idle (Lobby not found)" is what it says in the status bar.


I'm running the .exe version. It was said somewhere in this thread that it looks for "PokerStars lobby - logged as" text in the title to find pokerstars window. However, it just says "PokerStars Lobby" on my client, and yes I'm logged in. Now what?

Is version 7 even supported?

Today version 7 was a forced upgrade, so TN1 sng registration thingy finally stopped working. I'm hoping somebody can help me with this.
AHK script:Stars Filtered SNG Opener Quote
04-15-2015 , 05:24 PM
tried several times earlier today, but can't get links to work? redirected to page not found/the like
AHK script:Stars Filtered SNG Opener Quote
04-15-2015 , 05:57 PM
Here is 4.01c version:
Code:
; Author:         Everlong@2p2 Code assembled from misc sources, thanks to _dave_, chris228, finnisher
; v.4.01c
; added: PS 7 support
; 4.0x version fixed by Max1mums 
#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%
setwindelay,-1
setcontroldelay,-1
SetBatchLines, -1
SetTitleMatchMode, 2
SetTimer, register, off
SetTimer, safeguard, off
SetTimer, numcheck, 75
StringTrimRight, thisahk, A_ScriptName, 4
onexit,exitsub
IniRead, pspath, %thisahk%.ini, Settings, path


;;;;;;;;;;;SET YOUR pokerstars.log.0 file path below;;;;;;;;;;;;;;;
;;;;;;;;;;;eg: logfile:="c:\Program Files\PokerStars\pokerstars.log.0"
logfile:= pspath . "pokerstars.log.0" ;<-


IfNotExist,%logfile%
{
Loop, %A_ProgramFiles%\* , 2
{
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
}
IfNotExist,%logfile%
Loop, %A_AppData%\* , 2
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
IfNotExist,%logfile%
{
StringReplace,logfile,A_AppData,Roaming,Local
Loop, %logfile%\* , 2
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
}
}
IfNotExist,%logfile%
{
logfile:= pspath . "pokerstars.log.0"
IfNotExist,%logfile%
msgbox, PokerStars.log.0 file path is probably incorrect, recheck the configuration
}
IniRead, Targetnum, %thisahk%.ini, Settings, Targetnum
if Targetnum is not number
Targetnum:=0
;==============================================================
RegSofar=0
OpenTables=0
trows=17
SysGet,mon, MonitorworkArea
fivesec=0
ft:=0
two=0
ddlist4=Off|
ddlist5=Off|
ddlist6=Off|
ddlist7=Off|
LobbyList=Default|Black|
ddlist2:=ddlist2 . 1 . "|"
ddlist2:=ddlist2 . 2 . "|"
Loop 100
{
two:=two+2
ddlist3:=ddlist3 . two . "|"
ddlist:=ddlist . A_index . "|"
If (A_index<51)
{
fivesec:=fivesec+5
ddlist2:=ddlist2 . fivesec . "|"
ddlist6:=ddlist6 . fivesec . "|"
If (A_index<22)
{
ddlist7:=ddlist7 . A_Index . "|"
If (A_index<16)
{
ddlist4:=ddlist4 . A_index . "|"
}
}
}
else
{
ft:=ft+15
ddlist5:=ddlist5 . ft . "|"
}
}
ddlist3:=ddlist3 . 9999 . "|"
Gosub, BuildGui
Return
;==============================================================
;==============================================================

BuildGui:
Gui, color, white
Gui, font, cOlive
Gui, add, tab, h340 w240, General|Advanced Settings
Gui, add, text, , Auto-register
Gui, add, Checkbox, yp xp+80 Check3 Checked-1 vRegister
Gui, add, text, yp xp+30, Reg. next if full?
Gui, add, Checkbox, yp xp+80 VAutoifFull


Gui, add, text,xp-190 yp+30 , Register every (sec):
Gui, add, DropDownList, w50 yp-5 xp+140  vInterval1, %ddlist2%
Gui, add, text, xp-140 yp+30, No of SNG:s to keep open:
Gui, add, DropDownList, w50 yp-5 xp+140 vKeepOpen , %ddlist%
Gui, add, text,xp-140 yp+30, Limit total SNG:s to:
Gui, add, DropDownList, w50 yp-5 xp+140 vTotalLimit , %ddlist3%
Gui, add, text,xp-140 yp+30, Limit total time to (min):
Gui, add, DropDownList, w50 yp-5 xp+140 vLimitTime , %ddlist5%

Gui, add, text, xp-140 yp+30 cred vcdown w200
Gui, add, text, xp  yp+30 w200 vRegSofar, SNG:s registered so far:
Gui, add, text,  w200 vOpenTables, Tables open/waiting:
Gui, add, text, w200 cRed vStatus, Status: Idle
Gui, add, Button, w68 ggetgui, &Submit+Run
Gui, add, text, xp+72 yp+5, (Autosaves your settings)
Gui, Add, Button, Disabled xp-72 yp+20 w48 h20 Center , &Resume
Gui, Add, Button, Disabled  w45 h20 yp xp+48 Center , &Pause
Gui, Add, Button, w80 h20 yp xp+45 Center globbyrestore, &Lobby restore
Gui, tab, 2

Gui, add, Text, x25 y65 , Lobby Theme:
Gui, add, DropDownList, w65 yp-5 xp+140 vLobby, %LobbyList%
Gui, add, text,xp-140 yp+30 , Close lobbies every (sec):
Gui, add, DropDownList, w50 yp-5 xp+140  vCloseInterv, %ddlist6%
Gui, add, text, xp-140 yp+18 , (manually Close with ctrl+e)
Gui, add, text, yp+30, Disable if no user Input (min):
Gui, add, DropDownList, w50 yp-5 xp+140 vGuardtimer Choose1 , %ddlist4%
Gui, add, text, xp-140 yp+30 ,Batch-register?
Gui, add, Checkbox,yp xp+140 vBatchReg
Gui, add, text, yp+20 xp-140 ,SetReg* mode?
Gui, add, Checkbox,yp xp+140 vSetReg
Gui, add, text, yp+20 xp-140 ,Minimize lobby?
Gui, add, Checkbox,yp xp+140 vMinlob
Gui, add, Text, xp-140 yp+30, Times to scroll down:
Gui, add, DropDownList, w50 yp-5 xp+140 vscrldwn, %ddlist7%
Gui, add, Text, xp-140 yp+25, Always start at top of lobby?
Gui, add, Checkbox, yp xp+140 vTopReturn
Gui, show, w256, %thisahk%
WinGetPos, x, y, w, h, SFSO
;x:=monRight-w
;y:=monBottom-h
x:=monLeft
y:=monTop
Gosub, GetIni
Gui, show, x%x% y%y%, %thisahk%
Return

getgui:
GuiControl,, Register, -1
Register = 1
Gui, Submit, NoHide
displayedTime=
If (lobby="Default")
{
regButton:="PokerStarsButtonClass10"
}
Else If (lobby="Black" or lobby="Custom*")
{
regButton:="PokerStarsButtonClass10"
}
PS6list=PokerStarsListClass3
PS7list1=PokerStarsListClass13
PS7list2=PokerStarsListClass12
Gosub, MakeIni
PausedTime:=LimitTime
Gosub, TimeLimit
interval:=interval1*1000
If interval is not Number
interval=off
If guardtimer is not Number
{
SetTimer, safeguard, off
}
Else
{
killtime:=guardtimer*60000
SetTimer, safeguard, 1000
}
if CloseInterv is not number
SetTimer, NukeLobbies, off
else
{
lobclose:=CloseInterv*1000
SetTimer, NukeLobbies, %lobclose%
}
register=1
sleep,-1
Gosub, ButtonResume
Return

Safeguard:
If (A_TimeIdle > killtime)
{
Gosub, ButtonPause
GuiControl, , cdown, Stopped  due to inactivity!!! %displayedTime%
}
Return

TimeLimit:
If LimitTime is Number
{
allowedMinutes := LimitTime
endTime := A_Now
endTime += %allowedMinutes%, Minutes
SetTimer, CountDown, 1000
}
Else
{
SetTimer, CountDown, off
sleep,-1
GuiControl, , cdown, Time Limit off
}
Return

Countdown:
remainingTime := endTime
EnvSub remainingTime, %A_Now%, Seconds
m := remainingTime // 60
s := Mod(remainingTime, 60)
displayedTime := Format3Digits(m) ":" Format2Digits(s)
GuiControl, , cdown, Running another (mm:ss): %displayedTime%
If (A_now > endTime)
{
SetTimer, Countdown, off
Gosub, ButtonPause
GuiControl, , cdown, Time Limit reached.
}
Return

GuiClose:
Gui, Submit
Gosub, MakeIni
ExitApp
Return

ButtonResume:
Gui, Submit, NoHide
GuiControl, Disable, &Resume
GuiControl, Enable, &Pause
if LimitTime is Number
If PausedTime is Number
LimitTime:=PausedTime
Gosub, TimeLimit
GuiControl, , Register, -1
Register:=1
SetTitleMatchMode, 2
WinGet, LobbyID, id, PokerStars Lobby,,Tournament
wingettitle,lobbytitle,ahk_id%LobbyID%
if !instr(lobbytitle,"Logged In")>0
{
WinGet,ctrls,ControlList,ahk_id%LobbyID%
Loop,Parse,ctrls,`n
{
 controlgettext,text,%A_LoopField%,ahk_id%LobbyID%
 if text=Register
 regButton:=A_LoopField
}
}
settimer, AutoReg,37
OpenTables:=0
tables=
OpenTables:=CountTourneys(1)
Gosub,Register
SetTimer, Register, %Interval%
sleep,-1
Return

ButtonPause:
Critical
Gui, Submit, NoHide
if LimitTime is Number
PausedTime:=remainingTime/60
Register:=0
settimer, AutoReg,off
SetTimer, Countdown, off
SetTimer, Register, off
GuiControl, Disable, Pause
GuiControl, Enable, Resume
GuiControl, , Register, 0
GuiControl, , cdown, Manually Paused %displayedTime%
GuiControl, , Status, Status: Waiting ;TEST
Return

Register:
SetTitleMatchMode, 2
WinGet, LobbyID, id, PokerStars Lobby,,Tournament
If !LobbyID
{
Gosub, ButtonPause
GuiControl,, Status, Status: PokerStars Lobby not found
Gui, show, NoActivate, %thisahk%
Return
}
If (TopReturn=1)
{
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
ControlSend, %list%, {NumpadUp 20}, ahk_id%lobbyid%
}
WinGet, PhysicalTables, list,Table ahk_class PokerStarsTableFrameClass
If PhysicalTables is not Number
PhysicalTables:=0
If (PhysicalTables >= KeepOpen)
{
GuiControl,, Status, Set Full waiting
Return
}
OpenTables:=CountTourneys()
If OpenTables is not Number
OpenTables:=0
GuiControl, , OpenTables, Tables open/waiting: %OpenTables%
GuiControl, , RegSofar, SNG:s registered so far: %RegSofar%
If (RegSofar >= TotalLimit)
{
Gosub, ButtonPause
GuiControl, , cdown, SNG Total Limit reached
GuiControl, , Status, Status: Idle ;TEST
Return
}
If (OpenTables >= TotalLimit)
{
Gosub, ButtonPause
GuiControl, , cdown, SNG Total Limit reached
GuiControl, , Status, Status: Idle ;TEST
Return
}
If (OpenTables>=KeepOpen)
{
GuiControl, , OpenTables, Tables open/waiting: %OpenTables% (Set full)
GuiControl, , Status, Status: Waiting ;TEST
Return
}
Else
{
If (BatchReg=1)
{
Times:= KeepOpen - OpenTables
RegSNGexec(LobbyID, Times, scrldwn)
}
Else
{
RegSNGexec(LobbyID, 1, scrldwn)
}
}
Return

MakeIni:
IniWrite, %AutoIfFull%, %thisahk%.ini, Settings, AutoIfFull
IniWrite, %TopReturn%, %thisahk%.ini, Settings, TopReturn
IniWrite, %scrldwn%, %thisahk%.ini, Settings, scrldwn
IniWrite, %Lobby%, %thisahk%.ini, Settings, Lobby
IniWrite, %BatchReg%, %thisahk%.ini, Settings, BatchReg
IniWrite, %Setreg%, %thisahk%.ini, Settings, SetReg
IniWrite, %Minlob%, %thisahk%.ini, Settings, MinLob
IniWrite, %Interval1%, %thisahk%.ini, Settings, Interval1
IniWrite, %CloseInterv%, %thisahk%.ini, Settings, CloseInterv
IniWrite, %KeepOpen%, %thisahk%.ini, Settings, KeepOpen
IniWrite, %TotalLimit%, %thisahk%.ini, Settings, TotalLimit
IniWrite, %GuardTimer%, %thisahk%.ini, Settings, GuardTimer
IniWrite, %LimitTime%, %thisahk%.ini, Settings, LimitTime
Return

GetIni:
IfExist, %thisahk%.ini
{
IniRead, AutoIfFull, %thisahk%.ini, Settings, AutoIfFull
IniRead, TopReturn, %thisahk%.ini, Settings, TopReturn,0
IniRead, scrldwn, %thisahk%.ini, Settings, scrldwn
IniRead, Lobby, %thisahk%.ini, Settings, Lobby
IniRead, BatchReg, %thisahk%.ini, Settings, BatchReg
IniRead, SetReg, %thisahk%.ini, Settings, SetReg, 1
IniRead, MinLob, %thisahk%.ini, Settings, MinLob, 0
IniRead, Interval1, %thisahk%.ini, Settings, Interval1
IniRead, CloseInterv, %thisahk%.ini, Settings, CloseInterv
IniRead, KeepOpen, %thisahk%.ini, Settings, KeepOpen
IniRead, TotalLimit, %thisahk%.ini, Settings, TotalLimit
IniRead, GuardTimer, %thisahk%.ini, Settings, GuardTimer, Off
IniRead, LimitTime, %thisahk%.ini, Settings, LimitTime, Off
GuiControl, , AutoIfFull, %AutoIfFull%
StringReplace, ddlist7, ddlist7, %scrldwn%, %scrldwn%|
GuiControl, , scrldwn, |%ddlist7%
StringReplace, LobbyList, LobbyList, %Lobby%, %Lobby%|
GuiControl, , Lobby, |%LobbyList%
GuiControl, , BatchReg, %BatchReg%
GuiControl, , SetReg, %SetReg%
GuiControl, , MinLob, %MinLob%
GuiControl, , TopReturn, %TopReturn%
StringReplace, ddlist2, ddlist2, %interval1%, %Interval1%|
GuiControl, , Interval1, |%ddlist2%
StringReplace, ddlist6, ddlist6, %CloseInterv%, %CloseInterv%|
GuiControl, , CloseInterv, |%ddlist6%
StringReplace, ddlist, ddlist, %KeepOpen%, %KeepOpen%|
GuiControl, , KeepOpen, |%ddlist%
StringReplace, ddlist3, ddlist3, %TotalLimit%, %TotalLimit%|,
GuiControl, , TotalLimit, |%ddlist3%
StringReplace, ddlist4, ddlist4, %GuardTimer%, %GuardTimer%|
GuiControl, , GuardTimer, |%ddlist4%
StringReplace, ddlist5, ddlist5, %LimitTime%, %LimitTime%|
GuiControl, , LimitTime, |%ddlist5%
}
Return

#e::
gosub,NukeLobbies
Return

NukeLobbies:
SetTitleMatchMode, 2
GroupAdd, TLobbies, Lobby ahk_class PokerStarsTableFrameClass,,, PokerStars Lobby
GroupClose, TLobbies, A
Return

#H::
WinHide, %thisahk%
return

#S::
WinShow, %thisahk%
return

F11::
TmpSetReg:=SetReg
SetReg=0
CountTourneys()
SetReg:=TmpSetReg
Return
ManualCount:
CountTourneys()
Return

FindLobby:
If (%A_GuiEvent% = DoubleClick)
{
LV_GetText(TournId,A_EventInfo)
TournID:=SubStr(TournID, 1,10)
WinMenuSelectItem, PokerStars Lobby,, Requests, Find a Tournament
WinWait, Find Tournament ahk_class #32770, , 10
WinGet, fat, id
ControlFocus, Edit1, ahk_id%fat%
Sleep, -1
ControlSend, Edit1, %TournId%, ahk_id%fat%
ControlFocus, Button1, ahk_id%fat%
Sleep, -1
ControlSend, Button1, {Space}, ahk_id%fat%
}
Return

Format2Digits(_val) {
_val :=Round(_val) + 100
StringRight _val, _val, 2
Return _val
}

Format3Digits(_val) {
_val :=Round(_val) + 1000
StringRight _val, _val, 3
StringTrimRight, FirstZ, _val, 2
If FirstZ=0
{
StringTrimLeft, _val, _val, 1
}
StringTrimRight, FirstZ, _val, 1
If FirstZ=0
{
StringTrimLeft, _val, _val, 1
}
Return _val
}
LobbyRestore:
WinGet, lobbyid, id, PokerStars Lobby
WinShow, ahk_id%lobbyid%
WinMove, ahk_id%lobbyid%,,0,0
return

RegSNGexec(id, times, scrldwn) {
global RegSofar
global Register
global OpenTables
global KeepOpen
global TotalLimit
global RegButton
global AutoIfFull
global list,lobbytitle,lobbyid,PS7list1,PS7list2,PS6list

Loop %times%
{
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
ControlSend, %list%, {NumpadUp 20}, ahk_id%id%
If (OpenTables >= KeepOpen)
Exit
If (OpenTables >= TotalLimit)
Exit
ClickdirectionCount=0
direction=0
GuiControl, , Status, Status: Registering ;TEST
Loop 16
{
If (Register=0)
{
GuiControl, , Status, Status: Idle ;TEST
Exit
}
ControlGet, v, Visible, , %regButton%, ahk_id%id%
If (v = 0)
If (scrldwn!="Off")
{
If (ClickdirectionCount<scrldwn) {
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
If (direction=0) {
ControlSend, %list%, {NumpadDown}, ahk_id%id%
} Else {
ControlSend, %list%, {NumpadUp}, ahk_id%id%
}
ClickdirectionCount:=ClickdirectionCount+1
} Else {
If (direction=0) {
direction:=1
} Else {
direction:=0
}
ClickdirectionCount:=0
}
Sleep,1000
}
If ( v = 1 ) {
wingetclass,class,A
SetTitleMatchMode, 2
ControlSend, %regButton%, {Space}, ahk_id%id%
ControlSend, %regButton%, {Space}, ahk_id%id%
WinWait, Tournament Registration ahk_class #32770,,1
{
WinGet, regid, id, Tournament Registration ahk_class #32770
wingettext,text,
if instr(text,"Confirm")>0
{
autobtn=PokerStarsButtonClass3
okbtn=PokerStarsButtonClass2
}
else
{
autobtn=Button2
okbtn=PokerStarsButtonClass1
}
controlget,vis,visible,,%autobtn%,ahk_id%regid%
if vis
{
 If (AutoIfFull = 1)
 {
 Control,Check,,%autobtn%, ahk_id%regid%
 ;ControlSend, %autobtn%, {Space}, ahk_id%regid%
 Sleep, 30
 }
ControlSend, %okbtn%, {Space}, ahk_id%regid%
}
}
sleep,30
WinWait, Tournament Registration ahk_class #32770,,1
{
WinGet, regid, id, Tournament Registration ahk_class #32770
controlget,vis,visible,,Button2,ahk_id%regid%
controlget,vis1,visible,,PokerStarsButtonClass3,ahk_id%regid%
if !vis && !vis1
winclose,ahk_id%regid%
;ControlSend, PokerStarsButtonClass1, {Space}, ahk_id%regid%
}
GuiControl, , Status, Status: Waiting ;TEST
;if class=PokerStarsTableFrameClass
;winactivate,ahk_class PokerStarsTableFrameClass
Break
}
}
}
}
return

AutoReg:
AutoReg()
return

AutoReg()
{
global AutoIfFull
setwindelay,-1
settitlematchmode,2
IfWinExist, Tournament Registration ahk_class #32770
{
wingettext,text,
if instr(text,"Confirm")>0
{
autobtn=PokerStarsButtonClass3
okbtn=PokerStarsButtonClass2
}
else
{
autobtn=Button2
okbtn=PokerStarsButtonClass1
}
winget,id,id,
controlget,vis,visible,,%autobtn%,ahk_id%id%
if vis
{
If (AutoIfFull = 1)
{
ControlFocus, %autobtn%, ahk_id%id%
Sleep, -1
ControlSend, %autobtn%, {Space}, ahk_id%id%
Sleep, 30
}
ControlSend, %okbtn%, {Space}, ahk_id%id%
}
else
ControlSend, %okbtn%, {Space}, ahk_id%id%
;winclose,ahk_id%id%
}
}
return

CountTourneys(mode=0) {
global logfile,RegSofar,regtourneys,tables,Targetnum
If (SetReg=1)
Return 0
log := CheckFile(logfile,mode)
Loop, Parse, log, `n,
{
tnumber=
if (instr(A_loopField,"RT add")>0)
{
 tnumber:=RegExReplace(A_loopField, "RT add ", "")
 if instr(tnumber,A_space)
 StringLeft, tnumber, tnumber, instr(tnumber,A_space)-1
 tnumber:=RegExReplace(tnumber, "[`n,`r]", "")
 tnumber:=Floor(tnumber)
 if !instr(tables,tnumber) && ((Targetnum=0) || ((Targetnum>0) && (tnumber>=(Targetnum-50000)) && (tnumber<(Targetnum+100000))))
 listadd(tables,tnumber)
}
else
If (instr(A_loopField,"RT remove")>0)
{
 stringtrimleft,tnumber,A_loopField,instr(A_loopField,A_space,"",0)
 tnumber:=RegExReplace(tnumber, "[`n,`r]", "")
 tnumber:=Floor(tnumber)
 if instr(tables,tnumber)
 listDelItem(tables,tnumber)
}
}
log=
tcount:=0
Loop, Parse, tables, -,
{
if A_Loopfield is number
{
tcount++
if !(instr(regtourneys,A_Loopfield)>0)
{
listadd(regtourneys,A_Loopfield)
if mode=0
RegSofar++
}
}
}
return tcount
}

numcheck:
winget,nlist,list,Table ahk_class PokerStarsTableFrameClass
loop %nlist%
{
id:=nlist%A_index%
wingettitle,title,ahk_id%id%
stringtrimleft,num,title,instr(title,A_space,"",instr(title,"Tournament"))
stringleft,num,num,instr(num,A_space)-1
if num is not number
num:=0
if (num>targetnum)
targetnum:=num
StringReplace,targetnum,targetnum,A_space,,All
StringReplace,targetnum,targetnum,`n,,All
StringReplace,targetnum,targetnum,`r,,All
}
return

Ansi2Unicode(sString, CP = 0)
{
	  nSize := DllCall("MultiByteToWideChar"
		, "Uint", CP
		, "Uint", 0
		, "Uint", &sString
		, "int",  -1
		, "Uint", 0
		, "int",  0)

	VarSetCapacity(wString, nSize * 2)

	DllCall("MultiByteToWideChar"
		, "Uint", CP
		, "Uint", 0
		, "Uint", &sString
		, "int",  -1
		, "Uint", &wString
		, "int",  nSize)
return wstring
}

ReplaceByte( hayStackAddr, hayStackSize, ByteFrom=0, ByteTo=1, StartOffset=0, NumReps=-1)
{	Static fun
	IfEqual,fun,
	{
		h=
		( LTrim join
			5589E553515256579C8B4D0C8B451831D229C17E25837D1C00741F8B7D0801C70FB6451
			00FB65D14FCF2AE750D885FFF42FF4D1C740409C975EF9D89D05F5E5A595BC9C21800
		)
		VarSetCapacity(fun,StrLen(h)//2)
		Loop % StrLen(h)//2
			NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char")
	}
	Return DllCall(&fun
		, "uint",haystackAddr, "uint",hayStackSize, "short",ByteFrom, "short",ByteTo
		, "uint",StartOffset, "int",NumReps)
}

CheckFile(File, mode=0) {
   ; THX Sean for File.ahk : http://www.autohotkey.com/forum/post-124759.html
   Static CF := ""   ; Current File
   Static FP := 0    ; File Pointer
   Static OPEN_EXISTING := 3
   Static GENERIC_READ := 0x80000000
   Static FILE_SHARE_READ := 1
   Static FILE_SHARE_WRITE := 2
   Static FILE_SHARE_DELETE := 4
   Static FILE_BEGIN := 0
   BatchLines := A_BatchLines
   SetBatchLines, -1
   If (File != CF) {
      CF := File
      FP := 0
   }
   hFile := DllCall("CreateFile"
                  , "Str",  File
                  , "Uint", GENERIC_READ
                  , "Uint", FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE
                  , "Uint", 0
                  , "Uint", OPEN_EXISTING
                  , "Uint", 0
                  , "Uint", 0)
   If (!hFile) {
      CF := ""
      FP := 0
      SetBatchLines, %BatchLines%
      Return False
   }
   DllCall("GetFileSizeEx"
         , "Uint",   hFile
         , "Int64P", nSize)
   if mode=1
   FP:=1
   If (FP = 0 Or nSize <= FP) {
      FP := nSize
      SetBatchLines, %BatchLines%
      DllCall("CloseHandle", "Uint", hFile) ; close file
     Return False
   }
   DllCall("SetFilePointerEx"
         , "Uint",  hFile
         , "Int64", FP
         , "Uint",  0
         , "Uint",  FILE_BEGIN)
   VarSetCapacity(Tail, Length := nSize - FP, 0)
   DllCall("ReadFile"
         , "Uint",  hFile
         , "Str",   Tail
         , "Uint",  Length
         , "UintP", Length
         , "Uint",  0)
   DllCall("CloseHandle", "Uint", hFile)
   FP := nSize
   if A_IsUnicode
   {
   tail:=Ansi2Unicode(tail)
   Length:=strlen(tail)
   }
   ReplaceByte( &Tail, Length)
   VarSetCapacity(Tail, -1)
   SetBatchLines, %BatchLines%
   Return Tail
}

listAdd( byRef list, item, del="-" ) {
  list:=( list!="" ? ( list . del . item ) : item )
  return list
}

listDelItem( byRef list, item, del="-") {
  ifEqual, item,, return list
  list:=del . list . del
  StringReplace, list, list, %del%%item%%del%,%del%,All
  StringTrimLeft, list, list, 1
  StringTrimRight, list, list, 1
  return list
}

lobbyStars() {
SetTitleMatchMode 2
WinGet, id, id, PokerStars Lobby ahk_class #32770,,Tournament
Return id
}

;~^!Q::
;ExitApp

exitsub:
if Targetnum>0
IniWrite, %Targetnum%, %thisahk%.ini, Settings, Targetnum
exitapp
return
AHK script:Stars Filtered SNG Opener Quote
04-17-2015 , 06:46 AM
Max1mums, whats up?
im thespecial12, u should know, the super fish
AHK script:Stars Filtered SNG Opener Quote
04-17-2015 , 08:49 AM
RobengoSini, hey.
AHK script:Stars Filtered SNG Opener Quote
04-17-2015 , 11:18 AM
Thanks a lot !
AHK script:Stars Filtered SNG Opener Quote
05-05-2015 , 01:53 PM
is it possible to use this software on full tilt? they dont have filters for different buy ins , so its kinda impossible to pin point the specific games you want with the script , any ideas?
AHK script:Stars Filtered SNG Opener Quote
06-11-2015 , 01:36 PM
Hi all,

This is an updated version of the script posted before.

also on sourceforge: autoreg dot sourceforge dot net

It now handles the issue of "Register" Button Class
It can also Check if Sitting Out and Go Back

Please let me know of any issues

Tried to create a new thread (AHK script:PS SnG autoregister) but have no permission.


; autoreg.ahk
; a simple poker stars auto register script by castor_ades7
; based on/inspired by SFSO_4.01b.ahk
; Thanks go to: Everlong@2p2, _dave_, chris228, finnisher, Max1mums

; ================================================== ======================
; Log in before starting the script
; In Lobby, activate "Show registering/upcoming only"
; In Lobby, use "Games View"
; Choose the "Classic" Table Theme
; Do not minimize PokerStars Lobby, just move it out of the way
; Enable option: Allow registration(s) without showing Buy-In dialog
; It is suggested that:
; PokerStars hotkeys are used and Go to 'First Action' Table = SPACE
; Tested with PS7 Classic Theme for SnG tournaments, Favorites via filters
;
; on Getting the "Register" Button Class
; value is obtained at initial start of script
; value may change during play, hence it is suggested to keep the "Auto"
; option, to check the current value automatically, every so often
;
; user may change some options in script:
; "User defined variables" at around line 70 onwards
; Gui "Checked" options at around line 110 onwards
; hotkeys at end of script
;
; on Check if Sitting Out and Go Back
; there are two methods to do this automatically:
; - Auto: via checking the current table window
; - Auto_hh: via checking the hand history if hero is sitting out
; ================================================== ======================

Code:
; vim: set foldmethod=marker:  

; autoreg.ahk
; a simple poker stars auto register script by castor_ades7
; based on/inspired by SFSO_4.01b.ahk
; Thanks go to: Everlong@2p2, _dave_, chris228, finnisher, Max1mums

; ========================================================================
; Log in before starting the script 
; In Lobby, activate "Show registering/upcoming only"
; In Lobby, use "Games View"
; Choose the "Classic" Table Theme
; Do not minimize PokerStars Lobby, just move it out of the way
; Enable option: Allow registration(s) without showing Buy-In dialog	
; It is suggested that: 
;  PokerStars hotkeys are used and Go to 'First Action' Table = SPACE
; Tested with PS7 Classic Theme for SnG tournaments, Favorites via filters
;
; on Getting the "Register" Button Class
;  value is obtained at initial start of script
;  value may change during play, hence it is suggested to keep the "Auto"
;   option, to check the current value automatically, every so often
; 
; user may change some options in script:
;  "User defined variables" at around line 70 onwards
;  Gui "Checked" options at around line 110 onwards
;  hotkeys at end of script
;
; on Check if Sitting Out and Go Back
;  there are two methods to do this automatically:
;  - Auto: via checking the current table window
;  - Auto_hh: via checking the hand history if hero is sitting out
; ========================================================================

; init {{{
#NoEnv
#SingleInstance, Force
#WinActivateForce
SendMode Input
SetWorkingDir %A_ScriptDir%
SetBatchLines, -1
SetTitleMatchMode, 2
StringTrimRight, thisahk, A_ScriptName, 4
regButton := "PokerStarsButtonClass999"
unregButton := "PokerStarsButtonClass997"
regList := "PokerStarsListClass12"
unregAll_selBtn := "PokerStarsButtonClass1"
unregAll_unregBtn := "PokerStarsButtonClass3"
AutoRegister := 0
AutoRegister_prev := 0
AutoAutoClose := 0
AutoInfoTab := 0
AutoSittingOut := 0
AutoSittingOut_hh := 0
AutoWindowMaximize := 0
AutoActivateTableWin := 0
AutoGetRegButtonClass := 0
ct_Tables_Now := 0 ; number of open tables currently
ct_Tables_SoFar := 0 ; number of tables so far, since start of script
window_position_to_move := "Center"
ScriptStarted := 0
LogFile := "autoreg_" A_Now ".log"
Hero_Name := "noname" ; set in StartScript from lobby
so_tables_already_clicked_count := 0 ; sitting out
it_tables_already_clicked_count := 0 ; info tab
ct_tables_already_counted_count := 0 ; count tables
Register_in_progress := 0

; ----------------------
; User defined variables
; ----------------------
MaxTablesInit:=6 ; Maximum number of Tables to keep open, Initial value
AutoCloseInterval:=50 ; Check if any and close "confirm" windows every X msec
RegisterInterval:=30*1000 ; Register every X millisec
GetRegButtonClassInterval:=10*60*1000 ; Check Register Class every X millisec
MaxTimesToReg:=6 ; Maximum number of registrations per interval
SittingOut:=10 ; Check active table window if Sitting Out every X millisec 
SittingOut_hh:=5*1000 ; Check if Sitting Out every X millisec via hh
WindowMaximize:=2*1000 ; Check and Maximize all table Windows every X millisec
ActivateTableWinTime:=10*1000 ; Activate a Table  Window every X millisec
InfoTab:=200 ; Check active table win if InfoTab was clicked, every X millisec
CountTables:=3*1000 ; Count physical tables every X millisec
IdleTime:=10*60*1000 ; PauseScript and UnRegisterAll, if Idle for X millisec
MaxTablesSoFar:=500 ; Maximum number of total registered tables so far
SafeguardInterval:=1*60*1000 ; Do safeguard checks every X millisec
Path_to_HH:="C:\Program Files\PokerStars\HandHistory\" 
alt_Path_to_HH := "C:\HandHistory\"
; Path_to_HH is combined with Hero_Name in StartScript
; Hand histories are used to check if hero is sitting out
; ----------------------
; ----------------------

ifExist, %alt_Path_to_HH%
	Path_to_HH := alt_Path_to_HH

if (SafeguardInterval>0)
	Sleep, 37
	SetTimer, Safeguard, %SafeguardInterval%
Gosub, BuildGui
Return
; }}}

QuitScript: ; {{{
ExitApp
Return ; }}}

GuiClose: ; {{{
ExitApp
Return ; }}}

BuildGui: ; {{{
Gui, Color, White
Gui, Font, cOlive
Gui, Add, Text, x10 y12, Max Number of Open Tables:
Gui, Add, Edit, x155 y10 w42
Gui, Add, UpDown, vMaxTables, %MaxTablesInit%
Gui, Add, GroupBox, x5 y30 w92 h130,
Gui, Add, Button, x10 y40 w80 gStartScript
					, &[S]tart
Gui, Add, Text, x100 y45, Submit and start/continue script
Gui, Add, Button, x10 y70 w80 gUnRegisterAll
					, &S[T]op
Gui, Add, Text, x100 y75, Un-register all and stop registering
Gui, Add, Button, x10 y100 w80 gPauseScript
					, &[P]ause
Gui, Add, Text, x100 y105, Cancel all automated functions
Gui, Add, Button, x10 y130 w80 gQuitScript
					, &[Q]uit
Gui, Add, Text, x100 y135, Exit script and close window
Gui, Add, Checkbox, x10 y160 vSpaceG2FAT Checked
   , &PokerStars hotkeys are used and`nSPACE goes to "First Action" Table
Gui, Add, Button, x10 y190 w190 gSittingOut_via_button
					, &Check all if Sitting [O]ut and Go Back
Gui, Add, Checkbox, x205 y190 vAutoSittingOut Checked, &Auto
Gui, Add, Checkbox, x205 y202 vAutoSittingOut_hh Checked, &Auto_hh
Gui, Add, Button, x10 y220 w190 gInfoTab_via_button
					, &Check all if [I]nfo Tab is selected
Gui, Add, Checkbox, x205 y225 vAutoInfoTab, &Auto
Gui, Add, Button, x10 y250 w190 gInfoTab_via_button_active
					, &Click In(f)o Tab on active table
Gui, Add, Button, x10 y280 w190 gWindowMaximize_via_button
					, &Maximize all Table [W]indows
Gui, Add, Checkbox, x205 y285 vAutoWindowMaximize Checked, &Auto
Gui, Add, Button, x10 y310 w190 gActivateTableWin_via_button
					, &[A]ctivate a Table Window 
Gui, Add, Checkbox, x205 y315 vAutoActivateTableWin, &Auto
Gui, Add, Button, x10 y340 w190 gAutoClose_via_button
					, &Close small confirmation windows
Gui, Add, Checkbox, x205 y345 vAutoAutoClose Checked, &Auto
Gui, Add, Button, x10 y370 w190 gGetRegButtonClassViaButton
					, &Get Register Button Class
Gui, Add, Checkbox, x205 y375 vAutoGetRegButtonClass Checked, &Auto
Gui, Add, Button, x10 y400 w190 gMoveLobbyInOut
					, &Move [L]obby In/Out of Screen
Gui, Add, Text, x10 w255 cBlue
		, hotkeys: Ctl + Alt + letter_in_brackets`nOR letter_in_parentheses
Gui, Add, Text, w255 cGreen vStatus, Status: Idle
Gui, Add, Text, w255 cBlack vInfo1, n/a
Gui, Add, Text, w255 cBlack vInfo2, n/a
Gui, Add, Text, w255 cBlack vInfo3, n/a
Gui, Add, Text, w255 cBlack vInfo4, n/a
Gui, Add, Text, w255 cRed vInfo_Reg
	          , Registered now/total: %ct_Tables_Now%/%ct_Tables_SoFar%
Gui, Show, w265, %thisahk%
Gui, Show, x0 y0, %thisahk%
Sleep, -1
Gosub, Wait 
Return ; }}}

Safeguard: ; {{{
if ((A_TimeIdle > IdleTime) OR (ct_Tables_SoFar > MaxTablesSoFar))
{
	Gosub, UnRegisterAll
	GuiControl,, Status, Status: Stop registering due to safeguard
	FileAppend, %A_Now% Stop registering due to safeguard `n, %LogFile%
}
Return ; }}}

Wait: ; {{{
GuiControl,, Status, Status: Waiting
Return ; }}}

PauseScript: ; {{{
AutoRegister:=0
AutoAutoClose:=0
AutoInfoTab:=0
AutoSittingOut:=0
AutoSittingOut_hh:=0
AutoWindowMaximize:=0
AutoActivateTableWin:=0
AutoGetRegButtonClass:=0
GuiControl,, Status, Status: Script Paused
FileAppend, %A_Now% Script Paused `n, %LogFile%
Return ; }}}

StartScript: ; {{{
GuiControl,, Status, Status: Started/Continued on %A_Hour%:%A_Min%:%A_Sec%
FileAppend, %A_Now% Script Started/Continued `n, %LogFile%
Gui, Submit, NoHide ; update all AutoX switches
AutoRegister := 1
WinGet, LobbyId, Id, PokerStars Lobby ahk_class #32770
if !LobbyId {
	GuiControl,, Status, Status: PokerStars Lobby not found
	FileAppend, %A_Now% PokerStars Lobby not found `n, %LogFile%
	Return
}
WinActivate, ahk_id%LobbyId%
DetectHiddenText, On
SetTitleMatchMode, Slow
WinGetText, Lobby_Txt, ahk_id%LobbyId%
SetTitleMatchMode, Fast
StringMid, Lobby_Txt_short, Lobby_Txt, 1, 64
StringSplit, Lobby_Txt_split, Lobby_Txt_short, `n, `r
Hero_Name := Lobby_Txt_split1
Path_to_hero_HH := Path_to_HH Hero_Name "\*.txt"
GuiControl,, Info1, %A_Hour%:%A_Min%:%A_Sec% Hero_Name: %Hero_Name%
if !ScriptStarted
{
	Gosub, GetRegButtonClassViaButton
	Sleep, 3000
	if (CountTables>0)
		SetTimer, CountTables, %CountTables%
	Sleep, 37
	if (AutoCloseInterval>0)
		SetTimer, AutoClose, %AutoCloseInterval%
	Sleep, 37
	if (InfoTab>0)
		SetTimer, InfoTab, %InfoTab%
	Sleep, 37
	if (SittingOut>0)
		SetTimer, SittingOut, %SittingOut%
	Sleep, 37
	if (SittingOut_hh>0)
		SetTimer, SittingOut_hh, %SittingOut_hh%
	Sleep, 37
	if (WindowMaximize>0)
		SetTimer, WindowMaximize, %WindowMaximize%
	Sleep, 37
	if (ActivateTableWinTime>0)
		SetTimer, ActivateTableWin, %ActivateTableWinTime%
	Sleep, 37
	if (GetRegButtonClassInterval>0) {
		Gosub, GetRegButtonClass
		SetTimer, GetRegButtonClass, %GetRegButtonClassInterval%
	}
	Sleep, 37
	if (RegisterInterval>0) {
		Gosub, Register
		SetTimer, Register, %RegisterInterval%
	}
	FileAppend, %A_Now% Script Initial Start `n, %LogFile%
	ScriptStarted := 1
	Sleep, -1
}
Sleep, -1
Return ; }}}

ActivateTableWin: ; {{{
if AutoActivateTableWin
	ActivateTableWin()
Return
ActivateTableWin_via_button:
ActivateTableWin()
Return
ActivateTableWin() {
	Global SpaceG2FAT
	SetTitleMatchMode, 2
	if !SpaceG2FAT {
		WinActivate, Table ahk_class PokerStarsTableFrameClass
		Return
	}
	WinGetTitle, active_win_title, A
	IfInString, active_win_title, Table
		SendInput, {Space} ; Go to 'First Action' Table
	else {
		WinActivate, Table ahk_class PokerStarsTableFrameClass
		WinGetTitle, active_win_title, A
		IfInString, active_win_title, Table
			SendInput, {Space} ; Go to 'First Action' Table
	}
}
Return ; }}}

Register: ; {{{
if AutoRegister
	Register()
Return
SetListClass()
{
	Global ; all variables of this function will be globals
	SetTitleMatchMode, 2
	ControlGet, gh_vis, Visible,, PokerStarsHeaderClass15, ahk_id%rg_LobbyId%
	if gh_vis
		regList := "PokerStarsListClass12"
	else
		regList := "PokerStarsListClass13"
	Sleep, -1
}
Return
Register()
{
	Global ; all variables of this function will be globals
	SetTitleMatchMode, 2
	Register_in_progress := 1
	WinGet, rg_LobbyId, Id, PokerStars Lobby ahk_class #32770
	if !rg_LobbyId {
		GuiControl,, Status, Status: PokerStars Lobby not found
		FileAppend, %A_Now% PokerStars Lobby not found `n, %LogFile%
		Return
	}
	if (ct_Tables_Now >= MaxTables) {
		GuiControl,, Status, Status: Set Full at %ct_Tables_Now% tables_Waiting
		FileAppend, %A_Now% registering: set full %ct_Tables_Now% `n, %LogFile%
		Return
	}
	rg_TimesToReg := MaxTables - ct_Tables_Now 
	if (rg_TimesToReg > MaxTimesToReg) 
		rg_TimesToReg := MaxTimesToReg
	GuiControl,, Status, Status: Registering %rg_TimesToReg%
	FileAppend, %A_Now% registering %rg_TimesToReg% tables_now:%ct_Tables_Now% `n, %LogFile%
	SetListClass()
	ControlSend, %regList%, {PgUp}, ahk_id%rg_LobbyId%
	Loop %rg_TimesToReg%
	{
		Sleep, 1000
		ControlGet, rg_regBtnVis, Visible,, %regButton%, ahk_id%rg_LobbyId%
		if (rg_regBtnVis == 1) {
			GuiControl,, Status, %A_Index%/%rg_TimesToReg% NewRegistration
			FileAppend, %A_Now% reg_NewRegistration %A_Index%/%rg_TimesToReg% `n, %LogFile%
			ControlSend, %regButton%, {Space}, ahk_id%rg_LobbyId%
			ControlSend, %regButton%, {Space}, ahk_id%rg_LobbyId%
		} else {
			ControlGet, rg_unregBtnVis
				      , Visible,, %unregButton%, ahk_id%rg_LobbyId%
			if (rg_unregBtnVis == 1) {
				GuiControl,, Status, %A_Index%/%rg_TimesToReg% RegisteredAlready
				FileAppend, %A_Now% reg_AlreadyRegistered %A_Index%/%rg_TimesToReg% `n, %LogFile%
			} else {
				GuiControl,, Status, %A_Index%/%rg_TimesToReg% NoGameFound
				FileAppend, %A_Now% reg_NoGameFound %A_Index%/%rg_TimesToReg% `n, %LogFile%
			}
		}
		SetListClass()
		ControlSend, %regList%, {NumpadDown}, ahk_id%rg_LobbyId%
		ActivateTableWin() 
	}
	Register_in_progress := 0
	Sleep, -1
}
Return ; }}}

GetRegButtonClass: ; {{{
if AutoGetRegButtonClass
	GetRegButtonClass()
Return
GetRegButtonClassViaButton:
	GetRegButtonClass()
Return
GetRegButtonClass()
{
	Global ; all variables of this function will be globals
	SetTitleMatchMode, 2
	if Register_in_progress
	{
		GuiControl,, Info3, %A_Hour%:%A_Min%:%A_Sec% Register_in_progress_Try_later
		FileAppend, %A_Now% Register_in_progress_Try_later `n, %LogFile%
		Return
	}

	GuiControl,, Info3, %A_Hour%:%A_Min%:%A_Sec% Getting reg btn class Wait 5 seconds
	WinGet, bc_LobbyId, Id, PokerStars Lobby ahk_class #32770
	if !bc_LobbyId
	{
		GuiControl,, Status, Status: PokerStars Lobby not found
		FileAppend, %A_Now% PokerStars Lobby not found `n, %LogFile%
		Return
	}

	AutoRegister_prev := AutoRegister
	AutoRegister := 0
	Sleep, 30
	Sleep, -1

	WinGetPos, bc_x, bc_y, bc_w, bc_h, ahk_id%bc_LobbyId%
	WinMove, ahk_id%bc_LobbyId%,, (-765), 245, 935, 597
	MouseGetPos, bc_mouse_x_init, bc_mouse_y_init
	WinActivate, ahk_id%bc_LobbyId% 
	Sleep, 30
	MouseMove, 815, 525, 0
	MouseGetPos,,,, bc_regButton1
	Click, 815, 525
	Sleep, 30
	MouseMove, bc_mouse_x_init, bc_mouse_y_init, 0
	WinMove, ahk_id%bc_LobbyId%,, bc_x, bc_y, bc_w, bc_h
	StringTrimRight, bc_string1, bc_regButton1, 3
	bc_string := bc_string1
	if (bc_string != "PokerStarsButtonClass")
	{
		FileAppend, %A_Now%:failed_to_get_PokerStarsButtonClass_keep_old `n
				  , %LogFile%
		GuiControl,,Info3, %A_Hour%:%A_Min%:%A_Sec%_keep_old_reg:%regButton%
		GuiControl,,Info4, %A_Hour%:%A_Min%:%A_Sec%_keep_old_unreg:%unregButton%
	} else
	{
		ActivateTableWin()
		Sleep, 5000

		WinGetPos, bc_x, bc_y, bc_w, bc_h, ahk_id%bc_LobbyId%
		WinMove, ahk_id%bc_LobbyId%,, (-765), 245, 935, 597
		MouseGetPos, bc_mouse_x_init, bc_mouse_y_init
		WinActivate, ahk_id%bc_LobbyId% 
		Sleep, 30
		MouseMove, 815, 525, 0
		MouseGetPos,,,, bc_regButton2
		MouseMove, bc_mouse_x_init, bc_mouse_y_init, 0
		WinMove, ahk_id%bc_LobbyId%,, bc_x, bc_y, bc_w, bc_h
		StringTrimRight, bc_string2, bc_regButton2, 3
		bc_string := bc_string2
		if (bc_string != "PokerStarsButtonClass")
		{
			FileAppend, %A_Now%:failed_to_get_PokerStarsButtonClass_keep_old2 `n
					  , %LogFile%
			GuiControl,,Info3
					  , %A_Hour%:%A_Min%:%A_Sec%_keep_old_reg2:%regButton%
			GuiControl,,Info4
					  , %A_Hour%:%A_Min%:%A_Sec%_keep_old_unreg2:%unregButton%
		} else
		{
			StringRight, bc_number1, bc_regButton1, 3
			StringRight, bc_number2, bc_regButton2, 3
			if (bc_number1 == bc_number2)
			{
				FileAppend, %A_Now%:failed_to_get_PokerStarsButtonClass_keep_old3 `n , %LogFile%
				GuiControl,,Info3
					  , %A_Hour%:%A_Min%:%A_Sec%_keep_old_reg2:%regButton%
				GuiControl,,Info4
					  , %A_Hour%:%A_Min%:%A_Sec%_keep_old_unreg2:%unregButton%
			} else
			{
				bc_number := bc_number1 > bc_number2 ? bc_number1 : bc_number2
				regButton := bc_string . bc_number
				unregButton := bc_string . ( bc_number - 2 )
				FileAppend, %A_Now%:reg_unregButton:%regButton%_%unregButton% `n
				      , %LogFile%
				GuiControl,, Info3, %A_Hour%:%A_Min%:%A_Sec%_reg:%regButton%
				GuiControl,, Info4, %A_Hour%:%A_Min%:%A_Sec%_unreg:%unregButton%
			}
		}
	}

	AutoRegister := AutoRegister_prev
	Sleep, -1
	ActivateTableWin()
}
Return ; }}}

UnRegisterAll: ; {{{
AutoRegister:=0
AutoGetRegButtonClass:=0
GuiControl,, Status, Status: Stop Registering
if ScriptStarted
	UnRegisterAll()
else
	GuiControl,, Status, Status: Need to press Submit first
Return 
UnRegisterAll() {
	Global regList
	Global unregAll_selBtn
	Global unregAll_unregBtn
	Global LogFile
	SetTitleMatchMode,2
	WinGet, LobbyId, id, PokerStars Lobby ahk_class #32770
	if !LobbyId
	{
		GuiControl,, Status, Status: PokerStars Lobby not found
		FileAppend, %A_Now% PokerStars Lobby not found `n, %LogFile%
		Return
	}
	SetListClass()
	ControlSend, %regList%, ^r, ahk_id%lobbyid%
	WinWait, Registered In Tournaments ahk_class #32770,, 1
	{
		WinGet, regid, Id, Registered In Tournaments ahk_class #32770
		ControlGet, vis, Visible,, %unregAll_selBtn%, ahk_id%regid%
		if vis {
			ControlSend, %unregAll_selBtn%, {Space}, ahk_id%regid%
			Sleep, 30
			ControlSend, %unregAll_unregBtn%, {Space}, ahk_id%regid%
			Sleep, 30
		}
		WinClose, ahk_id%regid%
	}
	ActivateTableWin()
}
Return ; }}}

AutoClose: ; {{{
if AutoAutoClose
	AutoClose()
Return
AutoClose_via_button:
AutoClose()
Return
AutoClose() 
{
	Global AutoRegister
	Global LogFile
	a_win_was_closed:=0
	SetTitleMatchMode,2
	ifWinExist, Tournament Registration ahk_class #32770 
	{
		WinGet, id1, id, ; Automatically uses the window found above
		ControlGetText, btn_text, PokerStarsButtonClass1, ahk_id%id1%
		if !(btn_text = "OK")
		{
			AutoRegister := 0
			FileAppend
			, %A_Now% Registration not OK _ Stop Registering `n, %LogFile%
			GuiControl,, Info3
			, %A_Hour%:%A_Min%:%A_Sec% Registration not OK _ Stop Registering
		}
		WinGetTitle, title_id1, ahk_id%id1%
		WinClose, ahk_id%id1%
		GuiControl,, Info2, %A_Hour%:%A_Min%:%A_Sec% closed: %title_id1%
		a_win_was_closed:=1
	}
	ifWinExist, PokerStars ahk_class #32770,, Lobby 
	{
		; closes any PokerStars window that pops up, except Lobby
		WinGet, id2, id,
		WinMove, ahk_id%id2%,, A_ScreenWidth, 0
		WinGetTitle, title_id2, ahk_id%id2%
		GuiControl,, Info3, %A_Hour%:%A_Min%:%A_Sec% closed: %title_id2%
		FileAppend, %A_Now% closed_win %title_id2% `n, %LogFile%
		a_win_was_closed:=2
	}
	ifWinExist, News,,
	{
		if a_win_was_closed < 2
		{
			WinGet, id2, id,
			WinMove, ahk_id%id2%,, A_ScreenWidth, 0
			WinGetTitle, title_id2, ahk_id%id2%
			GuiControl,, Info3, %A_Hour%:%A_Min%:%A_Sec% closed: %title_id2%
			FileAppend, %A_Now% closed_win %title_id2% `n, %LogFile%
			a_win_was_closed:=2
		}
	}
	if a_win_was_closed 
		ActivateTableWin()
	if a_win_was_closed = 2
	{
		; saves the image of the non-tournament-registration closed window 
		; to a file, in order to check later
		image_file_name := "ahk_closed_window_" A_Now ".bmp"
		; www.autohotkey.com/forum/viewtopic.php?t=35242
		WinGetPos,,, w, h, ahk_id%id2%
		hDC := Dllcall( "GetDC"
						, UInt, id2 )
		hCDC := Dllcall( "CreateCompatibleDC"
						 , UInt, hDC )
		hCBMP := Dllcall( "CreateCompatibleBitmap"
						  , UInt, hDC
						  , Int, w
						  , Int, h )
		DllCall( "SelectObject"
				 , UInt, hCDC
				 , UInt, hCBMP )
		DllCall( "PrintWindow"
				 , UInt, id2
				 , UInt, hCDC
				 , UInt, 0 )
		DllCall( "BitBlt"
				 , Int, hCDC
				 , Int, 0
				 , Int, 0
				 , Int, w
				 , Int, h
				 , Int, hDC
				 , Int, 0
				 , Int, 0
				 , Int, 0xCC0020 )
		hBM := DllCall( "CopyImage"
						, UInt, hCBMP
						, UInt, 0
						, Int, 0
						, Int, 0
						, UInt, 0x2000 )
		DllCall( "GetObject"
				 , Int, hBM
				 , Int, VarSetCapacity($,84)
				 , UInt, NumPut(0,$,40,"Short") - 42 )
		Numput( VarSetCapacity( BFH, 14, 0) + 40
				, Numput( (NumGet($, 44) + 54)
						  , Numput(0x4D42, BFH) - 2) + 4 )
		hF := DllCall( "CreateFile"
					   , Str, image_file_name
					   , UInt, 2**30
					   , UInt, 2
					   , Int, 0
					   , UInt, 2
					   , Int64, 0 )
		If hF > 0 
		{
			; BITMAPFILEHEADER
			DllCall( "WriteFile"
					 , UInt, hF
					 , UInt, &BFH
					 , UInt, 14
					 , IntP, 0
					 , Int, 0 ) 
			; BITMAPINFOHEADER
			DllCall( "WriteFile"
					 , UInt, hF
					 , UInt, &$ + 24
					 , UInt, 40
					 , IntP, 0
					 , Int, 0 )
			DllCall( "WriteFile"
					 , UInt, hF
					 , UInt,NumGet($, 20)
					 , UInt, NumGet($, 44)
					 , UIntP, BW
					 , Int, 0 )
			DllCall( "CloseHandle"
					 , UInt, hF )
		}
		DllCall( "DeleteObject"
				 , Int, hCBMP )
		DllCall( "ReleaseDC"
				 , Int, id2
				 , Int, hDC )
		DllCall( "DeleteDC"
				 , Int, hCDC )
		WinClose, ahk_id%id2%
	}
}
Return ; }}}

InfoTab: ; {{{ 
; looks at every active table on screen if info tab is selected, once
if AutoInfoTab
	InfoTab()
Return
InfoTab()
{
	Global ; all variables of this function will be globals
	it_found := 0
	SetTitleMatchMode, 2
	it_id := WinExist("A")
	WinGetTitle, it_active_win_title, ahk_id%it_id%
	IfNotInString, it_active_win_title, Table
		Return

	Loop %it_tables_already_clicked_count% {
		it_id_already_clicked := it_tables_already_clicked%A_Index%
		if (it_id = it_id_already_clicked) {
			it_found := 1
			Break
		}
	}
	if it_found
		Return

	WinGetPos,,, it_w, it_h, ahk_id%it_id%
	VarSetCapacity(it_rc, 16)
	DllCall("GetClientRect", "UInt", it_id, "UInt", &it_rc)
	it_client_w := NumGet(it_rc, 8, "Int")
	it_client_h := NumGet(it_rc, 12, "Int")
	VarSetCapacity(it_rc, 0)
	it_win_frame_sides := (it_w - it_client_w) / 2
	it_win_frame_top := it_h - it_client_h - it_win_frame_sides
	it_x := Round(0.244 * it_client_w) + it_win_frame_sides
	it_y := Round(0.77 * it_client_h) + it_win_frame_top
	MouseGetPos, it_mouse_x_init, it_mouse_y_init
	Click %it_x%, %it_y%
	MouseMove, it_mouse_x_init, it_mouse_y_init, 0
	Sleep, -1
	ActivateTableWin()
	it_tables_already_clicked_count  += 1
	it_tables_already_clicked%it_tables_already_clicked_count% := it_id
	Sleep, -1
}
Return ; }}}

InfoTab_via_button: ; {{{ 
; looks at every table if info tab is selected
InfoTab_via_button()
Return
InfoTab_via_button()
{
	activated := 0
	SetTitleMatchMode, 2
	WinGet, TableWindows, List, Table ahk_class PokerStarsTableFrameClass
	if TableWindows = 0
		Return
	Loop %TableWindows% {
		id := TableWindows%A_Index%
		WinGetPos,,, w, h, ahk_id%id%
		VarSetCapacity(rc, 16)
		DllCall("GetClientRect", "UInt", id, "UInt", &rc)
		client_w := NumGet(rc, 8, "Int")
		client_h := NumGet(rc, 12, "Int")
		VarSetCapacity(rc, 0)
		win_frame_sides := (w - client_w) / 2
		win_frame_top := h - client_h - win_frame_sides
		x := Round(0.243 * client_w)
		y := Round(0.77 * client_h)
		x := x + win_frame_sides
		y := y + win_frame_top
		ColorID:=0x003386
		WinActivate, ahk_id%id%
		activated := 1
		PixelSearch,,, x, y, x+1, y+1, ColorID, 20, ahk_id%id%, Fast
		if (ErrorLevel=0) {
			MouseGetPos, mouse_x_init, mouse_y_init
			Click %x%, %y%
			MouseMove, mouse_x_init, mouse_y_init, 0
			Sleep, -1
			activeid := WinExist("A")
			if (id != activeid) {
				; another window might have poped, press key again
				WinActivate, ahk_id%id%
				MouseGetPos, mouse_x_init, mouse_y_init
				Click %x%, %y%
				MouseMove, mouse_x_init, mouse_y_init, 0
				Sleep, -1
			}
		}
	}
	if activated
		ActivateTableWin()
	Sleep, -1
}
Return ; }}}

InfoTab_via_button_active: ; {{{ 
; presses info tab of currently active table window
InfoTab_via_button_active()
Return
InfoTab_via_button_active()
{
	Global LogFile

	; click at center of screen first
	;scr_x := A_ScreenWidth/2
	;scr_y := A_ScreenHeight/2
	;CoordMode, Mouse, Screen
	;MouseGetPos, mouse_x_init, mouse_y_init
	;Click %scr_x%, %scr_y% 
	;FileAppend, %A_Now% clicked_at %scr_x% %scr_y% `n, %LogFile%
	;MouseMove, mouse_x_init, mouse_y_init, 0
	;CoordMode, Mouse, Relative
	;Sleep, -1

	; Click on active window
	Click 10,10
	FileAppend, %A_Now% clicked_at 10 10 `n, %LogFile%

	SetTitleMatchMode, 2
	id := WinExist("A")
	WinGetTitle, win_title, ahk_id%id%
	IfNotInString, win_title, Table
	{
		WinActivate, Table ahk_class PokerStarsTableFrameClass
		WinGetTitle, active_win_title, A
		IfInString, active_win_title, Table
			id := WinExist("A")
		else
			Return
	}
	WinGetPos,,, w, h, ahk_id%id%
	VarSetCapacity(rc, 16)
	DllCall("GetClientRect", "UInt", id, "UInt", &rc)
	client_w := NumGet(rc, 8, "Int")
	client_h := NumGet(rc, 12, "Int")
	VarSetCapacity(rc, 0)
	win_frame_sides := (w - client_w) / 2
	win_frame_top := h - client_h - win_frame_sides
	x := Round(0.243 * client_w) + win_frame_sides
	y := Round(0.77 * client_h) + win_frame_top
	MouseGetPos, mouse_x_init, mouse_y_init
	Click %x%, %y%
	MouseMove, mouse_x_init, mouse_y_init, 0
	FileAppend, %A_Now% info_tab_pressed`n, %LogFile%
	Sleep, -1
	ActivateTableWin()
	Sleep, -1
}
Return ; }}}

SittingOut: ; {{{ 
; looks at every active table on screen if hero is sitting out
if AutoSittingOut
	SittingOut()
Return
SittingOut()
{
	activated := 0
	SetTitleMatchMode, 2
	id := WinExist("A")
	WinGetTitle, active_win_title, ahk_id%id%
	IfNotInString, active_win_title, Table
		Return

	WinGetPos,,, w, h, ahk_id%id%
	VarSetCapacity(rc, 16)
	DllCall("GetClientRect", "UInt", id, "UInt", &rc)
	client_w := NumGet(rc, 8, "Int")
	client_h := NumGet(rc, 12, "Int")
	VarSetCapacity(rc, 0)
	win_frame_sides := (w - client_w) / 2
	win_frame_top := h - client_h - win_frame_sides
	x := Round(0.0143939 * client_w) + win_frame_sides
	y := Round(0.6967033 * client_h) + win_frame_top
	ColorID:=0x000000
	PixelSearch,,, x, y, x+1, y+1, ColorID, 0, ahk_id%id%, Fast
	if (ErrorLevel = 0) {
		x := Round(0.71 * client_w) + win_frame_sides
		y := Round(0.85 * client_h) + win_frame_top
		PixelSearch,,, x, y, x+1, y+1, ColorID, 0, ahk_id%id%, Fast
		if (ErrorLevel = 0) {
			MouseGetPos, mouse_x_init, mouse_y_init
			Click %x%, %y%
			MouseMove, mouse_x_init, mouse_y_init, 0
			GuiControl,, Info4, %A_Hour%:%A_Min%:%A_Sec% pressed i_am_back
			activated := 1
			Sleep, -1
		}
	}
	if activated
		ActivateTableWin()
	Sleep, -1
}
Return ; }}}

SittingOut_hh: ; {{{ 
; looks at hh files if hero is sitting out
if AutoSittingOut_hh
	SittingOut_hh()
Return
SittingOut_hh()
{
	Global ; all variables of this function will be globals
	so_iamback_clicked := 0
	so_tables_to_be_clicked_count := 0
	Loop, %Path_to_hero_HH%, 0 ; {{{
	{
		; look into recent hand history files if hero is sitting out
		so_modification_interval := 5 ;check hh files modified in last X minutes
		so_CharCount := 4000 ; characters to read, starting at end of hh file
		so_time_var := A_Now
		EnvSub, so_time_var, %A_LoopFileTimeModified%, Minutes 
		if (so_time_var > so_modification_interval)
			Continue
		if (A_LoopFileSize < so_CharCount)
			so_CharCount := A_LoopFileSize - 1
		so_BytesToRead := VarSetCapacity(so_HH_String, so_CharCount)
		so_FileName = %A_LoopFileLongPath%
		so_GENERIC_READ = 0x80000000
		so_OPEN_EXISTING = 3
		so_FILE_SHARE_READ = 0x1
		so_FILE_SHARE_WRITE = 0x2
		so_hFile := DllCall("CreateFile"
							, str, so_FileName
							, UInt, so_GENERIC_READ
							, UInt, so_FILE_SHARE_WRITE
							, UInt, 0
							, UInt, so_OPEN_EXISTING
							, Uint, 0, UInt, 0)
		if not so_hFile {
			GuiControl,, Info1, Can't open "%so_FileName%" for reading
			Return
		}
		so_ret_val := DllCall("SetFilePointerEx" 
							  , "Uint", so_hFile 
							  , "Int64", -so_CharCount
							  , "UInt *", "NULL"
							  , "Int", 2)
		if not so_ret_val {
			GuiControl,, Info1, Can't create new file pointer
				Return
		}
		DllCall("ReadFile"
				, UInt, so_hFile
				, str, so_HH_String
				, UInt, so_BytesToRead
				, UIntP, so_BytesActuallyRead 
				, UInt, 0)
		DllCall("CloseHandle", UInt, so_hFile)
		StringGetPos, so_table_pos, so_HH_String, Table ', R
		if (so_table_pos < 0)
			Continue
		so_FoundPos := RegExMatch(so_HH_String, Hero_Name ".*is sitting out"
						 , so_outvar, StartingPosition = %so_table_pos%)
		if (so_FoundPos = 0)
			Continue

		; get tournament/window id and click on "I am back" button
		StringMid, so_tournament_id_string, so_HH_String, %so_table_pos%, 32
		StringSplit, so_tournament_id_split, so_tournament_id_string
		                                   , %A_Space%'%A_Tab%
		so_tournament_id := so_tournament_id_split3
		FileAppend, %A_Now% %so_tournament_id% %so_outvar% `n, %LogFile%
		SetTitleMatchMode,2
		WinGet, so_id, Id,%so_tournament_id% ahk_class PokerStarsTableFrameClass
		if so_id is not Number
			Continue

		so_tables_to_be_clicked_count += 1
		so_tables_to_be_clicked%so_tables_to_be_clicked_count%_id := so_id
		so_tables_to_be_clicked%so_tables_to_be_clicked_count%_trn := so_tournament_id
	} ; }}}
	Loop %so_tables_to_be_clicked_count% { ; {{{
		so_id := so_tables_to_be_clicked%A_Index%_id
		so_trn := so_tables_to_be_clicked%A_Index%_trn
		so_already_clicked := 0
		Loop %so_tables_already_clicked_count% {
			so_stored_id := so_tables_already_clicked%A_Index%_id
			so_stored_time := so_tables_already_clicked%A_Index%_time
			if ((so_stored_id = so_id) && (A_Now - so_stored_time < 100)) {
				so_already_clicked:= 1
				Break
			}
		}
		if so_already_clicked 
			Continue

		WinGetPos,,, so_w, so_h, ahk_id%so_id%
		VarSetCapacity(so_rc, 16)
		DllCall("GetClientRect", "UInt", so_id, "UInt", &so_rc)
		so_client_w := NumGet(so_rc, 8, "Int")
		so_client_h := NumGet(so_rc, 12, "Int")
		VarSetCapacity(so_rc, 0)
		so_win_frame_sides := (so_w - so_client_w) / 2
		so_win_frame_top := so_h - so_client_h - so_win_frame_sides
		so_x := Round(0.71 * so_client_w) + so_win_frame_sides
		so_y := Round(0.85 * so_client_h) + so_win_frame_top
		ControlClick, x%so_x% y%so_y%, ahk_id%so_id%,,,, Pos
		so_iamback_clicked := 1
		GuiControl,, Info4
		           , %A_Hour%:%A_Min%:%A_Sec% i_am_back on %so_trn%
		FileAppend, %A_Now% %so_trn% i_am_back `n, %LogFile%
		so_tables_already_clicked_count += 1
		so_tables_already_clicked%so_tables_already_clicked_count%_id := so_id
		so_tables_already_clicked%so_tables_already_clicked_count%_time := A_Now
		Sleep, -1
	}

	if so_iamback_clicked {
		ActivateTableWin()
	} ; }}}
	Sleep, -1
}
Return ; }}}

SittingOut_via_button: ; {{{ 
; looks at every table if hero is sitting out
SittingOut_via_button()
Return
SittingOut_via_button()
{
	activated := 0
	SetTitleMatchMode, 2
	WinGet, TableWindows, List, Table ahk_class PokerStarsTableFrameClass
	if TableWindows = 0
		Return
	Loop %TableWindows% {
		id := TableWindows%A_Index%
		WinGetPos,,, w, h, ahk_id%id%
		VarSetCapacity(rc, 16)
		DllCall("GetClientRect", "UInt", id, "UInt", &rc)
		client_w := NumGet(rc, 8, "Int")
		client_h := NumGet(rc, 12, "Int")
		VarSetCapacity(rc, 0)
		win_frame_sides := (w - client_w) / 2
		win_frame_top := h - client_h - win_frame_sides
		x := Round(0.0143939 * client_w) + win_frame_sides
		y := Round(0.6967033 * client_h) + win_frame_top
		ColorID:=0x000000
		WinActivate, ahk_id%id%
		activated := 1
		PixelSearch,,, x, y, x+1, y+1, ColorID, 0, ahk_id%id%, Fast
		if (ErrorLevel = 0) {
			x := Round(0.71 * client_w) + win_frame_sides
			y := Round(0.85 * client_h) + win_frame_top
			PixelSearch,,, x, y, x+1, y+1, ColorID, 0, ahk_id%id%, Fast
			if (ErrorLevel = 0) {
				MouseGetPos, mouse_x_init, mouse_y_init
				Click %x%, %y%
				MouseMove, mouse_x_init, mouse_y_init, 0
				Sleep, -1
				GuiControl,, Info4, %A_Hour%:%A_Min%:%A_Sec% pressed i_am_back
				activeid := WinExist("A")
				if (id != activeid) {
					; another window might have poped, press key again
					WinActivate, ahk_id%id%
					MouseGetPos, mouse_x_init, mouse_y_init
					Click %x%, %y%
					MouseMove, mouse_x_init, mouse_y_init, 0
					Sleep, -1
					GuiControl,, Info4
					, %A_Hour%:%A_Min%:%A_Sec% pressed i_am_back2
			   }
			}
		}
	}
	if activated
		ActivateTableWin()
	Sleep, -1
}
Return ; }}}

WindowMaximize: ; {{{
if AutoWindowMaximize
	WindowMaximize()
Return

WindowMaximize_via_button: 
WindowMaximize()
Return

WindowMaximize()
{
	; maximizes all table windows, useful for "Stack Tables" multitabling
	SetTitleMatchMode,2
	wmax := 0
	WinGet, TableWindows, List, Table ahk_class PokerStarsTableFrameClass
	if (TableWindows == 0)
		Return

	if (A_ScreenWidth > 1900) 
	{
		Loop %TableWindows%
		{
			id := TableWindows%A_Index%
			WinGetPos,,, w, h, ahk_id%id%
			if ( w < 1328)
			{
				PostMessage, 0x112, 0xF030,,, ahk_id%id%
				wmax:=1
			}
			Sleep, -1
		}
	} else
	{
		taskbar_h := 0
		WinGetPos,,,, taskbar_h, ahk_class Shell_TrayWnd
		if (taskbar_h > 70)
			taskbar_h := 0

		Loop %TableWindows%
		{
			id := TableWindows%A_Index%
			WinGetPos,,, w, h, ahk_id%id%
			if ((w<A_ScreenWidth AND w<1328) AND (h<(A_ScreenHeight-taskbar_h)))
			{
				PostMessage, 0x112, 0xF030,,, ahk_id%id%
				wmax:=1
			}
			Sleep, -1
		}
	}

	if wmax
		ActivateTableWin()
}
Return ; }}}

CountTables: ; {{{ 
CountTables()
Return
CountTables()
{
	Global ; all variables of this function will be globals
	ct_found := 0
	SetTitleMatchMode,2
	WinGet, ct_Tables_Now, List, Logged ahk_class PokerStarsTableFrameClass
	if (ct_Tables_Now = 0) {
		GuiControl,, Info_Reg
			, Registered now/total: %ct_Tables_Now%/%ct_Tables_SoFar%
		Return
	}
	Loop %ct_Tables_Now% {
		ct_id := ct_Tables_Now%A_Index%
		Loop %ct_tables_already_counted_count% {
			ct_id_already_counted := ct_tables_already_counted%A_Index%
			if (ct_id = ct_id_already_counted) {
				ct_found := 1
				Break
			}
		}
		if ct_found {
			ct_found := 0
			Continue		
		}
		ct_tables_already_counted_count  += 1
		ct_tables_already_counted%ct_tables_already_counted_count% := ct_id
	}
	ct_Tables_SoFar := ct_tables_already_counted_count
	GuiControl,, Info_Reg 
		, Registered now/total: %ct_Tables_Now%/%ct_Tables_SoFar%
}
Return ; }}}

WindowMove: ; {{{
WindowMove()
Return
WindowMove()
{
	Global window_position_to_move
	SetTitleMatchMode,2
	activeid := WinExist("A")
	WinGetTitle, active_win_title, ahk_id%activeid%
	IfInString, active_win_title, Table 
	{
		WinGetPos, X, Y, Width, Height, ahk_id%activeid%
		if (window_position_to_move == "Top_Right")
			WinMove, ahk_id%activeid%,, (A_ScreenWidth - Width), 0
		else if (window_position_to_move == "Bottom_Right")
			WinMove, ahk_id%activeid%,, (A_ScreenWidth - Width)
									  , (A_ScreenHeight - Height)
		else if (window_position_to_move == "Top_Left")
			WinMove, ahk_id%activeid%,, 0, 0
		else if (window_position_to_move == "Bottom_Left")
			WinMove, ahk_id%activeid%,, 0, (A_ScreenHeight - Height)
		else if (window_position_to_move == "Center") {
			WinMove, ahk_id%activeid%,, X, Y, 0.8 * Width, 0.8 * Height
			PostMessage, 0x112, 0xF030,,, ahk_id%activeid%
		}
		ActivateTableWin()
	}
}
Return ; }}}

MoveLobbyInOut: ; {{{
WinGet, LobbyId, id, PokerStars Lobby ahk_class #32770
if !LobbyId
{
	GuiControl,, Status, Status: PokerStars Lobby not found
	FileAppend, %A_Now% PokerStars Lobby not found `n, %LogFile%
	Return
}
WinShow, ahk_id%LobbyId%
WinGetPos, lobby_x, lobby_y,,, ahk_id%LobbyId%
if (( lobby_x > 3*A_ScreenWidth/4 ) OR ( lobby_y > 3*A_ScreenHeight/4 ))
{
	WinMove, ahk_id%LobbyId%,, (A_ScreenWidth/4), 0
	WinActivate, ahk_id%LobbyId%
} else
{
	WinMove, ahk_id%LobbyId%,, (A_ScreenWidth - 35), (A_ScreenHeight - 100)
}
Return ; }}}

; hotkeys {{{
; ^ = Ctrl
; ! = Alt
^!s::
Gosub, StartScript
Return

^!t::
Gosub, UnRegisterAll
Return

^!p::
Gosub, PauseScript
Return

^!o::
Gosub, SittingOut_via_button
Return

^!i::
Gosub, InfoTab_via_button
Return

^!f::
Gosub, InfoTab_via_button_active
Return

^!w::
Gosub, WindowMaximize
Return

^!a::
Gosub, ActivateTableWin
Return

PgUp::
window_position_to_move := "Top_Right"
Gosub, WindowMove
Return

PgDn::
window_position_to_move := "Bottom_Right"
Gosub, WindowMove
Return

Insert::
window_position_to_move := "Top_Left"
Gosub, WindowMove
Return

Delete::
window_position_to_move := "Bottom_Left"
Gosub, WindowMove
Return

Home::
window_position_to_move := "Center"
Gosub, WindowMove
Return

NumpadHome::
ControlSend, Edit1, {Up}, %thisahk%
Gui, Submit, NoHide
Return

NumpadEnd::
ControlSend, Edit1, {Down}, %thisahk%
Gui, Submit, NoHide
Return

^!h::
WinHide, %thisahk%
Return

^!r::
WinShow, %thisahk%
Return

^!l::
Gosub, MoveLobbyInOut
Return

~^!q::
ExitApp
; }}}
AHK script:Stars Filtered SNG Opener Quote
08-02-2015 , 10:41 AM
Hi, after like 3 30minutes session with this AHK script I always get this error. This happens every day. Rebooting and stuff doesn't help anything.



Does anyone know how to fix this?
Thanks in advance.
AHK script:Stars Filtered SNG Opener Quote
08-02-2015 , 12:54 PM
Chief0r, either add
Code:
#MaxMem 300
(or more (mbs), depending on the size of pokerstars.log.0 file) at the script start or try using Autohotkey basic http://www.autohotkey.com/download/A...05_Install.exe or delete pokerstars.log.0 file when it grows big - you can automize it by inserting
Code:
filedelete,%logfile%
line right after
Code:
ddlist3:=ddlist3 . 9999 . "|"
, log file will be deleted on every script start then.
AHK script:Stars Filtered SNG Opener Quote
08-02-2015 , 01:17 PM
Thanks a lot. It looks like it worked.
AHK script:Stars Filtered SNG Opener Quote
08-22-2015 , 11:11 PM
Does the latest script still work?
For me it just goes on the waiting tab.

Also:

;;;;;;;;;;;SET YOUR pokerstars.log.0 file path below;;;;;;;;;;;;;;;
;;;;;;;;;;;eg: logfile:="c:\Program Files\PokerStars\pokerstars.log.0"
logfile:= pspath . "pokerstars.log.0" ;<-

I only have to change

eg: logfile:="this here"
logfile:= pspath . "pokerstars.log.0" ;<-

?
AHK script:Stars Filtered SNG Opener Quote
08-23-2015 , 06:02 AM
Forfail, it does work, the latest version can be found in post №1079 here, the script should be run as admin, you need to replace this line
Code:
logfile:= pspath . "pokerstars.log.0" ;<-
with your path,
Code:
logfile:="your path"
AHK script:Stars Filtered SNG Opener Quote
08-23-2015 , 07:21 AM
Sorry i need some further assistance :S

I Reinstalled Pokerstars, since it was messed up due the EU change.

Copied the Code of the script, added my path, opened Pokerstas and afterwards the script as admin.
Filtered SnG's.
UNchecked "Auto Open SnG Lobby" in the Settings.
Have the Lobby open and do "Submit+Run"

But it just Hops from "Registering" to "Waiting" without registering any.

Maybe you can find my failure somewhere on the screen below?

AHK script:Stars Filtered SNG Opener Quote
08-23-2015 , 07:35 AM
Forfail, it is admin privileges issue usually, try compiling the script to .exe and running that .exe as admin then. You can also try using this version
Code:
; Author:         Everlong@2p2 Code assembled from misc sources, thanks to _dave_, chris228, finnisher
; v.4.01c
; added: PS 7 support
; 4.0x version fixed by Max1mums 
#NoEnv
#SingleInstance, Force
#Maxmem 300
SendMode Input
SetWorkingDir %A_ScriptDir%
setwindelay,-1
setcontroldelay,-1
SetBatchLines, -1
SetTitleMatchMode, 2
SetTimer, register, off
SetTimer, safeguard, off
SetTimer, numcheck, 75
StringTrimRight, thisahk, A_ScriptName, 4
onexit,exitsub
IniRead, pspath, %thisahk%.ini, Settings, path


;;;;;;;;;;;SET YOUR pokerstars.log.0 file path below;;;;;;;;;;;;;;;
;;;;;;;;;;;eg: logfile:="c:\Program Files\PokerStars\pokerstars.log.0"
logfile:= pspath . "pokerstars.log.0" ;<-


IfNotExist,%logfile%
{
Loop, %A_ProgramFiles%\* , 2
{
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
}
IfNotExist,%logfile%
Loop, %A_AppData%\* , 2
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
IfNotExist,%logfile%
{
StringReplace,logfile,A_AppData,Roaming,Local
Loop, %logfile%\* , 2
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
}
}
IfNotExist,%logfile%
{
logfile:= pspath . "pokerstars.log.0"
;IfNotExist,%logfile%
;msgbox, PokerStars.log.0 file path is probably incorrect, recheck the configuration
}
IniRead, Targetnum, %thisahk%.ini, Settings, Targetnum
if Targetnum is not number
Targetnum:=0
;==============================================================
RegSofar=0
OpenTables=0
trows=17
SysGet,mon, MonitorworkArea
fivesec=0
ft:=0
two=0
ddlist4=Off|
ddlist5=Off|
ddlist6=Off|
ddlist7=Off|
LobbyList=Default|Black|
ddlist2:=ddlist2 . 1 . "|"
ddlist2:=ddlist2 . 2 . "|"
Loop 100
{
two:=two+2
ddlist3:=ddlist3 . two . "|"
ddlist:=ddlist . A_index . "|"
If (A_index<51)
{
fivesec:=fivesec+5
ddlist2:=ddlist2 . fivesec . "|"
ddlist6:=ddlist6 . fivesec . "|"
If (A_index<22)
{
ddlist7:=ddlist7 . A_Index . "|"
If (A_index<16)
{
ddlist4:=ddlist4 . A_index . "|"
}
}
}
else
{
ft:=ft+15
ddlist5:=ddlist5 . ft . "|"
}
}
ddlist3:=ddlist3 . 9999 . "|"
Gosub, deletelog
Gosub, BuildGui
Return
;==============================================================
;==============================================================

BuildGui:
Gui, color, white
Gui, font, cOlive
Gui, add, tab, h340 w240, General|Advanced Settings
Gui, add, text, , Auto-register
Gui, add, Checkbox, yp xp+80 Check3 Checked-1 vRegister
Gui, add, text, yp xp+30, Reg. next if full?
Gui, add, Checkbox, yp xp+80 VAutoifFull


Gui, add, text,xp-190 yp+30 , Register every (sec):
Gui, add, DropDownList, w50 yp-5 xp+140  vInterval1, %ddlist2%
Gui, add, text, xp-140 yp+30, No of SNG:s to keep open:
Gui, add, DropDownList, w50 yp-5 xp+140 vKeepOpen , %ddlist%
Gui, add, text,xp-140 yp+30, Limit total SNG:s to:
Gui, add, DropDownList, w50 yp-5 xp+140 vTotalLimit , %ddlist3%
Gui, add, text,xp-140 yp+30, Limit total time to (min):
Gui, add, DropDownList, w50 yp-5 xp+140 vLimitTime , %ddlist5%

Gui, add, text, xp-140 yp+30 cred vcdown w200
Gui, add, text, xp  yp+30 w200 vRegSofar, SNG:s registered so far:
Gui, add, text,  w200 vOpenTables, Tables open/waiting:
Gui, add, text, w200 cRed vStatus, Status: Idle
Gui, add, Button, w68 ggetgui, &Submit+Run
Gui, add, text, xp+72 yp+5, (Autosaves your settings)
Gui, Add, Button, Disabled xp-72 yp+20 w48 h20 Center , &Resume
Gui, Add, Button, Disabled  w45 h20 yp xp+48 Center , &Pause
Gui, Add, Button, w80 h20 yp xp+45 Center globbyrestore, &Lobby restore
Gui, tab, 2

Gui, add, Text, x25 y65 , Lobby Theme:
Gui, add, DropDownList, w65 yp-5 xp+140 vLobby, %LobbyList%
Gui, add, text,xp-140 yp+30 , Close lobbies every (sec):
Gui, add, DropDownList, w50 yp-5 xp+140  vCloseInterv, %ddlist6%
Gui, add, text, xp-140 yp+18 , (manually Close with ctrl+e)
Gui, add, text, yp+30, Disable if no user Input (min):
Gui, add, DropDownList, w50 yp-5 xp+140 vGuardtimer Choose1 , %ddlist4%
Gui, add, text, xp-140 yp+30 ,Batch-register?
Gui, add, Checkbox,yp xp+140 vBatchReg
Gui, add, text, yp+20 xp-140 ,SetReg* mode?
Gui, add, Checkbox,yp xp+140 vSetReg
Gui, add, text, yp+20 xp-140 ,Minimize lobby?
Gui, add, Checkbox,yp xp+140 vMinlob
Gui, add, Text, xp-140 yp+30, Times to scroll down:
Gui, add, DropDownList, w50 yp-5 xp+140 vscrldwn, %ddlist7%
Gui, add, Text, xp-140 yp+25, Always start at top of lobby?
Gui, add, Checkbox, yp xp+140 vTopReturn
Gui, show, w256, %thisahk%
WinGetPos, x, y, w, h, SFSO
;x:=monRight-w
;y:=monBottom-h
x:=monLeft
y:=monTop
Gosub, GetIni
Gui, show, x%x% y%y%, %thisahk%
Return

deletelog:
ifwinnotexist,ahk_class PokerStarsTableFrameClass
filedelete,%logfile%
return

getgui:
GuiControl,, Register, -1
Register = 1
Gui, Submit, NoHide
displayedTime=
If (lobby="Default")
{
regButton:="PokerStarsButtonClass10"
}
Else If (lobby="Black" or lobby="Custom*")
{
regButton:="PokerStarsButtonClass10"
}
PS6list=PokerStarsListClass3
PS7list1=PokerStarsListClass13
PS7list2=PokerStarsListClass12
Gosub, MakeIni
PausedTime:=LimitTime
Gosub, TimeLimit
interval:=interval1*1000
If interval is not Number
interval=off
If guardtimer is not Number
{
SetTimer, safeguard, off
}
Else
{
killtime:=guardtimer*60000
SetTimer, safeguard, 1000
}
if CloseInterv is not number
SetTimer, NukeLobbies, off
else
{
lobclose:=CloseInterv*1000
SetTimer, NukeLobbies, %lobclose%
}
register=1
sleep,-1
Gosub, ButtonResume
Return

Safeguard:
If (A_TimeIdle > killtime)
{
Gosub, ButtonPause
GuiControl, , cdown, Stopped  due to inactivity!!! %displayedTime%
}
Return

TimeLimit:
If LimitTime is Number
{
allowedMinutes := LimitTime
endTime := A_Now
endTime += %allowedMinutes%, Minutes
SetTimer, CountDown, 1000
}
Else
{
SetTimer, CountDown, off
sleep,-1
GuiControl, , cdown, Time Limit off
}
Return

Countdown:
remainingTime := endTime
EnvSub remainingTime, %A_Now%, Seconds
m := remainingTime // 60
s := Mod(remainingTime, 60)
displayedTime := Format3Digits(m) ":" Format2Digits(s)
GuiControl, , cdown, Running another (mm:ss): %displayedTime%
If (A_now > endTime)
{
SetTimer, Countdown, off
Gosub, ButtonPause
GuiControl, , cdown, Time Limit reached.
}
Return

GuiClose:
Gui, Submit
Gosub, MakeIni
ExitApp
Return

ButtonResume:
Gui, Submit, NoHide
GuiControl, Disable, &Resume
GuiControl, Enable, &Pause
if LimitTime is Number
If PausedTime is Number
LimitTime:=PausedTime
Gosub, TimeLimit
GuiControl, , Register, -1
Register:=1
SetTitleMatchMode, 2
WinGet, LobbyID, id, PokerStars Lobby,,Tournament
wingettitle,lobbytitle,ahk_id%LobbyID%
if !instr(lobbytitle,"Logged In")>0
{
WinGet,ctrls,ControlList,ahk_id%LobbyID%
Loop,Parse,ctrls,`n
{
 controlgettext,text,%A_LoopField%,ahk_id%LobbyID%
 ControlGet, v, Visible, , %A_LoopField%, ahk_id%LobbyID%
 if (text="Register") && v
 regButton:=A_LoopField
}
}
settimer, AutoReg,37
OpenTables:=0
tables=
OpenTables:=CountTourneys(1)
Gosub,Register
SetTimer, Register, %Interval%
sleep,-1
Return

ButtonPause:
Critical
Gui, Submit, NoHide
if LimitTime is Number
PausedTime:=remainingTime/60
Register:=0
settimer, AutoReg,off
SetTimer, Countdown, off
SetTimer, Register, off
GuiControl, Disable, Pause
GuiControl, Enable, Resume
GuiControl, , Register, 0
GuiControl, , cdown, Manually Paused %displayedTime%
GuiControl, , Status, Status: Waiting ;TEST
Return

Register:
SetTitleMatchMode, 2
WinGet, LobbyID, id, PokerStars Lobby,,Tournament
If !LobbyID
{
Gosub, ButtonPause
GuiControl,, Status, Status: PokerStars Lobby not found
Gui, show, NoActivate, %thisahk%
Return
}
If (TopReturn=1)
{
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
ControlSend, %list%, {NumpadUp 20}, ahk_id%lobbyid%
}
WinGet, PhysicalTables, list,Table ahk_class PokerStarsTableFrameClass
If PhysicalTables is not Number
PhysicalTables:=0
If (PhysicalTables >= KeepOpen)
{
GuiControl,, Status, Set Full waiting
Return
}
OpenTables:=CountTourneys()
If OpenTables is not Number
OpenTables:=0
GuiControl, , OpenTables, Tables open/waiting: %OpenTables%
GuiControl, , RegSofar, SNG:s registered so far: %RegSofar%
If (RegSofar >= TotalLimit)
{
Gosub, ButtonPause
GuiControl, , cdown, SNG Total Limit reached
GuiControl, , Status, Status: Idle ;TEST
Return
}
If (OpenTables >= TotalLimit)
{
Gosub, ButtonPause
GuiControl, , cdown, SNG Total Limit reached
GuiControl, , Status, Status: Idle ;TEST
Return
}
If (OpenTables>=KeepOpen)
{
GuiControl, , OpenTables, Tables open/waiting: %OpenTables% (Set full)
GuiControl, , Status, Status: Waiting ;TEST
Return
}
Else
{
If (BatchReg=1)
{
Times:= KeepOpen - OpenTables
RegSNGexec(LobbyID, Times, scrldwn)
}
Else
{
RegSNGexec(LobbyID, 1, scrldwn)
}
}
Return

MakeIni:
IniWrite, %AutoIfFull%, %thisahk%.ini, Settings, AutoIfFull
IniWrite, %TopReturn%, %thisahk%.ini, Settings, TopReturn
IniWrite, %scrldwn%, %thisahk%.ini, Settings, scrldwn
IniWrite, %Lobby%, %thisahk%.ini, Settings, Lobby
IniWrite, %BatchReg%, %thisahk%.ini, Settings, BatchReg
IniWrite, %Setreg%, %thisahk%.ini, Settings, SetReg
IniWrite, %Minlob%, %thisahk%.ini, Settings, MinLob
IniWrite, %Interval1%, %thisahk%.ini, Settings, Interval1
IniWrite, %CloseInterv%, %thisahk%.ini, Settings, CloseInterv
IniWrite, %KeepOpen%, %thisahk%.ini, Settings, KeepOpen
IniWrite, %TotalLimit%, %thisahk%.ini, Settings, TotalLimit
IniWrite, %GuardTimer%, %thisahk%.ini, Settings, GuardTimer
IniWrite, %LimitTime%, %thisahk%.ini, Settings, LimitTime
Return

GetIni:
IfExist, %thisahk%.ini
{
IniRead, AutoIfFull, %thisahk%.ini, Settings, AutoIfFull
IniRead, TopReturn, %thisahk%.ini, Settings, TopReturn,0
IniRead, scrldwn, %thisahk%.ini, Settings, scrldwn
IniRead, Lobby, %thisahk%.ini, Settings, Lobby
IniRead, BatchReg, %thisahk%.ini, Settings, BatchReg
IniRead, SetReg, %thisahk%.ini, Settings, SetReg, 1
IniRead, MinLob, %thisahk%.ini, Settings, MinLob, 0
IniRead, Interval1, %thisahk%.ini, Settings, Interval1
IniRead, CloseInterv, %thisahk%.ini, Settings, CloseInterv
IniRead, KeepOpen, %thisahk%.ini, Settings, KeepOpen
IniRead, TotalLimit, %thisahk%.ini, Settings, TotalLimit
IniRead, GuardTimer, %thisahk%.ini, Settings, GuardTimer, Off
IniRead, LimitTime, %thisahk%.ini, Settings, LimitTime, Off
GuiControl, , AutoIfFull, %AutoIfFull%
StringReplace, ddlist7, ddlist7, %scrldwn%, %scrldwn%|
GuiControl, , scrldwn, |%ddlist7%
StringReplace, LobbyList, LobbyList, %Lobby%, %Lobby%|
GuiControl, , Lobby, |%LobbyList%
GuiControl, , BatchReg, %BatchReg%
GuiControl, , SetReg, %SetReg%
GuiControl, , MinLob, %MinLob%
GuiControl, , TopReturn, %TopReturn%
StringReplace, ddlist2, ddlist2, %interval1%, %Interval1%|
GuiControl, , Interval1, |%ddlist2%
StringReplace, ddlist6, ddlist6, %CloseInterv%, %CloseInterv%|
GuiControl, , CloseInterv, |%ddlist6%
StringReplace, ddlist, ddlist, %KeepOpen%, %KeepOpen%|
GuiControl, , KeepOpen, |%ddlist%
StringReplace, ddlist3, ddlist3, %TotalLimit%, %TotalLimit%|,
GuiControl, , TotalLimit, |%ddlist3%
StringReplace, ddlist4, ddlist4, %GuardTimer%, %GuardTimer%|
GuiControl, , GuardTimer, |%ddlist4%
StringReplace, ddlist5, ddlist5, %LimitTime%, %LimitTime%|
GuiControl, , LimitTime, |%ddlist5%
}
Return

#e::
gosub,NukeLobbies
Return

NukeLobbies:
SetTitleMatchMode, 2
GroupAdd, TLobbies, Lobby ahk_class PokerStarsTableFrameClass,,, PokerStars Lobby
GroupClose, TLobbies, A
Return

#H::
WinHide, %thisahk%
return

#S::
WinShow, %thisahk%
return

F11::
TmpSetReg:=SetReg
SetReg=0
CountTourneys()
SetReg:=TmpSetReg
Return
ManualCount:
CountTourneys()
Return

FindLobby:
If (%A_GuiEvent% = DoubleClick)
{
LV_GetText(TournId,A_EventInfo)
TournID:=SubStr(TournID, 1,10)
WinMenuSelectItem, PokerStars Lobby,, Requests, Find a Tournament
WinWait, Find Tournament ahk_class #32770, , 10
WinGet, fat, id
ControlFocus, Edit1, ahk_id%fat%
Sleep, -1
ControlSend, Edit1, %TournId%, ahk_id%fat%
ControlFocus, Button1, ahk_id%fat%
Sleep, -1
ControlSend, Button1, {Space}, ahk_id%fat%
}
Return

Format2Digits(_val) {
_val :=Round(_val) + 100
StringRight _val, _val, 2
Return _val
}

Format3Digits(_val) {
_val :=Round(_val) + 1000
StringRight _val, _val, 3
StringTrimRight, FirstZ, _val, 2
If FirstZ=0
{
StringTrimLeft, _val, _val, 1
}
StringTrimRight, FirstZ, _val, 1
If FirstZ=0
{
StringTrimLeft, _val, _val, 1
}
Return _val
}
LobbyRestore:
WinGet, lobbyid, id, PokerStars Lobby
WinShow, ahk_id%lobbyid%
WinMove, ahk_id%lobbyid%,,0,0
return

RegSNGexec(id, times, scrldwn) {
global RegSofar
global Register
global OpenTables
global KeepOpen
global TotalLimit
global RegButton
global AutoIfFull
global list,lobbytitle,lobbyid,PS7list1,PS7list2,PS6list

Loop %times%
{
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
ControlSend, %list%, {NumpadUp 20}, ahk_id%id%
If (OpenTables >= KeepOpen)
Exit
If (OpenTables >= TotalLimit)
Exit
ClickdirectionCount=0
direction=0
GuiControl, , Status, Status: Registering ;TEST
Loop 16
{
If (Register=0)
{
GuiControl, , Status, Status: Idle ;TEST
Exit
}
ControlGet, v, Visible, , %regButton%, ahk_id%id%
If (v = 0)
If (scrldwn!="Off")
{
If (ClickdirectionCount<scrldwn) {
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
If (direction=0) {
ControlSend, %list%, {NumpadDown}, ahk_id%id%
} Else {
ControlSend, %list%, {NumpadUp}, ahk_id%id%
}
ClickdirectionCount:=ClickdirectionCount+1
} Else {
If (direction=0) {
direction:=1
} Else {
direction:=0
}
ClickdirectionCount:=0
}
Sleep,1000
}
If ( v = 1 ) {
wingetclass,class,A
SetTitleMatchMode, 2
ControlSend, %regButton%, {Space}, ahk_id%id%
ControlSend, %regButton%, {Space}, ahk_id%id%
WinWait, Tournament Registration ahk_class #32770,,1
{
WinGet, regid, id, Tournament Registration ahk_class #32770
wingettext,text,
if instr(text,"Confirm")>0
{
autobtn=PokerStarsButtonClass3
okbtn=PokerStarsButtonClass2
}
else
{
autobtn=Button2
okbtn=PokerStarsButtonClass1
}
controlget,vis,visible,,%autobtn%,ahk_id%regid%
if vis
{
 If (AutoIfFull = 1)
 {
 Control,Check,,%autobtn%, ahk_id%regid%
 ;ControlSend, %autobtn%, {Space}, ahk_id%regid%
 Sleep, 30
 }
ControlSend, %okbtn%, {Space}, ahk_id%regid%
}
}
sleep,30
WinWait, Tournament Registration ahk_class #32770,,1
{
WinGet, regid, id, Tournament Registration ahk_class #32770
controlget,vis,visible,,Button2,ahk_id%regid%
controlget,vis1,visible,,PokerStarsButtonClass3,ahk_id%regid%
if !vis && !vis1
winclose,ahk_id%regid%
;ControlSend, PokerStarsButtonClass1, {Space}, ahk_id%regid%
}
GuiControl, , Status, Status: Waiting ;TEST
;if class=PokerStarsTableFrameClass
;winactivate,ahk_class PokerStarsTableFrameClass
Break
}
}
}
}
return

AutoReg:
AutoReg()
return

AutoReg()
{
global AutoIfFull
setwindelay,-1
settitlematchmode,2
IfWinExist, Tournament Registration ahk_class #32770
{
wingettext,text,
if instr(text,"Confirm")>0
{
autobtn=PokerStarsButtonClass3
okbtn=PokerStarsButtonClass2
}
else
{
autobtn=Button2
okbtn=PokerStarsButtonClass1
}
winget,id,id,
controlget,vis,visible,,%autobtn%,ahk_id%id%
if vis
{
If (AutoIfFull = 1)
{
ControlFocus, %autobtn%, ahk_id%id%
Sleep, -1
ControlSend, %autobtn%, {Space}, ahk_id%id%
Sleep, 30
}
ControlSend, %okbtn%, {Space}, ahk_id%id%
}
else
ControlSend, %okbtn%, {Space}, ahk_id%id%
;winclose,ahk_id%id%
}
}
return

CountTourneys(mode=0) {
global logfile,RegSofar,regtourneys,tables,Targetnum
If (SetReg=1)
Return 0
log := CheckFile(logfile,mode)
Loop, Parse, log, `n,
{
tnumber=
if (instr(A_loopField,"RT add")>0)
{
 tnumber:=RegExReplace(A_loopField, "RT add ", "")
 if instr(tnumber,A_space)
 StringLeft, tnumber, tnumber, instr(tnumber,A_space)-1
 tnumber:=RegExReplace(tnumber, "[`n,`r]", "")
 tnumber:=Floor(tnumber)
 if !instr(tables,tnumber) && ((Targetnum=0) || ((Targetnum>0) && (tnumber>=(Targetnum-50000)) && (tnumber<(Targetnum+100000))))
 listadd(tables,tnumber)
}
else
If (instr(A_loopField,"RT remove")>0)
{
 stringtrimleft,tnumber,A_loopField,instr(A_loopField,A_space,"",0)
 tnumber:=RegExReplace(tnumber, "[`n,`r]", "")
 tnumber:=Floor(tnumber)
 if instr(tables,tnumber)
 listDelItem(tables,tnumber)
}
}
log=
tcount:=0
Loop, Parse, tables, -,
{
if A_Loopfield is number
{
tcount++
if !(instr(regtourneys,A_Loopfield)>0)
{
listadd(regtourneys,A_Loopfield)
if mode=0
RegSofar++
}
}
}
return tcount
}

numcheck:
winget,nlist,list,Table ahk_class PokerStarsTableFrameClass
loop %nlist%
{
id:=nlist%A_index%
wingettitle,title,ahk_id%id%
stringtrimleft,num,title,instr(title,A_space,"",instr(title,"Tournament"))
stringleft,num,num,instr(num,A_space)-1
if num is not number
num:=0
if (num>targetnum)
targetnum:=num
StringReplace,targetnum,targetnum,A_space,,All
StringReplace,targetnum,targetnum,`n,,All
StringReplace,targetnum,targetnum,`r,,All
}
return

Ansi2Unicode(sString, CP = 0)
{
	  nSize := DllCall("MultiByteToWideChar"
		, "Uint", CP
		, "Uint", 0
		, "Uint", &sString
		, "int",  -1
		, "Uint", 0
		, "int",  0)

	VarSetCapacity(wString, nSize * 2)

	DllCall("MultiByteToWideChar"
		, "Uint", CP
		, "Uint", 0
		, "Uint", &sString
		, "int",  -1
		, "Uint", &wString
		, "int",  nSize)
return wstring
}

ReplaceByte( hayStackAddr, hayStackSize, ByteFrom=0, ByteTo=1, StartOffset=0, NumReps=-1)
{	Static fun
	IfEqual,fun,
	{
		h=
		( LTrim join
			5589E553515256579C8B4D0C8B451831D229C17E25837D1C00741F8B7D0801C70FB6451
			00FB65D14FCF2AE750D885FFF42FF4D1C740409C975EF9D89D05F5E5A595BC9C21800
		)
		VarSetCapacity(fun,StrLen(h)//2)
		Loop % StrLen(h)//2
			NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char")
	}
	Return DllCall(&fun
		, "uint",haystackAddr, "uint",hayStackSize, "short",ByteFrom, "short",ByteTo
		, "uint",StartOffset, "int",NumReps)
}

CheckFile(File, mode=0) {
   ; THX Sean for File.ahk : http://www.autohotkey.com/forum/post-124759.html
   Static CF := ""   ; Current File
   Static FP := 0    ; File Pointer
   Static OPEN_EXISTING := 3
   Static GENERIC_READ := 0x80000000
   Static FILE_SHARE_READ := 1
   Static FILE_SHARE_WRITE := 2
   Static FILE_SHARE_DELETE := 4
   Static FILE_BEGIN := 0
   BatchLines := A_BatchLines
   SetBatchLines, -1
   If (File != CF) {
      CF := File
      FP := 0
   }
   hFile := DllCall("CreateFile"
                  , "Str",  File
                  , "Uint", GENERIC_READ
                  , "Uint", FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE
                  , "Uint", 0
                  , "Uint", OPEN_EXISTING
                  , "Uint", 0
                  , "Uint", 0)
   If (!hFile) {
      CF := ""
      FP := 0
      SetBatchLines, %BatchLines%
      Return False
   }
   DllCall("GetFileSizeEx"
         , "Uint",   hFile
         , "Int64P", nSize)
   if mode=1
   FP:=1
   If (FP = 0 Or nSize <= FP) {
      FP := nSize
      SetBatchLines, %BatchLines%
      DllCall("CloseHandle", "Uint", hFile) ; close file
     Return False
   }
   DllCall("SetFilePointerEx"
         , "Uint",  hFile
         , "Int64", FP
         , "Uint",  0
         , "Uint",  FILE_BEGIN)
   VarSetCapacity(Tail, Length := nSize - FP, 0)
   DllCall("ReadFile"
         , "Uint",  hFile
         , "Str",   Tail
         , "Uint",  Length
         , "UintP", Length
         , "Uint",  0)
   DllCall("CloseHandle", "Uint", hFile)
   FP := nSize
   if A_IsUnicode
   {
   tail:=Ansi2Unicode(tail)
   Length:=strlen(tail)
   }
   ReplaceByte( &Tail, Length)
   VarSetCapacity(Tail, -1)
   SetBatchLines, %BatchLines%
   Return Tail
}

listAdd( byRef list, item, del="-" ) {
  list:=( list!="" ? ( list . del . item ) : item )
  return list
}

listDelItem( byRef list, item, del="-") {
  ifEqual, item,, return list
  list:=del . list . del
  StringReplace, list, list, %del%%item%%del%,%del%,All
  StringTrimLeft, list, list, 1
  StringTrimRight, list, list, 1
  return list
}

lobbyStars() {
SetTitleMatchMode 2
WinGet, id, id, PokerStars Lobby ahk_class #32770,,Tournament
Return id
}

;~^!Q::
;ExitApp

exitsub:
if Targetnum>0
IniWrite, %Targetnum%, %thisahk%.ini, Settings, Targetnum
Gosub, deletelog
exitapp
return
AHK script:Stars Filtered SNG Opener Quote
08-23-2015 , 07:47 AM
Thank you!!!
Compiling to an .exe file fixed it. :-)
AHK script:Stars Filtered SNG Opener Quote
09-01-2015 , 01:41 PM
Hello, I am using this script, but does not stop the number of tables that I imposed, continues to register. How can I fix? Thank you.


Quote:
Originally Posted by Max1mums
Forfail, it is admin privileges issue usually, try compiling the script to .exe and running that .exe as admin then. You can also try using this version
Code:
; Author:         Everlong@2p2 Code assembled from misc sources, thanks to _dave_, chris228, finnisher
; v.4.01c
; added: PS 7 support
; 4.0x version fixed by Max1mums 
#NoEnv
#SingleInstance, Force
#Maxmem 300
SendMode Input
SetWorkingDir %A_ScriptDir%
setwindelay,-1
setcontroldelay,-1
SetBatchLines, -1
SetTitleMatchMode, 2
SetTimer, register, off
SetTimer, safeguard, off
SetTimer, numcheck, 75
StringTrimRight, thisahk, A_ScriptName, 4
onexit,exitsub
IniRead, pspath, %thisahk%.ini, Settings, path


;;;;;;;;;;;SET YOUR pokerstars.log.0 file path below;;;;;;;;;;;;;;;
;;;;;;;;;;;eg: logfile:="c:\Program Files\PokerStars\pokerstars.log.0"
logfile:= pspath . "pokerstars.log.0" ;<-


IfNotExist,%logfile%
{
Loop, %A_ProgramFiles%\* , 2
{
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
}
IfNotExist,%logfile%
Loop, %A_AppData%\* , 2
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
IfNotExist,%logfile%
{
StringReplace,logfile,A_AppData,Roaming,Local
Loop, %logfile%\* , 2
if instr(A_LoopFileName,"PokerStars")>0
logfile:=A_LoopFileFullPath . "\PokerStars.log.0"
}
}
IfNotExist,%logfile%
{
logfile:= pspath . "pokerstars.log.0"
;IfNotExist,%logfile%
;msgbox, PokerStars.log.0 file path is probably incorrect, recheck the configuration
}
IniRead, Targetnum, %thisahk%.ini, Settings, Targetnum
if Targetnum is not number
Targetnum:=0
;==============================================================
RegSofar=0
OpenTables=0
trows=17
SysGet,mon, MonitorworkArea
fivesec=0
ft:=0
two=0
ddlist4=Off|
ddlist5=Off|
ddlist6=Off|
ddlist7=Off|
LobbyList=Default|Black|
ddlist2:=ddlist2 . 1 . "|"
ddlist2:=ddlist2 . 2 . "|"
Loop 100
{
two:=two+2
ddlist3:=ddlist3 . two . "|"
ddlist:=ddlist . A_index . "|"
If (A_index<51)
{
fivesec:=fivesec+5
ddlist2:=ddlist2 . fivesec . "|"
ddlist6:=ddlist6 . fivesec . "|"
If (A_index<22)
{
ddlist7:=ddlist7 . A_Index . "|"
If (A_index<16)
{
ddlist4:=ddlist4 . A_index . "|"
}
}
}
else
{
ft:=ft+15
ddlist5:=ddlist5 . ft . "|"
}
}
ddlist3:=ddlist3 . 9999 . "|"
Gosub, deletelog
Gosub, BuildGui
Return
;==============================================================
;==============================================================

BuildGui:
Gui, color, white
Gui, font, cOlive
Gui, add, tab, h340 w240, General|Advanced Settings
Gui, add, text, , Auto-register
Gui, add, Checkbox, yp xp+80 Check3 Checked-1 vRegister
Gui, add, text, yp xp+30, Reg. next if full?
Gui, add, Checkbox, yp xp+80 VAutoifFull


Gui, add, text,xp-190 yp+30 , Register every (sec):
Gui, add, DropDownList, w50 yp-5 xp+140  vInterval1, %ddlist2%
Gui, add, text, xp-140 yp+30, No of SNG:s to keep open:
Gui, add, DropDownList, w50 yp-5 xp+140 vKeepOpen , %ddlist%
Gui, add, text,xp-140 yp+30, Limit total SNG:s to:
Gui, add, DropDownList, w50 yp-5 xp+140 vTotalLimit , %ddlist3%
Gui, add, text,xp-140 yp+30, Limit total time to (min):
Gui, add, DropDownList, w50 yp-5 xp+140 vLimitTime , %ddlist5%

Gui, add, text, xp-140 yp+30 cred vcdown w200
Gui, add, text, xp  yp+30 w200 vRegSofar, SNG:s registered so far:
Gui, add, text,  w200 vOpenTables, Tables open/waiting:
Gui, add, text, w200 cRed vStatus, Status: Idle
Gui, add, Button, w68 ggetgui, &Submit+Run
Gui, add, text, xp+72 yp+5, (Autosaves your settings)
Gui, Add, Button, Disabled xp-72 yp+20 w48 h20 Center , &Resume
Gui, Add, Button, Disabled  w45 h20 yp xp+48 Center , &Pause
Gui, Add, Button, w80 h20 yp xp+45 Center globbyrestore, &Lobby restore
Gui, tab, 2

Gui, add, Text, x25 y65 , Lobby Theme:
Gui, add, DropDownList, w65 yp-5 xp+140 vLobby, %LobbyList%
Gui, add, text,xp-140 yp+30 , Close lobbies every (sec):
Gui, add, DropDownList, w50 yp-5 xp+140  vCloseInterv, %ddlist6%
Gui, add, text, xp-140 yp+18 , (manually Close with ctrl+e)
Gui, add, text, yp+30, Disable if no user Input (min):
Gui, add, DropDownList, w50 yp-5 xp+140 vGuardtimer Choose1 , %ddlist4%
Gui, add, text, xp-140 yp+30 ,Batch-register?
Gui, add, Checkbox,yp xp+140 vBatchReg
Gui, add, text, yp+20 xp-140 ,SetReg* mode?
Gui, add, Checkbox,yp xp+140 vSetReg
Gui, add, text, yp+20 xp-140 ,Minimize lobby?
Gui, add, Checkbox,yp xp+140 vMinlob
Gui, add, Text, xp-140 yp+30, Times to scroll down:
Gui, add, DropDownList, w50 yp-5 xp+140 vscrldwn, %ddlist7%
Gui, add, Text, xp-140 yp+25, Always start at top of lobby?
Gui, add, Checkbox, yp xp+140 vTopReturn
Gui, show, w256, %thisahk%
WinGetPos, x, y, w, h, SFSO
;x:=monRight-w
;y:=monBottom-h
x:=monLeft
y:=monTop
Gosub, GetIni
Gui, show, x%x% y%y%, %thisahk%
Return

deletelog:
ifwinnotexist,ahk_class PokerStarsTableFrameClass
filedelete,%logfile%
return

getgui:
GuiControl,, Register, -1
Register = 1
Gui, Submit, NoHide
displayedTime=
If (lobby="Default")
{
regButton:="PokerStarsButtonClass10"
}
Else If (lobby="Black" or lobby="Custom*")
{
regButton:="PokerStarsButtonClass10"
}
PS6list=PokerStarsListClass3
PS7list1=PokerStarsListClass13
PS7list2=PokerStarsListClass12
Gosub, MakeIni
PausedTime:=LimitTime
Gosub, TimeLimit
interval:=interval1*1000
If interval is not Number
interval=off
If guardtimer is not Number
{
SetTimer, safeguard, off
}
Else
{
killtime:=guardtimer*60000
SetTimer, safeguard, 1000
}
if CloseInterv is not number
SetTimer, NukeLobbies, off
else
{
lobclose:=CloseInterv*1000
SetTimer, NukeLobbies, %lobclose%
}
register=1
sleep,-1
Gosub, ButtonResume
Return

Safeguard:
If (A_TimeIdle > killtime)
{
Gosub, ButtonPause
GuiControl, , cdown, Stopped  due to inactivity!!! %displayedTime%
}
Return

TimeLimit:
If LimitTime is Number
{
allowedMinutes := LimitTime
endTime := A_Now
endTime += %allowedMinutes%, Minutes
SetTimer, CountDown, 1000
}
Else
{
SetTimer, CountDown, off
sleep,-1
GuiControl, , cdown, Time Limit off
}
Return

Countdown:
remainingTime := endTime
EnvSub remainingTime, %A_Now%, Seconds
m := remainingTime // 60
s := Mod(remainingTime, 60)
displayedTime := Format3Digits(m) ":" Format2Digits(s)
GuiControl, , cdown, Running another (mm:ss): %displayedTime%
If (A_now > endTime)
{
SetTimer, Countdown, off
Gosub, ButtonPause
GuiControl, , cdown, Time Limit reached.
}
Return

GuiClose:
Gui, Submit
Gosub, MakeIni
ExitApp
Return

ButtonResume:
Gui, Submit, NoHide
GuiControl, Disable, &Resume
GuiControl, Enable, &Pause
if LimitTime is Number
If PausedTime is Number
LimitTime:=PausedTime
Gosub, TimeLimit
GuiControl, , Register, -1
Register:=1
SetTitleMatchMode, 2
WinGet, LobbyID, id, PokerStars Lobby,,Tournament
wingettitle,lobbytitle,ahk_id%LobbyID%
if !instr(lobbytitle,"Logged In")>0
{
WinGet,ctrls,ControlList,ahk_id%LobbyID%
Loop,Parse,ctrls,`n
{
 controlgettext,text,%A_LoopField%,ahk_id%LobbyID%
 ControlGet, v, Visible, , %A_LoopField%, ahk_id%LobbyID%
 if (text="Register") && v
 regButton:=A_LoopField
}
}
settimer, AutoReg,37
OpenTables:=0
tables=
OpenTables:=CountTourneys(1)
Gosub,Register
SetTimer, Register, %Interval%
sleep,-1
Return

ButtonPause:
Critical
Gui, Submit, NoHide
if LimitTime is Number
PausedTime:=remainingTime/60
Register:=0
settimer, AutoReg,off
SetTimer, Countdown, off
SetTimer, Register, off
GuiControl, Disable, Pause
GuiControl, Enable, Resume
GuiControl, , Register, 0
GuiControl, , cdown, Manually Paused %displayedTime%
GuiControl, , Status, Status: Waiting ;TEST
Return

Register:
SetTitleMatchMode, 2
WinGet, LobbyID, id, PokerStars Lobby,,Tournament
If !LobbyID
{
Gosub, ButtonPause
GuiControl,, Status, Status: PokerStars Lobby not found
Gui, show, NoActivate, %thisahk%
Return
}
If (TopReturn=1)
{
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
ControlSend, %list%, {NumpadUp 20}, ahk_id%lobbyid%
}
WinGet, PhysicalTables, list,Table ahk_class PokerStarsTableFrameClass
If PhysicalTables is not Number
PhysicalTables:=0
If (PhysicalTables >= KeepOpen)
{
GuiControl,, Status, Set Full waiting
Return
}
OpenTables:=CountTourneys()
If OpenTables is not Number
OpenTables:=0
GuiControl, , OpenTables, Tables open/waiting: %OpenTables%
GuiControl, , RegSofar, SNG:s registered so far: %RegSofar%
If (RegSofar >= TotalLimit)
{
Gosub, ButtonPause
GuiControl, , cdown, SNG Total Limit reached
GuiControl, , Status, Status: Idle ;TEST
Return
}
If (OpenTables >= TotalLimit)
{
Gosub, ButtonPause
GuiControl, , cdown, SNG Total Limit reached
GuiControl, , Status, Status: Idle ;TEST
Return
}
If (OpenTables>=KeepOpen)
{
GuiControl, , OpenTables, Tables open/waiting: %OpenTables% (Set full)
GuiControl, , Status, Status: Waiting ;TEST
Return
}
Else
{
If (BatchReg=1)
{
Times:= KeepOpen - OpenTables
RegSNGexec(LobbyID, Times, scrldwn)
}
Else
{
RegSNGexec(LobbyID, 1, scrldwn)
}
}
Return

MakeIni:
IniWrite, %AutoIfFull%, %thisahk%.ini, Settings, AutoIfFull
IniWrite, %TopReturn%, %thisahk%.ini, Settings, TopReturn
IniWrite, %scrldwn%, %thisahk%.ini, Settings, scrldwn
IniWrite, %Lobby%, %thisahk%.ini, Settings, Lobby
IniWrite, %BatchReg%, %thisahk%.ini, Settings, BatchReg
IniWrite, %Setreg%, %thisahk%.ini, Settings, SetReg
IniWrite, %Minlob%, %thisahk%.ini, Settings, MinLob
IniWrite, %Interval1%, %thisahk%.ini, Settings, Interval1
IniWrite, %CloseInterv%, %thisahk%.ini, Settings, CloseInterv
IniWrite, %KeepOpen%, %thisahk%.ini, Settings, KeepOpen
IniWrite, %TotalLimit%, %thisahk%.ini, Settings, TotalLimit
IniWrite, %GuardTimer%, %thisahk%.ini, Settings, GuardTimer
IniWrite, %LimitTime%, %thisahk%.ini, Settings, LimitTime
Return

GetIni:
IfExist, %thisahk%.ini
{
IniRead, AutoIfFull, %thisahk%.ini, Settings, AutoIfFull
IniRead, TopReturn, %thisahk%.ini, Settings, TopReturn,0
IniRead, scrldwn, %thisahk%.ini, Settings, scrldwn
IniRead, Lobby, %thisahk%.ini, Settings, Lobby
IniRead, BatchReg, %thisahk%.ini, Settings, BatchReg
IniRead, SetReg, %thisahk%.ini, Settings, SetReg, 1
IniRead, MinLob, %thisahk%.ini, Settings, MinLob, 0
IniRead, Interval1, %thisahk%.ini, Settings, Interval1
IniRead, CloseInterv, %thisahk%.ini, Settings, CloseInterv
IniRead, KeepOpen, %thisahk%.ini, Settings, KeepOpen
IniRead, TotalLimit, %thisahk%.ini, Settings, TotalLimit
IniRead, GuardTimer, %thisahk%.ini, Settings, GuardTimer, Off
IniRead, LimitTime, %thisahk%.ini, Settings, LimitTime, Off
GuiControl, , AutoIfFull, %AutoIfFull%
StringReplace, ddlist7, ddlist7, %scrldwn%, %scrldwn%|
GuiControl, , scrldwn, |%ddlist7%
StringReplace, LobbyList, LobbyList, %Lobby%, %Lobby%|
GuiControl, , Lobby, |%LobbyList%
GuiControl, , BatchReg, %BatchReg%
GuiControl, , SetReg, %SetReg%
GuiControl, , MinLob, %MinLob%
GuiControl, , TopReturn, %TopReturn%
StringReplace, ddlist2, ddlist2, %interval1%, %Interval1%|
GuiControl, , Interval1, |%ddlist2%
StringReplace, ddlist6, ddlist6, %CloseInterv%, %CloseInterv%|
GuiControl, , CloseInterv, |%ddlist6%
StringReplace, ddlist, ddlist, %KeepOpen%, %KeepOpen%|
GuiControl, , KeepOpen, |%ddlist%
StringReplace, ddlist3, ddlist3, %TotalLimit%, %TotalLimit%|,
GuiControl, , TotalLimit, |%ddlist3%
StringReplace, ddlist4, ddlist4, %GuardTimer%, %GuardTimer%|
GuiControl, , GuardTimer, |%ddlist4%
StringReplace, ddlist5, ddlist5, %LimitTime%, %LimitTime%|
GuiControl, , LimitTime, |%ddlist5%
}
Return

#e::
gosub,NukeLobbies
Return

NukeLobbies:
SetTitleMatchMode, 2
GroupAdd, TLobbies, Lobby ahk_class PokerStarsTableFrameClass,,, PokerStars Lobby
GroupClose, TLobbies, A
Return

#H::
WinHide, %thisahk%
return

#S::
WinShow, %thisahk%
return

F11::
TmpSetReg:=SetReg
SetReg=0
CountTourneys()
SetReg:=TmpSetReg
Return
ManualCount:
CountTourneys()
Return

FindLobby:
If (%A_GuiEvent% = DoubleClick)
{
LV_GetText(TournId,A_EventInfo)
TournID:=SubStr(TournID, 1,10)
WinMenuSelectItem, PokerStars Lobby,, Requests, Find a Tournament
WinWait, Find Tournament ahk_class #32770, , 10
WinGet, fat, id
ControlFocus, Edit1, ahk_id%fat%
Sleep, -1
ControlSend, Edit1, %TournId%, ahk_id%fat%
ControlFocus, Button1, ahk_id%fat%
Sleep, -1
ControlSend, Button1, {Space}, ahk_id%fat%
}
Return

Format2Digits(_val) {
_val :=Round(_val) + 100
StringRight _val, _val, 2
Return _val
}

Format3Digits(_val) {
_val :=Round(_val) + 1000
StringRight _val, _val, 3
StringTrimRight, FirstZ, _val, 2
If FirstZ=0
{
StringTrimLeft, _val, _val, 1
}
StringTrimRight, FirstZ, _val, 1
If FirstZ=0
{
StringTrimLeft, _val, _val, 1
}
Return _val
}
LobbyRestore:
WinGet, lobbyid, id, PokerStars Lobby
WinShow, ahk_id%lobbyid%
WinMove, ahk_id%lobbyid%,,0,0
return

RegSNGexec(id, times, scrldwn) {
global RegSofar
global Register
global OpenTables
global KeepOpen
global TotalLimit
global RegButton
global AutoIfFull
global list,lobbytitle,lobbyid,PS7list1,PS7list2,PS6list

Loop %times%
{
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
ControlSend, %list%, {NumpadUp 20}, ahk_id%id%
If (OpenTables >= KeepOpen)
Exit
If (OpenTables >= TotalLimit)
Exit
ClickdirectionCount=0
direction=0
GuiControl, , Status, Status: Registering ;TEST
Loop 16
{
If (Register=0)
{
GuiControl, , Status, Status: Idle ;TEST
Exit
}
ControlGet, v, Visible, , %regButton%, ahk_id%id%
If (v = 0)
If (scrldwn!="Off")
{
If (ClickdirectionCount<scrldwn) {
if !instr(lobbytitle,"Logged In")>0
{
ControlGet,vis,visible,,%PS7list1%,ahk_id%lobbyid%
if vis
list:=PS7list1
else
list:=PS7list2
}
else
list:=PS6list
If (direction=0) {
ControlSend, %list%, {NumpadDown}, ahk_id%id%
} Else {
ControlSend, %list%, {NumpadUp}, ahk_id%id%
}
ClickdirectionCount:=ClickdirectionCount+1
} Else {
If (direction=0) {
direction:=1
} Else {
direction:=0
}
ClickdirectionCount:=0
}
Sleep,1000
}
If ( v = 1 ) {
wingetclass,class,A
SetTitleMatchMode, 2
ControlSend, %regButton%, {Space}, ahk_id%id%
ControlSend, %regButton%, {Space}, ahk_id%id%
WinWait, Tournament Registration ahk_class #32770,,1
{
WinGet, regid, id, Tournament Registration ahk_class #32770
wingettext,text,
if instr(text,"Confirm")>0
{
autobtn=PokerStarsButtonClass3
okbtn=PokerStarsButtonClass2
}
else
{
autobtn=Button2
okbtn=PokerStarsButtonClass1
}
controlget,vis,visible,,%autobtn%,ahk_id%regid%
if vis
{
 If (AutoIfFull = 1)
 {
 Control,Check,,%autobtn%, ahk_id%regid%
 ;ControlSend, %autobtn%, {Space}, ahk_id%regid%
 Sleep, 30
 }
ControlSend, %okbtn%, {Space}, ahk_id%regid%
}
}
sleep,30
WinWait, Tournament Registration ahk_class #32770,,1
{
WinGet, regid, id, Tournament Registration ahk_class #32770
controlget,vis,visible,,Button2,ahk_id%regid%
controlget,vis1,visible,,PokerStarsButtonClass3,ahk_id%regid%
if !vis && !vis1
winclose,ahk_id%regid%
;ControlSend, PokerStarsButtonClass1, {Space}, ahk_id%regid%
}
GuiControl, , Status, Status: Waiting ;TEST
;if class=PokerStarsTableFrameClass
;winactivate,ahk_class PokerStarsTableFrameClass
Break
}
}
}
}
return

AutoReg:
AutoReg()
return

AutoReg()
{
global AutoIfFull
setwindelay,-1
settitlematchmode,2
IfWinExist, Tournament Registration ahk_class #32770
{
wingettext,text,
if instr(text,"Confirm")>0
{
autobtn=PokerStarsButtonClass3
okbtn=PokerStarsButtonClass2
}
else
{
autobtn=Button2
okbtn=PokerStarsButtonClass1
}
winget,id,id,
controlget,vis,visible,,%autobtn%,ahk_id%id%
if vis
{
If (AutoIfFull = 1)
{
ControlFocus, %autobtn%, ahk_id%id%
Sleep, -1
ControlSend, %autobtn%, {Space}, ahk_id%id%
Sleep, 30
}
ControlSend, %okbtn%, {Space}, ahk_id%id%
}
else
ControlSend, %okbtn%, {Space}, ahk_id%id%
;winclose,ahk_id%id%
}
}
return

CountTourneys(mode=0) {
global logfile,RegSofar,regtourneys,tables,Targetnum
If (SetReg=1)
Return 0
log := CheckFile(logfile,mode)
Loop, Parse, log, `n,
{
tnumber=
if (instr(A_loopField,"RT add")>0)
{
 tnumber:=RegExReplace(A_loopField, "RT add ", "")
 if instr(tnumber,A_space)
 StringLeft, tnumber, tnumber, instr(tnumber,A_space)-1
 tnumber:=RegExReplace(tnumber, "[`n,`r]", "")
 tnumber:=Floor(tnumber)
 if !instr(tables,tnumber) && ((Targetnum=0) || ((Targetnum>0) && (tnumber>=(Targetnum-50000)) && (tnumber<(Targetnum+100000))))
 listadd(tables,tnumber)
}
else
If (instr(A_loopField,"RT remove")>0)
{
 stringtrimleft,tnumber,A_loopField,instr(A_loopField,A_space,"",0)
 tnumber:=RegExReplace(tnumber, "[`n,`r]", "")
 tnumber:=Floor(tnumber)
 if instr(tables,tnumber)
 listDelItem(tables,tnumber)
}
}
log=
tcount:=0
Loop, Parse, tables, -,
{
if A_Loopfield is number
{
tcount++
if !(instr(regtourneys,A_Loopfield)>0)
{
listadd(regtourneys,A_Loopfield)
if mode=0
RegSofar++
}
}
}
return tcount
}

numcheck:
winget,nlist,list,Table ahk_class PokerStarsTableFrameClass
loop %nlist%
{
id:=nlist%A_index%
wingettitle,title,ahk_id%id%
stringtrimleft,num,title,instr(title,A_space,"",instr(title,"Tournament"))
stringleft,num,num,instr(num,A_space)-1
if num is not number
num:=0
if (num>targetnum)
targetnum:=num
StringReplace,targetnum,targetnum,A_space,,All
StringReplace,targetnum,targetnum,`n,,All
StringReplace,targetnum,targetnum,`r,,All
}
return

Ansi2Unicode(sString, CP = 0)
{
	  nSize := DllCall("MultiByteToWideChar"
		, "Uint", CP
		, "Uint", 0
		, "Uint", &sString
		, "int",  -1
		, "Uint", 0
		, "int",  0)

	VarSetCapacity(wString, nSize * 2)

	DllCall("MultiByteToWideChar"
		, "Uint", CP
		, "Uint", 0
		, "Uint", &sString
		, "int",  -1
		, "Uint", &wString
		, "int",  nSize)
return wstring
}

ReplaceByte( hayStackAddr, hayStackSize, ByteFrom=0, ByteTo=1, StartOffset=0, NumReps=-1)
{	Static fun
	IfEqual,fun,
	{
		h=
		( LTrim join
			5589E553515256579C8B4D0C8B451831D229C17E25837D1C00741F8B7D0801C70FB6451
			00FB65D14FCF2AE750D885FFF42FF4D1C740409C975EF9D89D05F5E5A595BC9C21800
		)
		VarSetCapacity(fun,StrLen(h)//2)
		Loop % StrLen(h)//2
			NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char")
	}
	Return DllCall(&fun
		, "uint",haystackAddr, "uint",hayStackSize, "short",ByteFrom, "short",ByteTo
		, "uint",StartOffset, "int",NumReps)
}

CheckFile(File, mode=0) {
   ; THX Sean for File.ahk : http://www.autohotkey.com/forum/post-124759.html
   Static CF := ""   ; Current File
   Static FP := 0    ; File Pointer
   Static OPEN_EXISTING := 3
   Static GENERIC_READ := 0x80000000
   Static FILE_SHARE_READ := 1
   Static FILE_SHARE_WRITE := 2
   Static FILE_SHARE_DELETE := 4
   Static FILE_BEGIN := 0
   BatchLines := A_BatchLines
   SetBatchLines, -1
   If (File != CF) {
      CF := File
      FP := 0
   }
   hFile := DllCall("CreateFile"
                  , "Str",  File
                  , "Uint", GENERIC_READ
                  , "Uint", FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE
                  , "Uint", 0
                  , "Uint", OPEN_EXISTING
                  , "Uint", 0
                  , "Uint", 0)
   If (!hFile) {
      CF := ""
      FP := 0
      SetBatchLines, %BatchLines%
      Return False
   }
   DllCall("GetFileSizeEx"
         , "Uint",   hFile
         , "Int64P", nSize)
   if mode=1
   FP:=1
   If (FP = 0 Or nSize <= FP) {
      FP := nSize
      SetBatchLines, %BatchLines%
      DllCall("CloseHandle", "Uint", hFile) ; close file
     Return False
   }
   DllCall("SetFilePointerEx"
         , "Uint",  hFile
         , "Int64", FP
         , "Uint",  0
         , "Uint",  FILE_BEGIN)
   VarSetCapacity(Tail, Length := nSize - FP, 0)
   DllCall("ReadFile"
         , "Uint",  hFile
         , "Str",   Tail
         , "Uint",  Length
         , "UintP", Length
         , "Uint",  0)
   DllCall("CloseHandle", "Uint", hFile)
   FP := nSize
   if A_IsUnicode
   {
   tail:=Ansi2Unicode(tail)
   Length:=strlen(tail)
   }
   ReplaceByte( &Tail, Length)
   VarSetCapacity(Tail, -1)
   SetBatchLines, %BatchLines%
   Return Tail
}

listAdd( byRef list, item, del="-" ) {
  list:=( list!="" ? ( list . del . item ) : item )
  return list
}

listDelItem( byRef list, item, del="-") {
  ifEqual, item,, return list
  list:=del . list . del
  StringReplace, list, list, %del%%item%%del%,%del%,All
  StringTrimLeft, list, list, 1
  StringTrimRight, list, list, 1
  return list
}

lobbyStars() {
SetTitleMatchMode 2
WinGet, id, id, PokerStars Lobby ahk_class #32770,,Tournament
Return id
}

;~^!Q::
;ExitApp

exitsub:
if Targetnum>0
IniWrite, %Targetnum%, %thisahk%.ini, Settings, Targetnum
Gosub, deletelog
exitapp
return
AHK script:Stars Filtered SNG Opener Quote
09-01-2015 , 02:51 PM
Zelo, set pokerstars.log.0 file path manually at the script start, run the script as admin.
AHK script:Stars Filtered SNG Opener Quote
09-01-2015 , 08:15 PM
Quote:
Originally Posted by Max1mums
Zelo, set pokerstars.log.0 file path manually at the script start, run the script as admin.

hello, how I can do this? thanks.
AHK script:Stars Filtered SNG Opener Quote
09-08-2015 , 08:36 PM
Hello, I put the path to the file but still does not stop, I always records. Any other advice?
AHK script:Stars Filtered SNG Opener Quote
10-13-2015 , 03:59 AM
Привет Max1mums. Скопировал выложенный код скрипта для авторегистраций, создал файл с разрешением AHk. Подскажи пожалуйста, какие галочки должны стоять на второй странице скрипта http://prntscr.com/8qqzxq .
И есть еще такая проблема, при переключении галочки с auto-register на окно reg.next if full почему то открывается браузер и начинают открываться окна сайта покерстарс до тех пор, пока не нажмешь паузу в скрипте.
Еще один вопрос, что поменять в настройках, чтобы скрипт в лобби покерстарс регестрировал все открытые строчки, по факту получается открыто 5 СНГ, из них скрипт регистрирует только верхнюю строчку.

Hi Max1mums. I copied the laid-out script code for autoregistration, I created the file with the permission of AHk. Prompt please, what ticks have to stand on the second page of a script http://prntscr .com/8qqzxq.
Also there is still such problem, when switching a tick with auto-register on the reg.next if full window the browser for some reason opens and site windows pokerstars start opening until you press a pause in a script.
One more question what to change in settings that the script in a lobby pokerstars registered all open lines, upon turns out openly 5 MTSNG, from them the script registers only the top line.
AHK script:Stars Filtered SNG Opener Quote
10-15-2015 , 03:01 PM
Hello

When I try to start session I get "Idle (lobby not found)" message in the status bar. What is wrong ?

I use default PS version 7 lobby. I identified PS controls in SFSO options dialog.
AHK script:Stars Filtered SNG Opener Quote
10-15-2015 , 03:12 PM
Try using the latest version guys, post №1091.
AHK script:Stars Filtered SNG Opener Quote
11-30-2015 , 08:50 PM
I created the latest script written here, but it doesn't register more tables when i'm out of a SnG. Auto-register cant be checked since it automatically unchecks when I hit submit!
AHK script:Stars Filtered SNG Opener Quote

      
m