Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > German Forums > Internet/Online [German]
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 10-06-2007, 07:36 PM
happyhour456 happyhour456 is offline
Senior Member
 
Join Date: May 2006
Location: window shopping in amsterdam
Posts: 669
Default Re: ipoker skins and scripts?

; ========================================
; AHK Bet Pot Script for iPoker by butcha
; ----------------------------------------
; Includes mouse wheel functionality
; Supports both full view and mini view
; ----------------------------------------
; Latest version is available at:
; http://hem.passagen.se/perg/iPokerBetPot.txt
; ========================================
;
; INSTRUCTIONS:
; ----------------------------------------
; 1. Check the 'User Settings'-section below,
; so that all 3 options (WheelUnit,
; WhiteBetBox and ButtonsOnLeft) are ok.
; (Defaults should be working for most.)
; 2. Rename the script file so that it has the
; file extension .ahk.
; 3. Start the script.
; 4. Right click the mouse button anywhere on a
; iPoker table, where it's your turn to act,
; to set the betting box to a pot bet.
; 5. Scroll the mouse wheel up or down to change
; the betting amount.
;
;
; CONFIRMED SUPPORTED SKINS:
; ----------------------------------------
; - CD Poker
; - Expekt Poker
; - Noble Poker
; - Paddy Power Poker
; - Titan Poker
; Feel free to add to this list by contacting me.
;
;
; HOW DOES THE SCRIPT WORK?
; ----------------------------------------
; The short version is that it reads the pot size
; from the text on the table and it reads the call-
; and raise sizes from the text on the Call- and
; Raise-button respectively.
; If you are interested in a more technical
; explanation go to line 520 in this script.
;
;
; TROUBLESHOOTING:
; ----------------------------------------
; Since the script reads the text off the screen
; it is extremely important that the table you
; want to act on has both the pot size-text and
; the Call- and Raise-buttons fully visible.
; This includes overlay statistics programs like
; PokerAce Hud and GameTime+.
;
; The next thing to note is that I haven't tested
; this script with every iPoker skin out there.
; It should work with all skins that writes out
; the pot size, call size and raise size with one
; color only (although possibly a different one for
; each), no anti-aliasing and with the font
; Tahoma 11 pts.
; It also works on skins that use Tahoma, 12 pts
; bold to write out the call or raise size on the
; buttons in full view, which I believe most skins
; do.
;
; If you have changed the appearance of your iPoker
; table by modding the graphics-files the script
; should still be in effect, but this is not 100%.
;
; If you still have no success the best thing you
; can do is take a screenshot of the table in a
; situation where you would expect it to work.
; Save the image in a format without compression,
; like BMP or PNG. Then upload the screenshot
; somewhere and give me the link. I will not accept
; file transfers over Msn, but you can contact me
; for help.
;
; One last note. If the iPoker client ever gets
; redesigned, this script will stop working.
;
;
; KNOWN BUGS:
; ----------------------------------------
; - If you move the mouse wheel very fast
; there might be strange behavior
;
;
; CONTACT ME:
; ----------------------------------------
; 2+2 Forums Name: butcha
;
; All comments are welcome.
;
;
; ----------------------------------------
; ========================================
;
;
; ====================
; SCRIPT SETTINGS 1
; ====================
#NoEnv
#Persistent
#SingleInstance, Force
; ====================
; USER SETTINGS
; ====================
; Mouse Wheel Unit
; --------------------
; The amount your bet changes up or down
; when you scroll the wheel. This value
; can be either the words sb or bb, or a
; number, e.g. 0.50 or 10
WheelUnit = bb
; --------------------
; White Betting Box
; --------------------
; Set this value to 1 if the background of the
; box where you type in your bets is white.
; Change this to 0 if the background is NOT white.
; If you don't have a white background the script
; may send the betting amount to the chat-box if
; you act out of turn, no matter of this setting.
; (Note 1: White means the exact color 0xFFFFFF.)
; (Note 2: This setting has no effect if the area
; behind the betting box is always white.)
WhiteBetBox := 1
; --------------------
; Buttons On Left
; --------------------
; This option is only for those of you playing
; at a skin where the Action-buttons (Fold, Call,
; Raise) and the box where you type in your bets
; is more to the left than most skins.
; If you do, set this option to 1.
; The only skin I know so far that this applies
; to is BetFred Poker.
; The default is 0 (zero).
; This setting ONLY effects full view.
ButtonsOnLeft := 0
; ====================
; ERROR CHECK USER SETTINGS
; ====================
If (WheelUnit != "sb" AND WheelUnit != "bb")
If WheelUnit Is Not Number
{
MsgBox, 16, Configuration error,
(LTrim
Check the 'User settings'-section at the top of the script.
The variable WheelUnit must be either the words sb or bb or a number.
)
ExitApp
}
; --------------------
If (WhiteBetBox != 0 AND WhiteBetBox != 1)
{
MsgBox, 16, Configuration error,
(LTrim
Check the 'User settings'-section at the top of the script.
The variable WhiteBetBox must be 1 for a white betting
box background and 0 for a non-white betting box background.
)
ExitApp
}
; --------------------
If (ButtonsOnLeft != 0 AND ButtonsOnLeft != 1)
{
MsgBox, 16, Configuration error,
(LTrim
Check the 'User settings'-section at the top of the script.
The variable ButtonsOnLeft must be 0 for most skins and 1
ONLY for those skins that have Action buttons more to the
left, like for example BetFred Poker.
)
ExitApp
}
; --------------------
; ====================
; SCRIPT SETTINGS 2
; ====================
SetBatchLines, -1
SetKeyDelay, -1
SetMouseDelay, -1
SetWinDelay, -1
SetTitleMatchMode, 2
SendMode, Input
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
; ====================
; GLOBAL VARIABLES
; ====================
SysGet, Sb, 7
SysGet, Sc, 4
TableSize := 0
PotTextColor := 0x0
CallTextColor := 0x0
RaiseTextColor := 0x0
MouseX := 0
MouseY := 0
BetSize := 0
ButtonOffset := -18*ButtonsOnLeft
; ====================
Return
; HOT KEYS
; ====================
; Right Mouse Button
; --------------------
~RButton::
BetPot()
Return
; --------------------
; Mouse Wheel Up
; --------------------
~WheelUp::
ChangeBet(1)
Return
; --------------------
; Mouse Wheel Down
; --------------------
~WheelDown::
ChangeBet(-1)
Return
; --------------------
; ====================
; MAIN FUNCTIONS
; ====================
; Bet Pot
; --------------------
; Sets the betting box to a pot size bet.
BetPot()
{
global
Id := GetTableId()
If (NOT Id)
Return

TableSize := GetTableSize(Id)
If (NOT TableSize)
Return

If (WhiteBetBox AND NOT WhiteBetBoxVisible())
Return

PotTextColor := GetPotTextColor()
PotLocationFound := GetPotLocation()
If (NOT PotLocationFound)
Return

PotSize := GetPotSize()
If (NOT PotSize)
Return

CallTextColor := GetCallTextColor()

CallLocationFound := GetCallLocation()
If (CallLocationFound)
CallSize := GetCallSize()
Else
CallSize := 0

BetSize := FormatBet(PotSize + 2*CallSize)

SaveMousePos()
SetBet(BetSize)
RestoreMousePos()
}
; --------------------
; Change Bet
; --------------------
; Changes the bet by the parameter unit multiplied
; by WheelUnit, as specified at the top of the script
ChangeBet(unit)
{
global
Id := GetTableId()
If (NOT Id)
Return

TableSize := GetTableSize(Id)
If (NOT TableSize)
Return

If (WhiteBetBox AND NOT WhiteBetBoxVisible())
Return

RaiseTextColor := GetRaiseTextColor()

RaiseLocationFound := GetRaiseLocation()
If (NOT RaiseLocationFound)
Return

RaiseSize := GetRaiseSize()
If (NOT RaiseSize)
Return


If WheelUnit Is Number
{
BetSize := FormatBet(RaiseSize + unit*WheelUnit)
} Else
{
Blind := GetBlind(Id,WheelUnit)
BetSize := FormatBet(RaiseSize + unit*Blind)
}

SaveMousePos()
SetBet(BetSize)
RestoreMousePos()
}
; --------------------
; ====================
; HELP FUNCTIONS
; ====================
; Get Table Id
; --------------------
; Returns the unique ID number of the window under
; the mouse if it is a iPoker table. If it is not
; the return value is zero.
GetTableId()
{
MouseGetPos, ,,id
WinGet, id, ID, - ahk_id %id% ahk_class PTIODEVICE
Return id
}
; --------------------
; Get Table Size
; --------------------
; Returns the position and size of a iPoker table.
; The size can take on one of three values, 1 for
; a full view table, 2 for a mini view table and
; 0 if the table size could not be determined.
; The parameter is the unique ID number of a table-
; window.
GetTableSize(id)
{
global Vx,Vy,Sb,Sc
WinGetPos, Vx,Vy,Width,Height, ahk_id %id%
Vx += Sb
Vy += Sb+Sc
Width -= (2*Sb)
Height -= (2*Sb+Sc)

If Width Between 798 And 802
If Height Between 598 And 602
Return 1

If Width Between 510 And 514
If Height Between 322 And 326
Return 2

Return 0
}
; --------------------
; White Bet Box Visible
; --------------------
; Self-explanatory.
; Returns True if a White Betting Box is visible,
; otherwise it returns False.
WhiteBetBoxVisible()
{
global TableSize,Vx,Vy
If (TableSize = 1)
{
PixelSearch, ,,Vx+557,Vy+462,Vx+601,Vy+472, 0xFFFFFF, 0, RGB
If (ErrorLevel = 0)
Return True
Else
Return False
}
If (TableSize = 2)
{
PixelSearch, ,,Vx+401,Vy+266,Vx+436,Vy+272, 0xFFFFFF, 0, RGB
If (ErrorLevel = 0)
Return True
Else
Return False
}
Return False
}
; --------------------
; Get Pot Text Color
; --------------------
; Self-explanatory.
GetPotTextColor()
{
global
If (TableSize = 1)
{
Return % GetOddColor(Vx+359,Vy+131,40,8)
}
If (TableSize = 2)
{
Return % GetOddColor(Vx+51,Vy+28,24,12)
}
Return 0
}
; --------------------
; Get Call Text Color
; --------------------
; Self-explanatory.
GetCallTextColor()
{
global
If (TableSize = 1)
{
Return % GetOddColor(Vx+414+ButtonOffset,Vy+513,24,12)
}
If (TableSize = 2)
{
Return % GetOddColor(Vx+296,Vy+293,24,12)
}
Return 0
}
; --------------------
; Get Raise Text Color
; --------------------
; Self-explanatory.
GetRaiseTextColor()
{
global
If (TableSize = 1)
{
Return % GetOddColor(Vx+541+ButtonOffset,Vy+513,24,12)
}
If (TableSize = 2)
{
Return % GetOddColor(Vx+386,Vy+293,24,10)
}
Return 0
}
; --------------------
; Get Pot Size
; --------------------
; Self-explanatory.
GetPotSize()
{
global Px,Py,Pw,Ph,PotTextColor
If (Ph = 10)
{
GetTextMatrix("st",Px,Py,Pw,Ph,PotTextColor)
Return % ParseSmallTextMatrix()
}
Return 0
}
; --------------------
; Get Call Size
; --------------------
; Self-explanatory.
GetCallSize()
{
global Cx,Cy,Cw,Ch,CallTextColor
If (Ch = 11)
{
GetTextMatrix("lt",Cx,Cy,Cw,Ch,CallTextColor)
Return % ParseLargeTextMatrix()
} Else If (Ch = 10)
{
GetTextMatrix("st",Cx,Cy,Cw,Ch,CallTextColor)
Return % ParseSmallTextMatrix()
}
Return 0
}
; --------------------
; Get Raise Size
; --------------------
; Self-explanatory.
GetRaiseSize()
{
global Rx,Ry,Rw,Rh,RaiseTextColor
If (Rh = 11)
{
GetTextMatrix("lt",Rx,Ry,Rw,Rh,RaiseTextColor)
Return % ParseLargeTextMatrix()
} Else If (Rh = 10)
{
GetTextMatrix("st",Rx,Ry,Rw,Rh,RaiseTextColor)
Return % ParseSmallTextMatrix()
}
Return 0
}
; --------------------
; Get Blind
; --------------------
; Returns the big or small blind.
; The type parameter can be "bb" or "sb".
GetBlind(id,type)
{
WinGetTitle, title, ahk_id %id%
If InStr(title, "/$") {
StringGetPos, s1, title, $
StringGetPos, s2, title, $,, s1+1
StringGetPos, s3, title, %A_Space%,, s2
If (s3 = -1) {
StringLen, s3, title
}
StringMid, sb, title, s1+2,s2-s1-2
StringMid, bb, title, s2+2,s3-s2-1
} Else {
StringLen, len, title
StringGetPos, s1, title, /
StringGetPos, s2, title, %A_Space%, R, len-s1
StringGetPos, s3, title, %A_Space%,, s1
If (s3 = -1) {
s3 := len
}
StringMid, sb, title, s2+2,s1-s2-1
StringMid, bb, title, s1+2,s3-s1-1
}
StringReplace, sb, sb, `,,
StringReplace, bb, bb, `,,

val := %type%
If val Is Not Number
Return 0

Return val
}
; --------------------
; Format Bet
; --------------------
; Returns 0 if the parameter is less than 0,
; otherwise it formats the input so that it has
; 2 decimals if it is a floating point.
; Integers are not altered.
FormatBet(bet)
{
If (bet < 0)
Return 0

If bet Is Float
{
OldFormat := A_FormatFloat
SetFormat, Float, 0.2
bet += 0.0
SetFormat, Float, %OldFormat%
}
Return bet
}
; --------------------
; Set Bet
; --------------------
; Sets the betting box at the iPoker table
; to be the specified parameter.
SetBet(bet)
{
global TableSize,Vx,Vy,ButtonOffset
If (TableSize = 1)
MouseMove, Vx+597+ButtonOffset,Vy+472
Else If (TableSize = 2)
MouseMove, Vx+432,Vy+270
Else
Return

Click, Left 2
Send, %bet%
}
; --------------------
; Save Mouse Position
; --------------------
SaveMousePos()
{
global MouseX,MouseY
MouseGetPos, MouseX,MouseY
}
; --------------------
; Restore Mouse Position
; --------------------
RestoreMousePos()
{
global MouseX,MouseY
MouseMove, MouseX,MouseY
}
; --------------------
; ====================
; COLOR & PIXEL FUNCTIONS
; ====================
; Here follows a more detailed explanation of how this script works. I have chosen to write
; this section mostly because I am more interested in the technical aspects of this script
; than its functionality. Also, if someone out there tries to modify this script it will
; be a lot easier if I provide comments here.
;
; Basically what this script does is read the color of each pixel in a specific area and
; match the result to a known color, thus extracting only wanted pixels.
; These pixels can then be matched to a known pattern to produce numbers.
;
; STEP 1:
; Identify the color of the text.
; This is done by the help of the GetOddColor-method. What this method does is extract
; the color in a specified area, which differs the MOST from the average color in that
; area. If the area only consist of 2 colors it will yield the one with the least amount
; of pixels.
;
; STEP 2:
; Locate the pot-, call- and/or raise-text on screen.
; Here we use the GetColorBounds-method. This method gives us the bounding rectangle of
; a specific color within a specific area. In other words, it gives us the smallest
; possible rectangle that contains ALL the pixels of the input-color within the input-area.
;
; STEP 3:
; Retrieve the pot/call/raise text
; This is done in two steps:
; Step 3.A) Read the pixel color of every pixel within the area from Step 2.
; Getting the pixel information is a piece of cake. Storing it in a way that makes sense
; is somewhat harder. What I have chosen to do is to store each pixel that corresponds to
; my text color as a 1 and each pixel that doesn't as a 0.
; I store the information in a numbered variable for each pixel column in the area.
; This variable is made to 0 before start and then I use bitwise-or to change the
; corresponding bit in the variable to a 1.
; The method GetTextMatrix is used for this step.
; Step 3.B) Transform this pixel information into numbers
; This is the step that probably makes the least sense when looking at the code, but once
; you know what bits are and how they are used it's pretty easy.
; From the last step we have all the information needed stored as arrays of 1's and 0's,
; but how? Well, the information is really not interpreted as an array of 1's and 0's,
; but instead as an integer. If you are familiar with computer arithmetic you know that!
; We can then simply figure out what value each column must take to match a certain number
; and Tada!, we have our number!
; Let's take the number 4 as an example:
; Here is how it is stored in step 3.A (assuming Tahoma 11pts):
; Column 1: 00011000
; Column 2: 00101000
; Column 3: 01001000
; Column 4: 11111111
; Column 5: 00001000
; If this makes no sense, let's turn it, flip it and change the 1's and 0's to something pretty:
; Column: 54321
; ---M-
; --MM-
; -M-M-
; M--M-
; MMMMM
; ---M-
; ---M-
; It's a freaking four!!
; If we now go back to the columns we note that each column is a binary number. Some simple
; binary arithmetic gives us:
; 00011000 = 24,
; 00101000 = 40,
; 01001000 = 72,
; 11111111 = 255,
; 00001000 = 8
; And these are the numbers we use to match the columns in the ParseSmallText.
; The ParseLargeText-method works exactly the same, but for use with Tahoma, 12pts bold.
;
GetOddColor(X,Y,Width,Height)
{
odd_color := 0
colors := ""
reds := 0x0
greens := 0x0
blues := 0x0
count := 0
Loop, %Width%
{
sx := X+A_Index-1
Loop, %Height%
{
sy := Y+A_Index-1
PixelGetColor, px_color, sx,sy, RGB

If (NOT InStr(colors,px_color))
{
px_r := SubStr(px_color, 1, 4)
px_g := "0x" . SubStr(px_color, 5, 2)
px_b := "0x" . SubStr(px_color, 7, 2)

reds += px_r
greens += px_g
blues += px_b

colors := colors . "`n" . px_color
count++
}
c%px_color%++
}
}
red_avg := reds / count
green_avg := greens / count
blue_avg := blues / count

StringTrimLeft, colors, colors, 1

If (StrLen(colors) < 20)
{
min_px_count := 99999
Loop, Parse, colors, `n
{
If (A_LoopField != "")
{
If (c%A_LoopField% < min_px_count)
{
min_px_count := c%A_LoopField%
odd_color := A_LoopField
}
}
}
Return odd_color
}

max_variation := 0

Loop, Parse, colors, `n
{
If (A_LoopField != "")
{
px_r := SubStr(A_LoopField, 1, 4)
px_g := "0x" . SubStr(A_LoopField, 5, 2)
px_b := "0x" . SubStr(A_LoopField, 7, 2)

SetFormat, Integer, D
px_r += 0
px_g += 0
px_b += 0

red_var := Sqrt( (red_avg - px_r)**2 )
green_var := Sqrt( (green_avg - px_r)**2 )
blue_var := Sqrt( (blue_avg - px_r)**2 )

variation := (red_var + green_var + blue_var) / 3
If (variation > max_variation)
{
max_variation := variation
odd_color := A_LoopField
}
c%A_LoopField% := 0
}
}
Return odd_color
}
; --------------------
; Get Pot Location
; --------------------
; Returns the boundaries for the rectangle
; around the Pot size-text
GetPotLocation()
{
global TableSize,Vx,Vy,PotTextColor,Px,Py,Pw,Ph
If (TableSize = 1)
{
PotFound := GetColorBounds("P",Vx+403,Vy+127,90,16,PotTextColo r)
If (NOT PotFound)
Return False

Pw++
If (Ph = 11)
Ph--
Else If (Ph = 10)
Py--
Else If (Ph = 9)
Ph++
Else If (Ph = 8)
{
Ph += 2
Py--
} Else
Return False

Return True
}
If (TableSize = 2)
{
PotFound := GetColorBounds("P",Vx+45,Vy+28,58,12,PotTextColor)
If (NOT PotFound)
Return False

Pw++
If (Ph = 11)
Ph--
Else If (Ph = 10)
Py--
Else If (Ph = 9)
Ph++
Else If (Ph = 8)
{
Ph += 2
Py--
} Else
{
Px := 0
Py := 0
Pw := 0
Ph := 0
Return False
}

Return True
}
Return False
}
; --------------------
; Get Call Location
; --------------------
; Returns the boundaries for the rectangle
; around the Call size-text
GetCallLocation()
{
global TableSize,Vx,Vy,ButtonOffset,CallTextColor,Cx,Cy,C w,Ch
If (TableSize = 1)
{
CallFound := GetColorBounds("C",Vx+386+ButtonOffset,Vy+510,80,1 8,CallTextColor)
If (NOT CallFound)
Return False

Cx--
Cw += 2

If (Ch = 13)
{
Cy++
Ch -= 2
} Else If (Ch = 12 OR Ch = 11)
{
Ch--
} Else If (Ch = 9 OR Ch = 8)
{
Cy--
Ch += 2
} Else
{
Cx := 0
Cy := 0
Cw := 0
Ch := 0
Return False
}

Return True
}
If (TableSize = 2)
{
CallFound := GetColorBounds("C",Vx+270,Vy+292,77,18,CallTextCol or)
If (NOT CallFound)
Return False

Cx--
Cw += 2
If (Ch = 11)
Ch--
Else If (Ch = 10)
Cy--
Else If (Ch = 9)
Ch++
Else If (Ch = 8)
{
Ch += 2
Cy--
} Else
{
Cx := 0
Cy := 0
Cw := 0
Ch := 0
Return False
}

Return True
}
Return False
}
; --------------------
; Get Raise Location
; --------------------
; Returns the boundaries for the rectangle
; around the Raise size-text
GetRaiseLocation()
{
global TableSize,Vx,Vy,ButtonOffset,RaiseTextColor,Rx,Ry, Rw,Rh
If (TableSize = 1)
{
RaiseFound := GetColorBounds("R",Vx+513+ButtonOffset,Vy+510,80,1 8,RaiseTextColor)
If (NOT RaiseFound)
Return False

Rx--
Rw += 2
If (Rh = 13)
{
Ry++
Rh -= 2
} Else If (Rh = 12 OR Rh = 11)
{
Rh--
} Else If (Rh = 9 OR Rh = 8)
{
Rh += 2
Ry--
} Else
{
Rx := 0
Ry := 0
Rw := 0
Rh := 0
Return False
}

Return True
}
If (TableSize = 2)
{
RaiseFound := GetColorBounds("R",Vx+360,Vy+292,77,12,RaiseTextCo lor)
If (NOT RaiseFound)
Return False

Rx--
Rw += 2
If (Rh = 11)
Rh--
Else If (Rh = 10)
Ry--
Else If (Rh = 9)
Rh++
Else If (Rh = 8)
{
Rh += 2
Ry--
} Else
{
Rx := 0
Ry := 0
Rw := 0
Rh := 0
Return False
}

Return True
}
Return False
}
; --------------------
; Get Color Bounds
; --------------------
; Calculates the smallest possible rectangle
; that encloses all the pixels within the
; provided area of the provided color.
; The result is stored in variables with the
; provided prefix.
GetColorBounds(prefix,X,Y,Width,Height,Color)
{
global
local min_x,max_x,min_y,max_y,i
min_x := 9999
max_x := 0
min_y := 9999
max_y := 0
Loop, %Width%
{
i := A_Index - 1
PixelSearch, ,, X+i,Y,X+i,Y+Height-1, %Color%, 0, RGB
If (ErrorLevel = 0)
{
If (i < min_x)
min_x := i
If (i > max_x)
max_x := i
}
}
If (min_x >= max_x OR max_x = 9999)
{
%prefix%x := 0
%prefix%y := 0
%prefix%w := 0
%prefix%h := 0
Return False
}
%prefix%x := X + min_x
%prefix%w := max_x - min_x + 1

Loop, %Height%
{
i := A_Index - 1
PixelSearch, ,, %prefix%x,Y+i,%prefix%x+%prefix%w,Y+i, %Color%, 0, RGB
If (ErrorLevel = 0)
{
If (i < min_y)
min_y := i
If (i > max_y)
max_y := i
}
}
If (min_y >= max_y OR max_y = 9999)
{
%prefix%x := 0
%prefix%y := 0
%prefix%w := 0
%prefix%h := 0
Return False
}
%prefix%y := Y + min_y
%prefix%h := max_y - min_y + 1

Return True

}
; --------------------
; Get Text Matrix
; --------------------
; Returns a matrix where each element is a 1
; if the corresponding pixel in the provided
; area is the provided color. If it is not
; the element is 0.
; The result is stored in separate variables
; for each column of the matrix.
; The col-variable contains the number of
; columns and the sep-variable contains a string
; with each column number in the matrix that
; is only zeros.
; The variables begin with the provided prefix.
GetTextMatrix(prefix,X,Y,Width,Height,Color)
{
global
local col,i,j,px_color
col := 0
%prefix%_sep := 0
Loop, %Width%
{
col++
%prefix%_col%col% := 0
i := A_Index - 1
Loop, %Height%
{
j := A_Index - 1
PixelGetColor, px_color, X+i,Y+j, RGB
If (px_color = Color)
{
%prefix%_col%col% := %prefix%_col%col% | 2**(Height-j-1)
}
}
If (%prefix%_col%col% = 0)
{
%prefix%_sep := %prefix%_sep . "`n" . col
}
}
%prefix%_col := col
}
; --------------------
; Parse Small Text Matrix
; --------------------
; Parses a text matrix with pixel information.
; The font is Tahoma, 11 pts.
ParseSmallTextMatrix()
{
global
local number,this,next,a,b,c,d,e
number := ""
StringSplit, st_sep, st_sep, `n
If (st_sep0 > 1)
{
Loop, %st_sep0%
{
If (A_Index = %st_sep0%)
Break

this := st_sep%A_Index%
next := A_Index + 1
next := st_sep%next%
If (this = next)
Continue

If (this + 2 = next)
{
a := this + 1
a := st_col%a%
If (a = 6)
number := number . "."
}
If (this + 4 = next)
{
a := this + 1
a := st_col%a% >> 1
b := this + 2
b := st_col%b% >> 1
c := this + 3
c := st_col%c% >> 1
If (a = 65 AND b = 255 AND c = 1)
number := number . "1"
}
If (this + 6 = next)
{
a := this + 1
a := st_col%a% >> 1
b := this + 2
b := st_col%b% >> 1
c := this + 3
c := st_col%c% >> 1
d := this + 4
d := st_col%d% >> 1
e := this + 5
e := st_col%e% >> 1
If (a = 67 AND b = 133 AND c = 137 AND d = 145 AND e = 97)
number := number . "2"
If (a = 66 AND b = 129 AND c = 145 AND d = 145 AND e = 110)
number := number . "3"
If (a = 24 AND b = 40 AND c = 72 AND d = 255 AND e = 8)
number := number . "4"
If (a = 242 AND b = 145 AND c = 145 AND d = 145 AND e = 142)
number := number . "5"
If (a = 62 AND b = 81 AND c = 145 AND d = 145 AND e = 14)
number := number . "6"
If (a = 128 AND b = 131 AND c = 140 AND d = 176 AND e = 192)
number := number . "7"
If (a = 110 AND b = 145 AND c = 145 AND d = 145 AND e = 110)
number := number . "8"
If (a = 112 AND b = 137 AND c = 137 AND d = 138 AND e = 124)
number := number . "9"
If (a = 126 AND b = 129 AND c = 129 AND d = 129 AND e = 126)
number := number . "0"
}
}
}
Loop, %st_col%
{
st_col%A_Index% := 0
}
If number is Number
Return number

Return 0
}
; --------------------
; Parse Large Text Matrix
; --------------------
; Parses a text matrix with pixel information.
; The font is Tahoma, 12 pts bold. Although
; the digit 2 is missing 1 pixel. Don't ask me
; why.
ParseLargeTextMatrix()
{
global
local number,this,next,a,b,c,d,e,f,g
number := ""
StringSplit, lt_sep, lt_sep, `n
If (lt_sep0 > 1)
{
Loop, %lt_sep0%
{
If (A_Index = %lt_sep0%)
Break

this := lt_sep%A_Index%
next := A_Index + 1
next := lt_sep%next%
If (this = next)
Continue

If (this + 3 = next)
{
a := this + 1
a := lt_col%a%
b := this + 2
b := lt_col%b%
If (a = 6 AND b = 6)
number := number . "."
}
If (this + 7 = next)
{
a := this + 1
a := lt_col%a% >> 1
b := this + 2
b := lt_col%b% >> 1
c := this + 3
c := lt_col%c% >> 1
d := this + 4
d := lt_col%d% >> 1
e := this + 5
e := lt_col%e% >> 1
f := this + 6
f := lt_col%f% >> 1
If (a = 129 AND b = 129 AND c = 511 AND d = 511 AND e = 1 AND f = 1)
number := number . "1"
}
If (this + 8 = next)
{
a := this + 1
a := lt_col%a% >> 1
b := this + 2
b := lt_col%b% >> 1
c := this + 3
c := lt_col%c% >> 1
d := this + 4
d := lt_col%d% >> 1
e := this + 5
e := lt_col%e% >> 1
f := this + 6
f := lt_col%f% >> 1
g := this + 7
g := lt_col%g% >> 1
If (a = 193 AND b = 259 AND c = 263 AND d = 269 AND e = 281 AND f = 497 AND g = 225)
number := number . "2"
If (a = 130 AND b = 257 AND c = 273 AND d = 273 AND e = 273 AND f = 511 AND g = 238)
number := number . "3"
If (a = 24 AND b = 40 AND c = 72 AND d = 136 AND e = 511 AND f = 511 AND g = 8)
number := number . "4"
If (a = 2 AND b = 481 AND c = 481 AND d = 289 AND e = 289 AND f = 319 AND g = 286)
number := number . "5"
If (a = 126 AND b = 255 AND c = 417 AND d = 289 AND e = 289 AND f = 319 AND g = 30)
number := number . "6"
If (a = 256 AND b = 256 AND c = 263 AND d = 287 AND e = 376 AND f = 480 AND g = 384)
number := number . "7"
If (a = 238 AND b = 511 AND c = 273 AND d = 273 AND e = 273 AND f = 511 AND g = 238)
number := number . "8"
If (a = 240 AND b = 505 AND c = 265 AND d = 265 AND e = 267 AND f = 510 AND g = 252)
number := number . "9"
If (a = 254 AND b = 511 AND c = 257 AND d = 257 AND e = 257 AND f = 511 AND g = 254)
number := number . "0"
}
}
}
Loop, %lt_col%
{
lt_col%A_Index% := 0
}
If number is Number
Return number

Return 0
}
; --------------------
; ====================
; END OF SCRIPT
; ====================
Reply With Quote
 


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

Forum Jump


All times are GMT -4. The time now is 09:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.