Open Side Menu Go to the Top
Register
MTSNG script: retrieve number of remaining players (HUD) MTSNG script: retrieve number of remaining players (HUD)

12-05-2012 , 07:09 PM
This script uses ImageSearch to scan the info tab for remaining players. Obviously ImageSearch is slow and the more images it searches for the slower it gets, so this one only uses 27 images for 36 down to 10 players. Only tested with detached chat windows, afaik attached chat uses a different background color which shouldn't be an issue due to the *Trans option, but idk if the font is the same. However, here's the code and the image archive:


Download image archive here: http://ul.to/7klh1wsw

Code:
#NoEnv  
#SingleInstance, Force
SendMode Input 
SetWinDelay, 0

;---------------------------------------------------------------------------

Img36 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\36.png"
Img35 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\35.png"
Img34 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\34.png"
Img33 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\33.png"
Img32 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\32.png"
Img31 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\31.png"
Img30 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\30.png"
Img29 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\29.png"
Img28 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\28.png"
Img27 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\27.png"
Img26 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\26.png"
Img25 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\25.png"
Img24 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\24.png"
Img23 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\23.png"
Img22 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\22.png"
Img21 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\21.png"
Img20 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\20.png"
Img19 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\19.png"
Img18 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\18.png"
Img17 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\17.png"
Img16 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\16.png"
Img15 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\15.png"
Img14 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\14.png"
Img13 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\13.png"
Img12 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\12.png"
Img11 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\11.png"
Img10 := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\10.png"

; top left corner of rectangle to scan
Tx = 100
Ty = 355

; bottom right corner of rectangle to scan
Bx = 300
By = 450

;---------------------------------------------------------------------------

Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Color, 000000
Gui +LastFound  
WinSet, TransColor, 000000
Gui, Font, s27 cWhite w1000, Verdana			
Gui, Margin, 6,-2						
Gui, Add, Text, vNo Center, 00

Loop
{
IfWinActive, ahk_class PokerStarsTableFrameClass
	{
	id := WinExist("A")
	WinGetPos, xpos, ypos, W, H, ahk_id%id%
	WinActivate, ahk_class PokerStarsTableHelperFrameClass

	N := 36
	
	Loop
	{
		Image := Img%N%

		ImageSearch,,, %Tx%, %Ty%, %Bx%, %By%, *Trans0xFFFFFF %Image%
		if ErrorLevel=0
			break
		else, if ErrorLevel=1
			N := N-1
		if N = 9
			break
	}

	if N = 9
		N = 

	Gui_x := xpos+50
	Gui_y := ypos+500
		
	Gui, Show, x%Gui_x% y%Gui_y%	
	GuiControl,, No, %N%
		
	WinActivate, ahk_id%id%
	WinWaitNotActive, ahk_id%id%
	Gui, hide
	}
	
else, Gui, hide
WinWaitActive,  ahk_class PokerStarsTableFrameClass
}
return

^Q::ExitApp
You could obv as well use it to auto-move tables and only scan tables at certain areas so it has less to do. I'd be happy to assist you with this, just lmk.

HTH HF

Last edited by Baobhan-Sith; 12-05-2012 at 07:16 PM.
MTSNG script: retrieve number of remaining players (HUD) Quote
12-05-2012 , 09:19 PM
A bit nicer code, easier to config + more options:

Code:
#NoEnv  
#SingleInstance, Force
SendMode Input 
SetWinDelay, 0

;---------------------------------------------------------------------------

Path := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\Img\"

; screen area of tables to consider
Startx = 500
Endx = 1000
Starty = 0
Endy = 1200

; top left corner of rectangle to scan (detached info tab)
Tx = -160
Ty = 500

; bottom right corner of rectangle to scan (detached info tab)
Bx = -40
By = 550

; above coords are screen relative; if you want them to be table relative
; eg. for attached chat, remove the highlighted CoordMode command below

; HUD coords (table relative)
HUDx = 50
HUDy = 500

;---------------------------------------------------------------------------

Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Color, 000000
Gui +LastFound  
WinSet, TransColor, 000000
Gui, Font, s27 cWhite w1000, Verdana			
Gui, Margin, 6,-2						
Gui, Add, Text, vNo Center, 00

;---------------------------------------------------------------------------

Loop
{
IfWinActive, ahk_class PokerStarsTableFrameClass
	{
	id := WinExist("A")
	WinGetPos, x, y,,, ahk_id%id%

	if x between %Startx% and %Endx% 
		{
		N := 36
		if y between %Starty% and %Endy%
			Loop
			{
			CoordMode, Pixel, screen	; remove this for attached chat

			File = %N%.png
			Image = %Path%%File%

			ImageSearch,,, %Tx%, %Ty%, %Bx%, %By%, *Trans0xFFFFFF %Image%
			if ErrorLevel=0
				break
			else, if ErrorLevel=1
				N := N-1
			if N = 9
				break
			}
		else
			{
			WinWaitNotActive, ahk_id%id%
		 	continue
			}
		}
	else
		{
		WinWaitNotActive, ahk_id%id%
		continue
		}
	
	if N = 9
		N = 

	CoordMode, Pixel, relative

	Guix := HUDx+x
	Guiy := HUDy+y
		
	Gui, Show, x%Guix% y%Guiy%	
	GuiControl,, No, %N%

	WinActivate, ahk_id%id%
	WinWaitNotActive, ahk_id%id%
	Gui, hide
	}
	
else, Gui, hide
WinWaitActive,  ahk_class PokerStarsTableFrameClass
}
return

;---------------------------------------------------------------------------

^Q::ExitApp

Last edited by Baobhan-Sith; 12-05-2012 at 09:24 PM.
MTSNG script: retrieve number of remaining players (HUD) Quote
12-09-2012 , 12:13 AM
Ok, forget those versions I posted above. This one's a major improvement as it's really quick (even though it still uses ImageSearch) and therefore shouldn't cause any focus losses nor any noticeable CPU load, plus it's easy to configure. It also supports 10 to 180 players and is best to use for grinding MTSNG up to 180s (PokerStars only atm).

How does it work?
  • For each new SNG it retrieves the number of players from the window title and sets that as a starting point; this number will be displayed in the HUD
  • For each tourney it will create an ini file with the last retrieved number in it
  • As soon as the table pops up again it will scan the info tab (supports only detached chat atm) for a number lower than the ini entry, but only will try a custom defined time (-> MaxCount)
  • If it finds a match it will replace the ini value and show the new number in the HUD
  • If it doesn't find a match in the info tab within the counting cycles you set up, it won't change the ini value and the HUD will show the old number from the ini and go from there again upon next table activation.
  • As soon as you reach the FT the HUD will disappear, and it will also only show on one PokerStars table at once, and only if the table is active
  • So basically, it never compares images endless times as above versions did (they scanned the whole set of images every time if they didn't find a match)

I would recommend to set the MaxCount value to a reasonable maximum of players to bust within one hand. This could still be more than 10 early in 180mans though; if you set up eg. 5 and there were 7 bustouts since you last acted on the table it won't ever catch up finding a match, so make sure the number is actually high enough. Not too high though because during the very first hand of each tourney players aren't listed in the info tab and it therefore can't find a match

Another important thing is, the script will never automatically delete ini files. This is to make sure you don't run into troubles if you ever have to restart the script (or your whole comp) during a grind. You can delete the whole Data folder periodically prior to a new session; the script will automatically recreate the folder on startup if it doesn't exist.

One last thing to say: It will not auto refresh on a permanently active table so it might not be as useful for singletablers.

Here you go:

Image Archive Download Link

Code:
#NoEnv   
#SingleInstance force
SetWinDelay, 0
SendMode Input

;==================================================================================

ImgPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Img"
IniPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Data"

; top left & bottom right corners of rectangle to scan (detached info tab, screen relative)
TL_x = -160
TL_y = 500
BR_x = -40
BR_y = 550

; HUD coords (table relative) and color
HUD_x = 50
HUD_y = 500
HUD_Color = FF0000

; maximum count cycles before aborting (resets counter to primary value)
MaxCount = 10

;==================================================================================

Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Color, 000000
Gui +LastFound  
WinSet, TransColor, 000000
Gui, Font, s27 c%HUD_Color% w1000, Verdana			
Gui, Margin, 6,-2						
Gui, Add, Text, vHUD Center, 000

IfNotExist, %IniPath%
	FileCreateDir, %IniPath%

Loop
{
IfWinActive, ahk_class PokerStarsTableFrameClass
	{
	id := WinExist("A")
	WinGetPos, x, y, w, w, ahk_id%id%
	WinGetActiveTitle, Title
	IfInString, Title, Players
		{		
		IfInString, Title, 18 Players
			N = 4
		else, IfInString, Title, 27 Players
			N = 4
		else, IfInString, Title, 45 Players
			N = 4
		else, IfInString, Title, 90 Players
			N = 4
		else, IfInString, Title, 180 Players
			N = 5
	
		StartID := InStr(Title, "Tournament")+10
		StringTrimLeft, TourneyID, Title, StartID		
		EndID := InStr(TourneyID, " ")-1
		StringLeft, TourneyID, TourneyID, EndID
				
		StartEntr := InStr(Title, "Players")-N
		StringTrimLeft, Entrants, Title, StartEntr		
		EndEntr := InStr(Entrants, "Players")-2
		StringLeft, Entrants, Entrants, EndEntr
		
		INI = %IniPath%\%TourneyID%.ini
				
		if FileExist(INI)
			{
			IniRead, LastPlayers, %INI%, Players, Last
			
			CountLimit := LastPlayers - MaxCount
			Focus = 1
			
			Loop
				{
				IfWinActive, ahk_id%id%
					{
					PNG = %LastPlayers%.png
					IMG = %ImgPath%\%PNG%
					CoordMode, Pixel, Screen
					ImageSearch,,, %TL_x%, %TL_y%, %BR_x%, %BR_y%, %IMG%
					if ErrorLevel=0
						{
						CurrentPlayers := LastPlayers
						IniWrite, %CurrentPlayers%, %INI%, Players, Last
						break
						}
					else, if ErrorLevel=1
						{
						LastPlayers := LastPlayers - 1
						if LastPlayers = %CountLimit%
							{
							CurrentPlayers := LastPlayers + MaxCount
							break
							}
						if LastPlayers = 9
							{
							CurrentPlayers =
							break
							}
						}						
					}
				else
					{
					Focus = 0
					break
					}
				}
			if Focus = 0
				{
				Focus = 1
				continue
				}
			}		
		else
			{
			CurrentPlayers := Entrants
			IniWrite, %CurrentPlayers%, %INI%, Players, Last
			}
		
		x := HUD_x+x
		y := HUD_y+y	
		CoordMode, Pixel, relative	
		Gui, Show, x%x% y%y%	
		GuiControl,, HUD, %CurrentPlayers% 
		
		WinActivate, ahk_id%id%
		WinWaitNotActive, ahk_id%id%
		}
	else
		{
		Gui, Hide
		WinWaitNotActive, ahk_id%id%
		}
	}		
else
	{
	Gui, Hide
	WinWaitActive, ahk_class PokerStarsTableFrameClass
	}

IfWinNotExist, ahk_class PokerStarsTableFrameClass
	{
	Gui, Hide
	WinWaitActive, ahk_class PokerStarsTableFrameClass
	}
}
return

^Q::ExitApp
This is the rectangle to scan btw:



Feel free to report bugs ITT or PM me anytime.

Have fun and good luck at the felts!

Last edited by Baobhan-Sith; 12-09-2012 at 12:29 AM.
MTSNG script: retrieve number of remaining players (HUD) Quote
12-09-2012 , 05:12 PM
good work
MTSNG script: retrieve number of remaining players (HUD) Quote
12-10-2012 , 09:08 PM
Thx dude!

Fixed some bugs and added some options:
  • no more endless image searches if players > 180
  • now supports 2-990 players, MTSNG only though (HUD will only show <= 180)
  • customizable bubble/ITM/FT-bubble field sizes and according HUD colors as well as option to hide HUD completely (eg. at FT)
  • hotkey to reload script, useful for redrawing HUD at a single table - idk how else to accomplish this
  • hotkey to bring up an input box to manually override the active tourney's field size in case the script fails to catch up (make sure no other table steals focus while using this because it edits the ini of last found tourney ID)
  • optional delay to make sure HUD goes to the correct position in case you use another script/tool to auto-arrange (move) tables
  • option to scan attached chat (still not supported though due to lack of images - I just cba to grind with attached chat and taking dozens of screenshots again )
  • less ini write accesses; script will now only update an ini if the field size changed
This should be all for now but I'm sure more will come. I plan to include optional auto table movements for instance, and I'd be more than happy if I managed to get the NoActivate GUI option to work. Also, the next version will auto-detect bubbles to support the different colors option for multiple SNG types at once. Also on the to-do list is managing with a single ini but that's of minor importance.

Download Additional Images Here
(required for this version)

Code:
#NoEnv   
#SingleInstance force
SetWinDelay, 50

;==================================================================================

; folder locations (IniPath will be automatically created if it doesn't exist)
ImgPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Img"
IniPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Data"

; info tab / chat window appearance (0 = attached, 1 = detached)
Detached = 1

; top left & bottom right corners of rectangle to scan (~ top right quarter of info tab)
; detached chat = screen relative, attached chat = table relative
TL_x = -160
TL_y = 500
BR_x = -40
BR_y = 550

; HUD coords (table relative) and colors
HUD_x = 360
HUD_y = 126

HUD_Color = 666666
HUD_Color_Bubble = ff0000
HUD_Color_ITM = ffaa00
HUD_Color_FT_Bubble = 00ff00

; bubble & ITM field sizes, affects above colors
Bubble = 21
ITM = 18
FT_Bubble = 12

; players per table (option to hide HUD at FT, ie. if players < MinPlayers)
MinPlayers = 2

; maximum ImageSearch cycles before aborting (keeps HUD & ini value at primary value)
; default = 0 (players/10+2, maximum 10)
MaxAttempts = 0

; optional HUD delay in msec (1000 = 1 sec, default/off = 0)
; this is to make sure HUD goes to the correct position after tables get auto-moved
Delay = 100

; hotkeys (edit them at bottom of script)
;reload script (redraw HUD) = F10
;close script = CTRL+Q
;manually override player number for active table (input box) = F9

;==================================================================================

Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Color, 000000
Gui +LastFound  
WinSet, TransColor, 000000
Gui, Font, s27 c%HUD_Color% w1000, Verdana			
Gui, Margin, 6,-2						
Gui, Add, Text, vHUD Center, 000

IfNotExist, %IniPath%
	FileCreateDir, %IniPath%
	
Loop
{
IfWinActive, ahk_class PokerStarsTableFrameClass
	{
	id := WinExist("A")
	WinGetActiveTitle, Title
	IfInString, Title, Players
		{				
		StartID := InStr(Title, "Tournament")+10
		StringTrimLeft, TourneyID, Title, StartID		
		EndID := InStr(TourneyID, " ")-1
		StringLeft, TourneyID, TourneyID, EndID
				
		StartEntr := InStr(Title, "[")
		StringTrimLeft, Entrants, Title, StartEntr		
		EndEntr := InStr(Entrants, "Players")-2
		StringLeft, Entrants, Entrants, EndEntr
		
		INI = %IniPath%\%TourneyID%.ini
		
		if FileExist(INI)
			{
			IniRead, IniValue, %INI%, Players, Last	
			
			LastPlayers := IniValue		
			if LastPlayers > 180
				LastPlayers = 181		
							
			MaxCount := MaxAttempts
			if MaxCount = 0
				{
				MaxCount := Round(LastPlayers/10+2, 0)
				if MaxCount > 10
					MaxCount = 10
				}			
				
			CountLimit := LastPlayers - MaxCount - 1
			Focus = 1		
			
			Loop
				{
				IfWinActive, ahk_id%id%
					{
					PNG = %ImgPath%\%LastPlayers%.png
					
					if Detached = 1
						CoordMode, Pixel, Screen
					else, CoordMode, Pixel, relative
					
					ImageSearch,,, %TL_x%, %TL_y%, %BR_x%, %BR_y%, %PNG%
					if ErrorLevel=0
						{
						if LastPlayers < %IniValue%
							IniWrite, %LastPlayers%, %INI%, Players, Last
						break
						}
					else, if ErrorLevel=1
						{
						LastPlayers := LastPlayers - 1
						if LastPlayers = %CountLimit%
							{
							LastPlayers := IniValue
							break
							}
						if LastPlayers < 2
							{
							LastPlayers := IniValue
							break
							}
						}						
					}
				else
					{
					Focus = 0
					break
					}
				}
			if Focus = 0
				{
				Focus = 1
				continue
				}
			}		
		else
			{
			LastPlayers := Entrants
			IniWrite, %Entrants%, %INI%, Players, Entrants
			IniWrite, %LastPlayers%, %INI%, Players, Last
			}
			
		if LastPlayers > 180		
			Gui, hide			
		else, if LastPlayers < %MinPlayers%
			Gui, hide
		else		
			{
			IfWinActive, ahk_id%id%	
				{
				Sleep %Delay%
				WinGetPos, x, y,,, ahk_id%id%	
				x := HUD_x + x
				y := HUD_y + y	
				
				if LastPlayers <= %FT_Bubble%
					Gui, Font, c%HUD_Color_FT_Bubble%, Verdana
				else, if LastPlayers <= %ITM% 
					Gui, Font, c%HUD_Color_ITM%, Verdana
				else, if LastPlayers <= %Bubble% 
					Gui, Font, c%HUD_Color_Bubble%, Verdana
				else, Gui, Font, c%HUD_Color%, Verdana	
				GuiControl, Font, HUD
			
				Gui, Show, x%x% y%y% 
				GuiControl,, HUD, %LastPlayers%
				
				WinActivate, ahk_id%id%
				WinWaitNotActive, ahk_id%id%
				Gui, Hide
				continue
				}
			else, continue
			}
		}
	else
		{
		Gui, Hide
		WinWaitNotActive, ahk_id%id%
		continue
		}
	}		
else	
	{
	Gui, Hide
	WinWaitActive, ahk_class PokerStarsTableFrameClass
	}
}
return

;==================================================================================

F9::
InputBox, Override, %TourneyID%,,, 200, 100
if ErrorLevel
	return
else
	IniWrite, %Override%, %INI%, Players, Last
return

F10::Reload

^Q::ExitApp
gl hf
MTSNG script: retrieve number of remaining players (HUD) Quote
01-11-2013 , 10:00 PM
Fixed some issues with the input box:
- 2 sec auto timeout added
- value now highlighted so you can instantly type
- box will reappear if value is blank or not a number
- box automatically goes to the middle of relevant table

Also, some changes to the main script:
- colored bubble indication replaced with different colors for different stakes
- delay now applies prior to scanning loop for increased reliability
- customizable MaxPlayers variable added
- fixed 177.png (or whatever it was)

DOWNLOAD FIXED IMAGE ARCHIVE HERE
Code:
#NoEnv   
#SingleInstance force

;==================================================================================

; folder locations (IniPath will be automatically created if it doesn't exist)
ImgPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Img"
IniPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Data"

; info tab / chat window appearance (0 = attached, 1 = detached)
; attached chat not yet supported
Detached = 1

; top left & bottom right corners of rectangle to scan (~ top right quarter of info tab)
; detached chat = screen relative, attached chat = table relative
TL_x = 1780
TL_y = 360
BR_x = 1880
BR_y = 400

; HUD coords (table relative)
HUD_x = 367
HUD_y = 130

FontSize = 22

; stakes and corresponding HUD colors
Stake1 = $2.50
Stake2 = $8.00
Stake3 = $15.00
Stake4 = $3.50+R

HUD_Color0 = 666666
HUD_Color1 = B4045F
HUD_Color2 = ff66ff
HUD_Color3 = 58FAAC
HUD_Color4 = 00aaff

; HUD appearance (minimum 2, maximum 180)
MinPlayers = 2
MaxPlayers = 180

; maximum ImageSearch cycles before aborting (keeps HUD & ini value at primary value)
; default = 0 (=> players/9+1, maximum 10, minimum 2)
MaxAttempts = 0

; optional HUD delay in msec (1000 = 1 sec, default/off = 0)
Delay = 150

; hotkeys (edit them at bottom of script)
;manually override player number for active table (input box) = F9
;reload script (redraw HUD) = F10
;close script = CTRL+Q

;==================================================================================

Gui -Caption +ToolWindow +AlwaysOnTop 
Gui, Color, 000000
Gui +LastFound  
WinSet, TransColor, 000000
Gui, Font, s%FontSize% c%HUD_Color0% w1000, Verdana			
Gui, Margin, 6,-2						
Gui, Add, Text, vHUD Center, 000

IfNotExist, %IniPath%
	FileCreateDir, %IniPath%
	
Loop
{
IfWinActive, ahk_class PokerStarsTableFrameClass
	{
	id := WinExist("A")
	WinGetActiveTitle, Title
	Sleep %Delay%
	IfInString, Title, Players
		{				
		StartID := InStr(Title, "Tournament")+10
		StringTrimLeft, TourneyID, Title, StartID		
		EndID := InStr(TourneyID, " ")-1
		StringLeft, TourneyID, TourneyID, EndID
				
		StartEntr := InStr(Title, "[")
		StringTrimLeft, Entrants, Title, StartEntr		
		EndEntr := InStr(Entrants, "Players")-2
		StringLeft, Entrants, Entrants, EndEntr
		
		INI = %IniPath%\%TourneyID%.ini		
		MatchFound = 1
		
		if FileExist(INI)
			{
			IniRead, IniValue, %INI%, Players, Last	
			
			LastPlayers := IniValue		
			if LastPlayers > 180
				LastPlayers = 181		
							
			MaxCount := MaxAttempts
			if MaxCount = 0
				{
				MaxCount := Round(LastPlayers/9+1, 0)
				if MaxCount > 10
					MaxCount = 10
				}			
				
			CountLimit := LastPlayers - MaxCount - 1
			Focus = 1		
			Count = 0
			
			Loop
				{
				IfWinActive, ahk_id%id%
					{
					PNG = %ImgPath%\%LastPlayers%.png
					
					if Detached = 1
						CoordMode, Pixel, Screen
					else, CoordMode, Pixel, relative
					
					ImageSearch,,, %TL_x%, %TL_y%, %BR_x%, %BR_y%, %PNG%
					if ErrorLevel = 0
						{
						if LastPlayers < %IniValue%
							IniWrite, %LastPlayers%, %INI%, Players, Last
						break
						}
					else, if ErrorLevel = 1
						{
						Count++
						LastPlayers := LastPlayers - 1
						if LastPlayers = %CountLimit%
							{
							MatchFound = 0
							LastPlayers := IniValue
							break
							}
						if LastPlayers < 2
							{
							LastPlayers := IniValue
							break
							}
						}			
					}	
				else
					{
					Focus = 0
					break
					}
				}
			if Focus = 0
				{
				Focus = 1
				continue
				}
			}				
		else
			{
			LastPlayers := Entrants
			IniWrite, %Entrants%, %INI%, Players, Entrants
			IniWrite, %LastPlayers%, %INI%, Players, Last
			}
			
		IfWinActive, ahk_id%id%
			{	
			if LastPlayers between %MinPlayers% and %MaxPlayers%
				{
				WinGetPos, x, y,,, ahk_id%id%	
				
				x := HUD_x + x
				y := HUD_y + y	
				
				IfInString, Title, %Stake1%
					Gui, Font, c%HUD_Color1%, Verdana
				else, IfInString, Title, %Stake2%
					Gui, Font, c%HUD_Color2%, Verdana
				else, IfInString, Title, %Stake3%
					Gui, Font, c%HUD_Color3%, Verdana 
				else, IfInString, Title, %Stake4%
					Gui, Font, c%HUD_Color4%, Verdana
				else, Gui, Font, c%HUD_Color%, Verdana	
				
				if MatchFound = 0
					Gui, Font, italic
				else, Gui, Font, norm
				
				Gui, Font, bold				
				GuiControl, Font, HUD			
				Gui, Show, x%x% y%y% 
				GuiControl,, HUD, %LastPlayers%
				}					
			WinActivate, ahk_id%id%
			WinWaitNotActive, ahk_id%id%
			Gui, Hide
			}
		}
	else
		{
		Gui, Hide
		WinWaitNotActive, ahk_id%id%
		}
	}		
else	
	{
	Gui, Hide
	WinWaitActive, ahk_class PokerStarsTableFrameClass
	}
}
return

;==================================================================================

F9::
IfWinActive, ahk_class PokerStarsTableFrameClass
	id := WinExist("A")
	WinGetPos, x, y, w, h, ahk_id%id%
	
	x := x + w/2 - 96
	y := y + h/2 - 96
	
	Loop
		{ 			
		WinActivate, ahk_id%id%
		InputBox, Override, %TourneyID%,,, 200, 100, %x%, %y%,, 2, %IniValue%
		if ErrorLevel = 1
			return
		else, if Override is number
				{
				IniWrite, %Override%, %INI%, Players, Last
				Reload
				}
		}
return

F10::Reload

^Q::ExitApp
MTSNG script: retrieve number of remaining players (HUD) Quote
01-14-2013 , 11:06 AM
Forgot to mention, above version also indicates if it didn't find a match by changing the font to italic, ie. whenever the font isn't italic you can be 100% confident about the number being correct.

The info tab sometimes remains blank for almost a second, that's why the script sometimes doesn't find a match and/or fails to catch up. There's nothing to be done about this other than increasing the delay to like 1000 msec, which to me seems less comfortable than match indication and manual override.

I also forgot to implement auto mouse movement to its original pos after override/inputbox, here's the fix:
Code:
F9::
IfWinActive, ahk_class PokerStarsTableFrameClass
	id := WinExist("A")
	WinGetPos, x, y, w, h, ahk_id%id%
	MouseGetPos, xmouse, ymouse
	
	x := x + w/2 - 96
	y := y + h/2 - 96
	
	Loop
		{ 			
		WinActivate, ahk_id%id%
		InputBox, Override, %TourneyID%,,, 200, 100, %x%, %y%,, 2, %IniValue%
		if ErrorLevel = 1
			return
		else, if Override is number
				{
				IniWrite, %Override%, %INI%, Players, Last
				MouseMove, xmouse, ymouse
				Reload
				}
		}
return
Might also want to add "SetMouseDelay, 0" to the top of the script for quicker mouse movement.

Last edited by Baobhan-Sith; 01-14-2013 at 11:13 AM.
MTSNG script: retrieve number of remaining players (HUD) Quote
02-02-2013 , 12:32 PM
Quote:
Originally Posted by Baobhan-Sith
The info tab sometimes remains blank for almost a second, that's why the script sometimes doesn't find a match and/or fails to catch up. There's nothing to be done about this other than increasing the delay to like 1000 msec, which to me seems less comfortable than match indication and manual override.
Fixed

Create a pure white png file (20*10px), name it blank.png and put it into the Img folder. The red section of this code will scan the top left info tab corner for the blank image and only start the actual image search once the tab contains text. Increased reliability by about 200% .

I also implemented an auto update interval so you can now use the script for singletabling as well (blue part of code).

The green part is also new, should be self explanatory.

Code:
#NoEnv   
#SingleInstance force
SetMouseDelay, 0

;================== CONFIG SECTION ================================================

; folder locations (IniPath will be automatically created if it doesn't exist)
ImgPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Img"
IniPath := "C:\Program Files (x86)\AutoHotkey\Scripts\Stars\GetPlayers\Data"

; info tab / chat window appearance (0 = attached, 1 = detached)
; attached chat not yet supported
Detached = 1

; top left corner of info tab
; detached chat = screen relative, attached chat = table relative
TAB_x = 827
TAB_y = 464

; top left & bottom right corners of rectangle to scan (~ top right quarter of info tab)
; detached chat = screen relative, attached chat = table relative
TL_x = 972
TL_y = 464
BR_x = 1072
BR_y = 520

; HUD coords (table relative)
HUD_x = 367
HUD_y = 130

; stakes and corresponding HUD colors
Stake1 = $35.00
Stake2 = $8.00
Stake3 = $15.00
Stake4 = $3.50+R

HUD_Color0 = 666666
HUD_Color1 = ffff00 
HUD_Color2 = ff66ff
HUD_Color3 = 58FAAC
HUD_Color4 = 00aaff

; HUD appearance (minimum 2, maximum 180)
MinPlayers = 2
MaxPlayers = 180

; HUD auto-update interval (sec)
AutoUpdate = 10

; maximum ImageSearch cycles before aborting (keeps HUD & ini value at primary value)
; default = 0 (=> players/9+1, maximum 12, minimum 2)
MaxAttempts = 0

; HUD appearance delay in msec (1000 = 1 sec, default/off = 0)
Delay = 100

; hotkeys (edit them at bottom of script)
;manually override player number for active table (input box) = CTRL+F1
;reload script (redraw HUD) = CTRL+F2
;close script = CTRL+Q

;==================================================================================

Gui -Caption +ToolWindow +AlwaysOnTop 
Gui, Color, 000000
Gui +LastFound  
WinSet, TransColor, 000000
Gui, Font, s22 c%HUD_Color% w1000, Verdana			
Gui, Margin, 6,-2						
Gui, Add, Text, vHUD Center, 000

TAB_x2 := TAB_x + 40
TAB_y2 := TAB_y + 20
AutoRefresh := AutoUpdate * 10

IfNotExist, %IniPath%
	FileCreateDir, %IniPath%
	
Loop
{
IfWinActive, ahk_class PokerStarsTableFrameClass
	{
	id := WinExist("A")
	WinGetActiveTitle, Title
	Sleep %Delay%
	IfInString, Title, Players
		{				
		StartID := InStr(Title, "Tournament")+10
		StringTrimLeft, TourneyID, Title, StartID		
		EndID := InStr(TourneyID, " ")-1
		StringLeft, TourneyID, TourneyID, EndID
				
		StartEntr := InStr(Title, "[")
		StringTrimLeft, Entrants, Title, StartEntr		
		EndEntr := InStr(Entrants, "Players")-2
		StringLeft, Entrants, Entrants, EndEntr
		
		INI = %IniPath%\%TourneyID%.ini		
		MatchFound = 1
		
		if FileExist(INI)
			{
			IniRead, IniValue, %INI%, Players, Last	
			
			LastPlayers := IniValue		
			if LastPlayers > 180
				LastPlayers = 181		
							
			MaxCount := MaxAttempts
			if MaxCount = 0
				{
				MaxCount := Round(LastPlayers/9+1, 0)
				if MaxCount > 12
					MaxCount = 12
				}			
				
			CountLimit := LastPlayers - MaxCount - 1
			Focus = 1		
			Count = 0
			
			Loop
				{
				IfWinActive, ahk_id%id%
					{
					Loop
						{
						ImageSearch,,, %TAB_x%, %TAB_y%, %TAB_x2%, %TAB_y2%, %ImgPath%\blank.png
						if ErrorLevel = 0
							Sleep 50
						else, break
						}
					PNG = %ImgPath%\%LastPlayers%.png
					
					if Detached = 1
						CoordMode, Pixel, Screen
					else, CoordMode, Pixel, relative
					
					ImageSearch,,, %TL_x%, %TL_y%, %BR_x%, %BR_y%, %PNG%
					if ErrorLevel = 0
						{
						if LastPlayers < %IniValue%
							IniWrite, %LastPlayers%, %INI%, Players, Last
						break
						}
					else, if ErrorLevel = 1
						{
						Count++
						LastPlayers := LastPlayers - 1
						if LastPlayers = %CountLimit%
							{
							MatchFound = 0
							LastPlayers := IniValue
							break
							}
						if LastPlayers < 2
							{
							LastPlayers := IniValue
							break
							}
						}			
					}	
				else
					{
					Focus = 0
					break
					}
				}
			if Focus = 0
				{
				Focus = 1
				continue
				}
			}				
		else
			{
			LastPlayers := Entrants
			IniWrite, %Entrants%, %INI%, Players, Entrants
			IniWrite, %LastPlayers%, %INI%, Players, Last
			}
			
		IfWinActive, ahk_id%id%
			{	
			if LastPlayers between %MinPlayers% and %MaxPlayers%
				{
				WinGetPos, x, y,,, ahk_id%id%	
				
				x := HUD_x + x
				y := HUD_y + y	
				
				IfInString, Title, %Stake1%
					Gui, Font, c%HUD_Color1%, Verdana
				else, IfInString, Title, %Stake2%
					Gui, Font, c%HUD_Color2%, Verdana
				else, IfInString, Title, %Stake3%
					Gui, Font, c%HUD_Color3%, Verdana 
				else, IfInString, Title, %Stake4%
					Gui, Font, c%HUD_Color4%, Verdana
				else, Gui, Font, c%HUD_Color0%, Verdana	
				
				if MatchFound = 0
					Gui, Font, italic
				else, Gui, Font, norm
				
				Gui, Font, bold				
				GuiControl, Font, HUD			
				Gui, Show, x%x% y%y% 
				GuiControl,, HUD, %LastPlayers%
				}					
			WinActivate, ahk_id%id%
			Loop, %AutoRefresh%
				{
				IfWinActive, ahk_id%id%
					{
					Sleep 100
					}
				else
					{
					Gui, hide
					continue
					}
				}
			}
		}
	else
		{
		Gui, Hide
		WinWaitNotActive, ahk_id%id%
		}
	}		
else	
	{
	Gui, Hide
	WinWaitActive, ahk_class PokerStarsTableFrameClass
	}
}
return

;==================================================================================

^F1::
IfWinActive, ahk_class PokerStarsTableFrameClass
	id := WinExist("A")
	WinGetPos, x, y, w, h, ahk_id%id%
	MouseGetPos, xmouse, ymouse
	
	x := x + w/2 - 96
	y := y + h/2 - 96
	
	Loop
		{ 			
		WinActivate, ahk_id%id%
		InputBox, Override, %TourneyID%,,, 200, 100, %x%, %y%,, 2, %IniValue%
		if ErrorLevel = 1
			return
		else, if Override is number
				{
				IniWrite, %Override%, %INI%, Players, Last
				MouseMove, xmouse, ymouse
				Reload
				}
		}
return

^F2::Reload

^Q::ExitApp
MTSNG script: retrieve number of remaining players (HUD) Quote

      
m