Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > Internet Poker > Software

Notices

Software Discussions about gambling-related and poker software.

Reply
 
Thread Tools Display Modes
Old 10-08-2008, 12:08 AM   #16
adept
 
doodydota's Avatar
 
Join Date: Jun 2007
Location: Vienna (Austria) & Cracow (Poland)
Posts: 809
Re: PokerStars: Grab screenname from tournament lobby?

It can, but it's a tough one.
You would have to go through the hassles of optical recongnition, since the text is not directly retrievable from the window.
doodydota is offline   Reply With Quote
Old 10-08-2008, 08:27 AM   #17
centurion
 
flip for stacks?'s Avatar
 
Join Date: Jul 2008
Location: Gotham City
Posts: 170
Re: PokerStars: Grab screenname from tournament lobby?

I'm the developer working on the software in the link listed earlier in the thread, and I just want to mention, neither the popup or OCR work for this method.
flip for stacks? is offline   Reply With Quote
Old 10-09-2008, 12:57 PM   #18
grinder
 
Join Date: May 2006
Location: Norway
Posts: 468
Re: PokerStars: Grab screenname from tournament lobby?

You should be able to use butchas OCR method from the "Ahk bet pot for ipoker" script. From what I can tell you should be able to distinguish any letters except the difference between "l" and "I". Some letters are a pain in the ass because they are too close to other letters to distinguish using spacing (ie "r"), but you can use a loop to pick those out. Also, certain letters get cut off on the left side when it's the first letter in the name (ie "W"), so you have to essentially check for those twice.

I started writing it but then I remembered that I don't even play on stars, so I don't wanna spend time finishing it. It works for most letters but the parser isn't complete. Should be simple enough to finish it (when an unknown letter is encountered a message pops up and the it's copied to the clipboard, so you can just paste it into the ParseStarseName function after the others), though it's too time consuming for my lazy ass.

Here's what I wrote so far if you want it:
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Coordmode, pixel, screen

SysGet, border, 32
SysGet, caption, 4

; press F12 to read the first name in the tournament lobby player list (must be selected/highlighted and visible on-screen)
F12::
{
	WinGet, id, id, Tournament ahk_class #32770
	nick := ScrapeNameFromTourneyLobbyStars(id)
	msgbox %nick%
}


ScrapeNameFromTourneyLobbyStars(id)
{
	global border, caption

	WinGetPos, x, y, , , ahk_id %id%
	x := x + 542 + border
	y := y + 129 + caption

	word := GetTextMatrix(x, y, 114, 12, 0xFFFFFF)
	word :=ParseStarsName(word)

	StringReplace, word, word, %a_space%, , all
	return word
}

;------------------ OCR technique from butcha, slightly modified
;
GetTextMatrix(X,Y,Width,Height,Color)
{
  global

  local col,i,j,px_color, letter, word
  col := 0
  spacecount := 0
  
  Loop, %Width%
  {
    col++
    matrix%col% := 0
    i := A_Index - 1
    Loop, %Height%
    {
      j := A_Index - 1
      PixelGetColor, px_color, X+i,Y+j, fast
      If (px_color = Color)
      {
        matrix%col% := matrix%col% | 2**(Height-j-1)
      }
    }

    letter := matrix%col%
    if letter
    {
	if spacecount
	{
	   if spacecount >= 4
		letter := "SPACE" . letter
	   letter := "`n" . letter
	}
    	word := word . letter . " "
	spacecount := 0
    }    
    else
    {
       spacecount++
    }
  }
  return word
}

ParseStarsName(word)
{
   parsed = 

   loop, parse, word, `n
   {   	
	addLast =
	StringTrimRight, letter, a_loopfield, 1

	IfInString, letter, SPACE
	{
	   StringTrimLeft, letter, letter, 5
	   parsed := parsed . " "
	}

	; "r" is a special case, it's sometimes too close to the next letter to be distinguished by spacing
	loop
	{
		IfInString, letter, 252 64 128
		{
	  		StringTrimLeft, letter, letter, 10
		        parsed := parsed . "r"
		}
		else
		  break
	}

	If !letter
	   continue

	;don't bother reading past the open parenthesis (sp?) (ie when location starts)
	if (letter = "252 258 513")
		return parsed

	else if (letter = "16 16 16")
		parsed := parsed . "-"
	else if (letter = "4")
		parsed := parsed . "."
	else if (letter = "896")
		parsed := parsed . "'"

	else if (letter = "504 516 516 516 504")
		parsed := parsed . "0"
	else if (letter = "128 256 1020")
		parsed := parsed . "1"
	else if (letter = "260 524 532 548 452")
		parsed := parsed . "2"
	else if (letter = "264 516 580 580 440")
		parsed := parsed . "3"
	else if (letter = "200 836 580 580 568")
		parsed := parsed . "5"
	else if (letter = "504 580 580 580 312")
		parsed := parsed . "6"
	else if (letter = "512 540 608 896 512")
		parsed := parsed . "7"
	else if (letter = "440 580 580 580 440")
		parsed := parsed . "8"
	else if (letter = "456 548 548 548 504")
		parsed := parsed . "9"

	else if (letter = "88 164 164 168 124")
		parsed := parsed . "a"
	else if (letter = "1020 72 132 132 120")
		parsed := parsed . "b"
	else if (letter = "120 132 132 132 72")
		parsed := parsed . "c"
	else if (letter = "120 132 132 72 1020")
		parsed := parsed . "d"
	else if (letter = "120 164 164 164 104")
		parsed := parsed . "e"
	else if (letter = "128 508 640")
		parsed := parsed . "f"
	else if (letter = "121 133 133 73 254")
		parsed := parsed . "g"
	else if (letter = "1020 64 128 128 124")
		parsed := parsed . "h"
	else if (letter = "764")
		parsed := parsed . "i"
	else if (letter = "766")			;this is when a "j" is the first letter in the name, the first pixel gets truncated
		parsed := parsed . "j"
	else if (letter = "1020 32 88 132")
		parsed := parsed . "k"
	else if (letter = "1020")
		parsed := parsed . "l"
	else if (letter = "252 64 128 252 128 128 124")
		parsed := parsed . "m"
	else if (letter = "252 128 128 128 124")
		parsed := parsed . "n"
	else if (letter = "120 132 132 132 120")
		parsed := parsed . "o"
	else if (letter = "255 72 132 132 120")
		parsed := parsed . "p"
	else if (letter = "72 164 164 148 72")
		parsed := parsed . "s"
	else if (letter = "1020 132")
		parsed := parsed . "t"			;this is when a "t" is the first letter in the name, the first pixel gets truncated
	else if (letter = "248 4 4 8 252")
		parsed := parsed . "u"
	else if (letter = "192 48 12 48 192")
		parsed := parsed . "v"
	else if (letter = "192 48 12 112 128 112 12 48 192")
		parsed := parsed . "w"
	else if (letter = "132 72 48 72 132")
		parsed := parsed . "x"
	else if (letter = "192 49 14 48 192")
		parsed := parsed . "y"
	else if (letter = "132 140 180 196 132")
		parsed := parsed . "z"

	else if (letter = "12 48 464 528 464 48 12")
		parsed := parsed . "A"
	else if (letter = "1020 580 580 580 580 504")
		parsed := parsed . "B"
	else if (letter = "240 264 516 516 516 264")
		parsed := parsed . "C"
	else if (letter = "1020 516 516 516 264 240")
		parsed := parsed . "D"
	else if (letter = "1020 580 580 580 580")
		parsed := parsed . "E"
	else if (letter = "1020 576 576 576 512")
		parsed := parsed . "F"
	else if (letter = "240 264 516 516 548 296 176")
		parsed := parsed . "G"
	else if (letter = "1020 64 64 64 64 1020")
		parsed := parsed . "H"
	else if (letter = "24 4 4 1016")
		parsed := parsed . "J"
	else if (letter = "1020 32 64 224 280 516")
		parsed := parsed . "K"
	else if (letter = "1020 4 4 4 4")
		parsed := parsed . "L"
	else if (letter = "1020 384 112 12 112 384 1020")
		parsed := parsed . "M"
	else if (letter = "1020 256 192 48 8 1020")
		parsed := parsed . "N"
	else if (letter = "240 264 516 516 516 264 240")
		parsed := parsed . "O"
	else if (letter = "1020 576 576 608 600 388")
		parsed := parsed . "R"
	else if (letter = "392 580 580 548 548 280")
		parsed := parsed . "S"
	else if (letter = "512 512 1020 512 512")
		parsed := parsed . "T"

	else if (letter = "512 384 64 60 64 384 512")
		parsed := parsed . "Y"

	else
	{	
		clipboard = `telse if (letter = "%letter%")`r`n`t`tparsed := parsed . ""
		msgbox Unable to parse letter, update parser:`n|%letter%|`n|%parsed%|
	}
   }

return parsed
}
HalvSame is offline   Reply With Quote
Old 10-09-2008, 05:02 PM   #19
journeyman
 
Join Date: Apr 2007
Location: So much to learn...
Posts: 359
Re: PokerStars: Grab screenname from tournament lobby?

Quote:
I started writing it but then I remembered that I don't even play on stars, so I don't wanna spend time finishing it. It works for most letters but the parser isn't complete. Should be simple enough to finish it (when an unknown letter is encountered a message pops up and the it's copied to the clipboard, so you can just paste it into the ParseStarseName function after the others), though it's too time consuming for my lazy ass.
This seems pretty interesting - I'll take a look at it over the next couple of days and see if I can finish it and package it up.
pokercurious is offline   Reply With Quote
Old 10-09-2008, 07:48 PM   #20
adept
 
Join Date: Apr 2007
Posts: 935
Re: PokerStars: Grab screenname from tournament lobby?

hmmm would you finish it for money?
Thois is offline   Reply With Quote
Old 10-10-2008, 02:55 PM   #21
journeyman
 
Join Date: Apr 2007
Location: So much to learn...
Posts: 359
Re: PokerStars: Grab screenname from tournament lobby?

Alright, so it's not completely finished, but it's got the basic functionality:

Just open a HUSNG lobby and press F12. The script will either:
  • copy the name to the clipboard
  • show you what it couldn't recognize and prompt you to add to the "letters.ahk" file

I'm still missing some letters (notably Q and q), and "l" and "I" are indistinguishable, so I default to "l". Also, there are times (especially with underscores and some of the skinnier letter ("i", "j", "t") where a couple of letters get scanned together. The best way to deal with that imo is just to add that scan into the letters.ahk file and let it encompass "ij" or whatever. (Just open the file to see what I mean). Finally, it's not that great at playing with some of the special characters (I'll work on this more later). You can enter -1 for any of the strange ones, and it'll just ignore those.

I plan on cleaning this up more and genericizing it to be able to be used more broadly - maybe i'll even try and implement some sharkscope stuff. We'll see what the weekend brings.

So please, play with it, break it, suggest improvements, what have you.

here's the main script:

Code:
#SingleInstance, force
#NoEnv 
SetWorkingDir %A_ScriptDir%  
SetTitleMatchMode, Regex



colors = 0xBCE1BF,0xDEC1A8,0xFFFFFF,0xFFFFEA,0xFFFFD5,0xBCFFFF,0xFFE1D5,0xFFE1BF,0xBCFFD5,0xDEE1D5,0xBCFFEA,0xDEE1BF,0xBCE1FF,0x99E1FF,0xDEFFFF,0x99C1EA,0x99E1EA,0x73C1EA,0x73C1FF
width = 124
height = 14


return


F12::
	if Lobby_hwnd := WinActive("Tournament \d+ Lobby")
		clipboard := ScrapeFirstNameFromTourneyLobby(Lobby_hwnd)
		Tooltip, Copied to clipboard: %clipboard%
		sleep 2500
		Tooltip
return


ScrapeFirstNameFromTourneyLobby(hwnd) {
	global colors, width, height
	#Include letters.ahk	
	ControlGetPos, x, y, w, h, PokerStarsListClass3, ahk_id %hwnd%	

	col = 0 
	spacecount = 0 
	Loop, %width%
	{   i := A_Index 
		matrix%i% = 0 
		Loop, %height%
		{   j := A_Index
			PixelGetColor, pcolor, x+i-1, y+j-1, RGB
			if pcolor in %colors%
			{	matrix%i% += 2**j
				spacecount=0
			}
		}
		if matrix%i% = 0
		{	if spacecount >= 3
			{	matrix%i% := -1
				spacecount = 0
			} else
				spacecount++
		}
	}

	Loop, %width%
	{	if matrix%A_Index% = -1
			letters .= "|one_space_|"
	    else
			letters .= matrix%A_Index% ? matrix%A_Index% . "_" : "|"
	}

	Loop, parse, letters, |
	{	if A_LoopField
		{	StringTrimRight, x, A_LoopField, 1
			
			if (%x% = "(")
				break				
			if %x% < 1
				continue
			if %x%
				name .= %x%
			else
			{	notfound .= x . " := `n"
				name .= "[ ]"
			}
		}
	}
	
	if notfound
	{	err := "The following codes were not recognized:`n`n"
			 . name . "`n`n" . notfound . "`n"
			 . "`nFigure out what the character(s) are and add them to the letters.ahk file."
		
		Gui, Add, Edit, ,% err
		Gui, Show, , some letters not found...
		return

		GuiClose:
			Gui, Destroy
		return		
	}
	return name
}
and here's the letters.ahk file:

Code:
2688_2368_320_3968 := "a"
3312_2112_2112_1152 := "b"
1920_2112_2112_2112_1024 := "c"
2112_2112_2032 := "d"
384_2368_2368_1408 := "e"
64_4080_80 := "f"
10112_10304_10304_6016 := "g"
3952_64_64_3968 := "h"
4048 := "i"
8192_8144 := "j"
4080_256_1024_2048 := "k"
4080 := "l"
3904_64_64_3840_64_64_3968 := "m"
3840_64_64_3968 := "n"
2112_2112_1920 := "o"
15168_2112_2112_1152 := "p"
3904_64_64 := "r"
2368_2368_2624_3712 := "s"
64_4080_2112 := "t"
4080_2112 := "t"
3008_2048_2048_960 := "u"
384_2048_512_384 := "v"
192_1536_3072_64_384_2048_1536_192 := "w"
2112_1216_768_896_3136 := "x"
64_8448_5120_1024_384 := "y"
8448_5120_1024_384 := "y"
3136_2624_2368_2240 := "z"
512_704_528_512_896_1536 := "A"
4080_2192_2192_2192_1888 := "B"
1632_2064_2064_2064_1056 := "C"
2064_2064_2064_2064_576 := "D"
2192_2192_2192_2192 := "E"
4080_144_144_144 := "F"
1632_2064_2064_2320_2320_1888 := "G"
4080_128_128_128_4080 := "H"
1024_2048_2048_2032 := "J"
3696_128_448_544_3088_2048 := "K"
4080_2048_2048_2048 := "L"
4048_32_1024_1024_32_48 := "M"
4064_64_384_1024_2032 := "N"
1632_2064_2064_2064_1056_960 := "O"
4080_272_272_272_224 := "P"
4080_272_272_784_2272_2048 := "R"
1216_2192_2192_2320_1280 := "S"
16_16_16_16_16_16 := "T"
2032_2048_2048_2048_1008 := "U"
16_96_768_3072_2048_384_96_16 := "V"
16_448_2048_512_48_16_256_3072_448_16 := "W"
2048_1072_576_128_512_16_2048 := "X"
16_32_64_3840_128_64_16_ := "Y"
2048_3088_2832_2192_2128_2064 := "Z"
4032_4128 := "("
8208_1024 := ")"
32_4080 := "1"
2064_2064_2320_2208 := "2"
2048_2064_2064_2320_2208 := "2"
2064_2064_2192_1376 := "3"
768_576_544_512 := "4"
2096_2192_2192_16 := "5"
896_288_2192_2192_1312 := "6"
16_1808_208_16 := "7"
3424_2192_2192_1376 := "8"
2480_2320_2320_672 := "9"
1632_2064_2064_960 := "0"
2224_2192_2192_1312 := "$"
2048 := "."
4048_8192_8144 := "ij"
4048_64_4080_2112 := "it"
4048_64_4080_2112_64_4080_2112 := "itt"
4080_272_272_784_2272_2048_64_4080_2112_16_32_64_3840_128_64_16 := "RtY"
4080_272_272_784_2272_2048_64_4080_2112 := "Rt"
64_4080_2112_16_32_64_3840_128_64_16 := "tY"
4080_272_272_784_2272_2048_1024_2048_2048_2032 := "RJ"
3904_64_64_3840_64_64_3968_64_8448_5120_1024_384 := "my"
16_2112_2128_1920 := "o"
64_4080_80_8192_8144 := "fj"
one_space := " "
128 := "-1"
32 := "-1"
pokercurious is offline   Reply With Quote
Old 10-10-2008, 06:16 PM   #22
centurion
 
flip for stacks?'s Avatar
 
Join Date: Jul 2008
Location: Gotham City
Posts: 170
Re: PokerStars: Grab screenname from tournament lobby?

does not work! returns "copied to clipboard: " and then nothing. I tried this method on Seeker but my problem was that Stars seems to change fonts or something, because I could never get consistent results. I'm currently working on a different method entirely, but it would be interesting if this was to work.

Last edited by flip for stacks?; 10-10-2008 at 06:30 PM.
flip for stacks? is offline   Reply With Quote
Old 10-10-2008, 06:51 PM   #23
journeyman
 
Join Date: Apr 2007
Location: So much to learn...
Posts: 359
Re: PokerStars: Grab screenname from tournament lobby?

Quote:
Originally Posted by flip for stacks? View Post
does not work! returns "copied to clipboard: " and then nothing. I tried this method on Seeker but my problem was that Stars seems to change fonts or something, because I could never get consistent results. I'm currently working on a different method entirely, but it would be interesting if this was to work.
could you (and perhaps others as well) post screenshots of the tournament lobby? i'd like to see if the colors that i'm using are the same for everyone.
pokercurious is offline   Reply With Quote
Old 10-10-2008, 07:58 PM   #24
centurion
 
flip for stacks?'s Avatar
 
Join Date: Jul 2008
Location: Gotham City
Posts: 170
Re: PokerStars: Grab screenname from tournament lobby?

Those will tend to artifact. WindowSpy shows the background behind the players name as Color: 0x787878 (Blue=78 Green=78 Red=78)
flip for stacks? is offline   Reply With Quote
Old 10-10-2008, 08:02 PM   #25
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK
Posts: 9,133
Re: PokerStars: Grab screenname from tournament lobby?

Quote:
Originally Posted by pokercurious View Post
could you (and perhaps others as well) post screenshots of the tournament lobby? i'd like to see if the colors that i'm using are the same for everyone.
Quote:
Originally Posted by flip for stacks? View Post
Those will tend to artifact.
PNG ftw.
_dave_ is offline   Reply With Quote
Old 10-11-2008, 04:50 AM   #26
journeyman
 
Join Date: Apr 2007
Location: So much to learn...
Posts: 359
Re: PokerStars: Grab screenname from tournament lobby?

Quote:
Originally Posted by flip for stacks? View Post
Those will tend to artifact. WindowSpy shows the background behind the players name as Color: 0x787878 (Blue=78 Green=78 Red=78)
you must be using the black theme, b/c 0x787878 is grey. my script as it is now is designed to work with the classic theme. try that and see what you get.


Last edited by pokercurious; 10-11-2008 at 04:56 AM.
pokercurious is offline   Reply With Quote
Old 10-11-2008, 11:50 PM   #27
centurion
 
flip for stacks?'s Avatar
 
Join Date: Jul 2008
Location: Gotham City
Posts: 170
Re: PokerStars: Grab screenname from tournament lobby?

Same results, with Color: 0x7A331E (Blue=7A Green=33 Red=1E)

This was one of the problems I had with my attempt at screen scraping and feeding into an OCR dll... they make -everything- fuzzy to prevent just this. In other words, PM or AIM me if you want to discuss this further, because Stars can see anything posted here and make everything break next update.
flip for stacks? is offline   Reply With Quote
Old 10-12-2008, 06:21 AM   #28
grinder
 
Join Date: May 2006
Location: Norway
Posts: 468
Re: PokerStars: Grab screenname from tournament lobby?

Turn off ClearType.
HalvSame is offline   Reply With Quote
Old 10-12-2008, 03:23 PM   #29
newbie
 
Join Date: Jun 2005
Posts: 16
Re: PokerStars: Grab screenname from tournament lobby?

I used the idea and rewrote the script. I added the following features:
-Inputbox for missing characters
-Get sharkscope stats for selected player in tournamentlobby when pressing F12 and save them in file.
-Display the sharkscoperesults in Traytip.
-Only get sharkscoperesults if results in file are older than 1 hour.

Don't know if I want it to post b/c of Stars TOC. If interested, please PM.
MrHaas is offline   Reply With Quote
Old 05-26-2012, 11:05 AM   #30
grinder
 
Join Date: Nov 2007
Posts: 605
Re: PokerStars: Grab screenname from tournament lobby?

Is anyone still using this script Or has a similar one that works?
chaosad is online now   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 01:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.
Copyright © 2008-2010, Two Plus Two Interactive