#11
|
|||
|
|||
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 ; ==================== |
#12
|
|||
|
|||
Re: ipoker skins and scripts?
achja, wenn jmd die Functions.ahk braucht, dann bitte bescheid sagen. dann poste ich die auch noch.
|
#13
|
|||
|
|||
Re: ipoker skins and scripts?
ich kann ohne diese Script gar nicht mehr zocken.. übelst hilfreich
|
#14
|
|||
|
|||
Re: ipoker skins and scripts?
vielen dank happyhour... werd ich gleich morgen ausprobieren!
|
#15
|
|||
|
|||
Re: ipoker skins and scripts?
mousewheel klappt schon mal
|
#16
|
|||
|
|||
Re: ipoker skins and scripts?
bet pot leider noch nicht..
|
#17
|
|||
|
|||
Re: ipoker skins and scripts?
was bedeutet/kann die functions.ahk??
|
#18
|
|||
|
|||
Re: ipoker skins and scripts?
die functions.ahk ist quasi eine bibliothek mit bereits geschriebenen funktionen. die muss in dem gleichen ordner sein, wie das script, was ausgeführt wird und auf die functions.ahk zu greifen will. die muss also nicht extra ausgeführt werden.
functions.ahk: ; ##### RolandsFunctions ##### ; date: 9:00 PM Tuesday, July 24, 2007 ; version: 2.15 ; authors: Roland & many others ; ### Overview ### /* ;----- Miscellanious ----- IsCompiled() CheckAHKVersion(req) Tip(text,timeout="",x="",y="") IsIn(var,matchlist) Contains(var,matchlist) Web() iif(_boolExpr, _exprTrue, _exprFalse) JoyExist() CleanHotkey(k) Random(min,max,newSeed="") IsBetween(var, lower, upper) FontList() CreateDFCFile(file) DrawFrame(frame=0, x=0, y=0, w=0, h=0, t=0, c=0) Gradient(File, RGB1, RGB2, Vertical=1) Eval(x) ExitMsg() DigitSearch(startX,startY,endX,endY,win,dir,ex="", shades=100) PostLeftClick(x, y, table_id, activate=1) osd(msg="", options="", font="", gui=92) osdEx(msg="", options="", font="", x=0, y=0, gui=91) SectionToTheme( ini, section ) ThemeToSection( ini, section ) ProcessCreationTime(pid) GetPriority(process="") psql(sql, database="", debug=0, host="", username="") CaptureScreen(aRect, bCursor = False, sFile = "") toggleCursor() ;----- Mouse ----- mouseGetX() mouseGetY() mouseGetWin() mouseGetCtrl() toggleCursor() ;----- Gui ----- SetParent(win, gui) LV_GetTxt(row,column) TV_GetTxt(id) FreeGui() ForceOS(x, y, title, NA=0, offSetX=0, offSetY=0) SetGuiPos(owner, x="",y="") SetOwner(options="") MouseOver() AddCustomFrame(iPaths, title="", toolwindow=0, resize=0, pIcon="") InsertIntegerAtAddress(pInteger, pAddress, pOffset = 0, pSize = 4) ;----- Strings ----- StrRep(str,char,rep_char="",all=1) StrMid(str,str1,str2,startPos1=1,startPos2=1,caseS ense=0) StrLeft(str,count) StrSlice(str,len,del="") TrimWhiteSpace(str) TabsToSpaces(c, spaces=2) ExtractNum(str,start=0) StrEnd(O,str) StrUpper(str) StrLower(str) varize(var, autofix = true) InStrX(h, n, LR# = "", of = 0) SymbolsToKeys(s) ;----- Lists ----- AddToList(list,item,del="") ExFromList(list,pos=1,del="") RemoveFromList(list,item=1,del="") RemoveItemNFromList(list,n,del="") GetItemPos(list,item,del="") InsertItem(list,item,pos,del="") CleanList(list, del="") List_longest(list, del="") min(list, del="") max(list, del="") ;----- Controls ----- CtrlGetTxt(ctrl,win,matchMode=1) IsVisCtrl(ctrl,win,matchMode=1) IsDisabledCtrl(ctrl,win,matchMode=1) CtrlGetHwnd(ctrl,win,matchMode=1) CtrlGetStyle(ctrl,win,matchMode=1) CtrlGetExStyle(ctrl,win,matchMode=1) ToggleCheckbox(ctrl, win, matchMode=1) IsCheckedCtrl(ctrl, win, matchMode=1) FocusedCtrl() CtrlWaitVis(ctrl,win="",timeout="") CtrlClick(ctrl,win,matchMode=1) CtrlCheck(ctrl, win, matchMode=1) CtrlUncheck(ctrl, win, matchMode=1) FrameAroundCtrl(ctrl,win,frame="",width=5,color="" ) ;----- Files ----- FileRead(file) FileReadLine(file,line) FileSelectFile(Options="",RootDir="",Prompt="",Fil ter="") IniRead(file,section,key,def="") CreateCustomFile(file,dir) SplitCustomFile(file,dir) WriteFile(file,data) FileSave(str, file) ;----- Pixel ----- PixelGetColor(x,y,options="") GetPixelCount(x1,y1,x2,y2,color,options="") GetPredominateColor(x1,y1,x2,y2,options="") BGRToRGB(c) ;----- Windows ----- WinMinMax(id) WinWaitStatic(win,int=1000,timeout="") FrameAroundWin(win, t=10) ConfirmDialogue(title,txt="",timeout=5,extitle="", exTxt="") IsWinInTray(title) RemoveMinimizedTables(list) WinGetTitle(win) WindowFromPoint(x, y) Border() Caption() getClientRect(byRef x, byRef y, byRef w, byRef h, hwnd="") ;----- Poker - General ----- LobbyIdParty() LobbyIdStars() LobbyIDFullTilt() LobbyIDAbsolute() LobbyIDPacific() LobbyIDParadise() LobbyIDBetfair() LobbyIDPokerRoom() TableIDListParty(lobbyID) TableIDListStars(lobbyID) TableIDListFullTilt(LobbyID) TableIDListAbsolute(LobbyID) TableIDListPacific(lobbyID) TableIDListParadise(lobbyID) TableIDListBetfair(lobbyID) TableIDListPokerRoom(lobbyID) tablesParty() tablesStars() tablesFullTilt() tablesAbsolute() tablesPacific() tablesParadise() tablesBetfair() tablesPokerRoom() GetBBParty(id, game_type) GetBBStars(id) GetBBFullTilt(id) GetBBParadise(id) GetBBPacific(id) GetBBBetfair(id) GetBBPokerRoom(id) GameTypeParty(title) GameTypeStars(title) GameTypeFullTilt(title) GameTypeParadise(title) GameTypePacific(title) GameTypeBetfair(title) GameTypePokerRoom(title) PotParadise(id) PotFullTilt(id) PotBetfair(id) PotPokerRoom(id) sb(bb) StartImport(stud=false) ToggleImport(stud=false) ForceImport(seconds=10, stud=false) KillToolbar() PTNotesExport(stud=false) tableNav() PostAbsClick(x, y, win) ;----- Poker - Stars ----- HHFileStars(win, dir) SeatsStacksNamesStars(hh, win) StackStars(hh, sn) DollarsWonStars(hh, sn) GetKnownHandsStars(hh) PotStars(win, frac=1, round=2, openAd="" , openAdblinds="", autoBet=0, maxRake=3) LimpersStars(pot, bb) IAmBlindsStars(call, bb) IsRaisedStars(win, call) IsPreflopStars(win) SetTextStars(id, dir, frac=1, unit="") IsStudHHStars(hh) Is6maxHHStars(hh) Is9maxHHStars(hh) instantHHStars(hh, x, y, dir, dirStud="", theme="", font="", bgColor="" , 4color=1, colorStreet=0, colorPlayers=0, colorAction=0, colorCards=0) LastHHStars(win, dir) RebuyMaxStars(win) RebuyStars(win, bb) bbStars(win) IdHHStars(hh) SizeStarsTable(w, win) IsPlayerOnlineStars(player) PostStarsClick(x, y, win) ;----- Poker - Party ----- HH(file, id) HHFile(win, exe, format="") GetPartyDate(exe, screenName) HandID(win) LastHandID(win) MyScreenName(win) SeatsStacksNames(hh, win) GetKnownHands(hh) Is6max(win) GetChatParty(id) GetChatByID(id, hand) InvestedLastHand(hh, player) InvestedLastHandSNG(hh, player) IsButtonCheckedParty(ctrl,win,matchMode=1) PotParty(id, frac=1, round=2, openAd=0 , openAdblinds="", autoBet=0, maxrake=3) IsPreflop(hh) IsRaised(hh) Limpers(hh) IAmBlinds(hh, win) SetTextParty(id, dir, frac=1, unit="") NavToGame(game) NavToLimit(limit) SetFilter(button) TogglePlanner() relX(x, ww) relY(y, wh) relW(w, ww) relH(h, wh) instantHH(hh, x, y, gui, dir, theme="", font="" , bgColor="", 4ColorDeck=1, showPot=1, showdown=1, rows=10) IsStudHH(hh) LastHH(win, exe) CurrentHand(hh, win, x, y, gui, theme="", font="", bgColor="") OpenBuddyList() OpenPlayerSearch() AddPlayerToBuddyList(player) ToggleSitoutParty() SitOutParty(win) SitInParty(win) SitOutPartyEx() SitInPartyEx() PositionActed(hh, player, ByRef action) PositionActedStud(hh, player, ByRef action) ;----- Dialogues ------ Msgbox(msg="", options="", title="", font="", gui=66) InputBox(prompt="", options="", title="", default="", font="", gui=67) Hotkey(Options="",Prompt="",Title="",GuiNumber=77) ColorPicker(HEXString="",Title="",owner="",Gui=97) Font(ini, section, options="", owner="", gui=93) ;----- ExtractFunctions&Subroutines ------ ExLabelList(file) ExSub(sub,file) ExFunct(function, file) */ ; comment ; ### Miscellanious ### ;don't allow compiled scripts IsCompiled() { ; by Roland If A_IsCompiled { msg = (LTrim Join`s Sorry, but it is not possible to run this script correctly if it is compiled. The program will exit. ) Msgbox(msg, "IconX w250 bold -Owner",version) ExitApp } } CheckAHKVersion(req) { If (A_AhkVersion < req) { msg = (LTrim Join`s This script needs AutoHotkey version %req% or newer to run correctly (you are using version %A_AhkVersion%). `nGo to web page to download new version now? ) If (Msgbox(msg, "ButtonsYes|No IconI c8B0000 Default1 bold s10 w320 -Owner", version) = "Yes") Run, % Web() "http://www.autohotkey.com/download/" ExitApp } } Tip(text,timeout="",x="",y="") { CoordMode, ToolTip, Screen If ( x ) Tooltip,%text%, %x%, %y% else Tooltip %text% If timeout SetTimer,RemoveTooltip,% timeout*1000 CoordMode, ToolTip, Relative return RemoveTooltip: Tooltip SetTimer, RemoveTooltip, Off return } ;"If var in..." IsIn(var,matchlist) { strSense = %a_stringCaseSense% StringCaseSense Off If var in %matchlist% { return 1 StringCaseSense %strSense% } StringCaseSense %strSense% return 0 } ;"If var in %matchlist%" as a function Contains(var,matchlist) { If var contains %matchlist% return 1 return 0 } ;thanks to Titan for this handy little funtion ;it returns the path of the systems default browser, so ;that web pages can be opened in a new window Web() { ; by Titan, modified by Roland RegRead, p, HKCR, HTTP\shell\open\command Return SubStr(p, 1, InStr(p, ".exe")+4) } ; no longer neccessary since we have the ; ternary operator now... ; but have to keep it for old scripts iif(_boolExpr, _exprTrue, _exprFalse) { If _boolExpr Return _exprTrue else return _exprFalse } ; checks if a joystick exists and returns its ; number if yes, else 0 JoyExist() { Loop 32 { GetKeyState, joy_name, %A_Index%JoyName If joy_name <> return a_index } return 0 } ; removes modifiers and special ; operators... forgot where I needed this CleanHotkey(k) { k := StrRep(k, "^") k := StrRep(k, "<^") k := StrRep(k, ">^") k := StrRep(k, "!") k := StrRep(k, "<!") k := StrRep(k, ">!") k := StrRep(k, "+") k := StrRep(k, "<+") k := StrRep(k, ">+") k := StrRep(k, "#") k := StrRep(k, "<#") k := StrRep(k, ">#") k := StrRep(k, "*") k := StrRep(k, "~") k := StrRep(k, " UP") return k } Random(min,max,newSeed="") { If ( newSeed ) { Random,,newSeed return } Random, var, min, max return var } IsBetween(var, lower, upper) { If var between %lower% and %upper% return 1 return 0 } ; returns a pipe-seperated list with ; all available fonts fontList() { Loop, HKEY_LOCAL_MACHINE , SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts { StringLeft, f, a_loopRegName, InStr(a_loopRegName, "(")-1 if regExMatch(f, "[\w\s]+\s(\d+,)+\d") f:=regExReplace(f, "\d+(,| )") listAdd(fonts, f, "|") } return fonts } ; used for TableNavigator... CreateDFCFile(file) { functions := ExLabelList(file) num_params_prev = 0 Loop, Parse, functions, | { IfNotInString, a_loopfield, ( continue IfInString, a_loopfield, / continue IfInString, a_loopfield, dfc continue info := GetdfcInfo(a_loopfield,num_params) If info = continue dfc = %dfc%`n%info% If num_params > %num_params_prev% num_params_prev = %num_params% } Loop %num_params_prev% params = %params%,p%a_index%="" StringTrimLeft, params, params, 1 dfc = dfc(f,%params%) {`nglobal A_LastDFCError`n%dfc%`nA_LastDFCError = `%f`%`n} return dfc } GetDFCInfo(f, ByRef num_params) { num_params = 0 StringLeft, func, f, InStr(f, "(") - 1 dfc = %a_space%If (f = "%func%") params := StrMid(a_loopfield,"(",")") Loop, Parse, params, `, { num_params++ IfInString, a_loopfield, = { num++ StringTrimLeft,p, a_loopfield, InStr(a_loopfield, "=") IfInString, p, ByRef return If p = "" ; p = continue cond = %cond%`nIf (p%a_index% = "")`n%a_space%%a_space%p%a_index% = %p% } ps = %ps%,p%a_index% } StringTrimLeft, params, ps, 1 If cond thisF = %dfc%%a_space%%a_space%{%a_space%%a_space%%cond%`n return %func%(%params%)`n} else thisF = %dfc%`n%a_space%%a_space%return %func%(%params%) return thisF } ; not sure how well this actually works\performs... ; probably best to use simpler methods in most cases DrawFrame(frame=0, x=0, y=0, w=0, h=0, t=0, c=0) { local h_brush static _gui,SRCCOPY,frames ,hdc_frame,hdc_buffer ,h_region,hbm_buffer c := BGRToRGB(c) If ( frame = "*" ) { StringSplit, f, frames, `, Loop { If ( f%a_index% ) continue frame = %a_index% break } } If ( ! frames ) { ;no frames means this is the first call (or first call after a clean-up) _gui = 50 Gui %_gui%: +Lastfound +AlwaysOnTop +Toolwindow Gui %_gui%: Color, 0x000001 ;this color cannot be used as a frame color obviously WinSet, TransColor, 0x000001 Gui %_gui%: -Caption Gui %_gui%: Show, x0 y0 w%a_screenwidth% h%a_screenheight% NoActivate hdc_frame := DllCall( "GetDC", "uint", WinExist() ) hdc_buffer := DllCall( "gdi32.dll\CreateCompatibleDC", "uint", hdc_frame ) hbm_buffer := DllCall( "gdi32.dll\CreateCompatibleBitmap", "uint", hdc_frame , "int", a_screenwidth, "int", a_screenwidth ) DllCall( "gdi32.dll\SelectObject", "uint", hdc_buffer, "uint", hbm_buffer ) DllCall( "gdi32.dll\SelectObject", "uint", hdc_buffer, "uint", hbm_buffer ) h_region := DllCall( "gdi32.dll\CreateRectRgn", "int", 0, "int", 0, "int", 0, "int", 0 ) SRCCOPY = 0x00CC0020 } ;if this frame already exists, remove previously drawn ;rectangle (restore previoulsy buffered color data): If IsIn(frame,frames) { DllCall( "gdi32.dll\BitBlt", "uint", hdc_frame, "int", old_x_%frame%, "int", old_y_%frame% , "int", old_w_%frame%, "int", old_h_%frame%, "uint", hdc_buffer, "int", 0, "int", 0 , "uint", SRCCOPY ) If ( !x && !y && !w && !h) ;just erase it (there must be a better way to do this?) frames := RemoveFromList(frames,frame) } else frames := AddToList(frames,frame) If ( ! frame || ! frames ) { ;clean up DllCall( "gdi32.dll\DeleteObject", "uint", h_region ) DllCall( "gdi32.dll\DeleteObject", "uint", hbm_buffer ) DllCall( "gdi32.dll\DeleteDC", "uint", hdc_frame ) DllCall( "gdi32.dll\DeleteDC", "uint", hdc_buffer ) frames = Gui %_gui%: Destroy return } If ( !x && !y && !w && !h) return ;add last position to global array: old_x_%frame% = %x% old_y_%frame% = %y% old_w_%frame% = %w% old_h_%frame% = %h% ;Store current color data of new ractangle in buffer: DllCall( "gdi32.dll\BitBlt", "uint", hdc_buffer, "int", 0, "int", 0 , "int", w, "int", h, "uint", hdc_frame, "int", x, "int", y , "uint", SRCCOPY ) DllCall( "gdi32.dll\SetRectRgn", "uint", h_region, "int", x, "int", y, "int", x+w, "int", y+h ) h_brush := DllCall( "gdi32.dll\CreateSolidBrush", "uint", c ) DllCall( "gdi32.dll\FrameRgn", "uint", hdc_frame, "uint", h_region, "uint", h_brush, "int", t, "int", t ) DllCall( "gdi32.dll\DeleteObject", "uint", h_brush ) return frame } ; Creates a Two Pixel Bitmap (Horizontal/Vertical) ; see http://www.autohotkey.com/forum/view...?p=61081#61081 ; Param1: File name to be created ; Param2: A Valid Hex Color code for the Bottom (or) Left pixel. ; Param3: A Valid Hex Color code for the Top (or) Right pixel. ; Param4: 0 (or) 1 . Vertical=1 / Horizontal=0 Gradient(File, RGB1, RGB2, Vertical=1) { If (BGR(RGB1)="" OR BGR(RGB2)="") Return Null Hs1:="424d3e00000000000000360000002800000" Hs3:="00100180000000000080000000000000000000000000 0000000000000" If Vertical { Hs2:="0010000000200000" HexString:= Hs1 Hs2 Hs3 BGR(RGB1) "00" BGR(RGB2) "00" } Else { Hs2:="0020000000100000" HexString:= Hs1 Hs2 Hs3 BGR(RGB1) BGR(RGB2) "0000" } Handle:= DllCall("CreateFile","str",file,"Uint",0x40000000 ,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0) Loop 62 { StringLeft, Hex, HexString, 2 StringTrimLeft, HexString, HexString, 2 Hex = 0x%Hex% DllCall("WriteFile","UInt", Handle,"UChar *", Hex ,"UInt",1,"UInt *",UnusedVariable,"UInt",0) } DllCall("CloseHandle", "Uint", Handle) Return File } BGR(RGB) { If (StrLen(RGB)<>6) Return Null Loop, Parse, RGB If A_LoopField not in 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Return Null StringMid,R,RGB,1,2 StringMid,G,RGB,3,2 StringMid,B,RGB,5,2 Return B G R } RandomHexColor(Range1=0,Range2=255) { Random, _RGB1, %Range1%, %Range2% Random, _RGB2, %Range1%, %Range2% Random, _RGB3, %Range1%, %Range2% SetFormat, Integer, Hex _RGB1+=0 _RGB2+=0 _RGB3+=0 If StrLen(_RGB1) = 3 _RGB1= 0%_RGB1% If StrLen(_RGB2) = 3 _RGB2= 0%_RGB2% If StrLen(_RGB3) = 3 _RGB3= 0%_RGB3% SetFormat, Integer, D HEXString = % _RGB1 _RGB2 _RGB3 StringReplace, HEXString, HEXString,0x,,All StringUpper, HEXString, HEXString Return HexString } ; see http://www.autohotkey.com/forum/view...highlight=eval Eval(x) { ; by Laszlo pi = 3.141592653589793 e = 2.718281828459045 ; add below your constants StringReplace x, x, %A_Space%,, All ; remove white space StringReplace x, x, %A_Tab%,, All StringReplace x, x, -, #, All ; # = subtraction StringReplace x, x, (#, (0#, All ; (-x -> (0-x If (Asc(x) = Asc("#")) x = 0%x% ; leading -x -> 0-x StringReplace x, x, (+, (, All ; (+x -> (x If (Asc(x) = Asc("+")) StringTrimLeft x, x, 1 ; leading +x -> x StringReplace x, x, **, @, All ; ** -> @ for easier process Loop { ; replace constants StringGetPos i, x, [ ; find [ IfLess i,0, Break StringGetPos j, x, ], L, i+1 ; closest ] StringMid y, x, i+2, j-i-1 ; variable in [] StringLeft L, x, i StringTrimLeft R, x, j+1 x := L . %y% . R ; replace [var] with value of var } Loop { ; finding an innermost (..) StringGetPos i, x, (, R ; rightmost ( IfLess i,0, Break StringGetPos j, x, ), L, i+1 ; closest ) StringMid y, x, i+2, j-i-1 ; expression in () StringLeft L, x, i StringTrimLeft R, x, j+1 x := L . Eval@(y) . R ; replace (x) with value of x } Return Eval@(x) } Eval@(x) { StringGetPos i, x, +, R ; i = -1 if no + is found StringGetPos j, x, #, R If (i > j) Return Left(x,i)+Right(x,i) If (j > i) ; i = j only if no + or - found Return Left(x,j)-Right(x,j) StringGetPos i, x, *, R StringGetPos j, x, /, R StringGetPos k, x,`%, R If (i > j && i > k) Return Left(x,i)*Right(x,i) If (j > i && j > k) Return Left(x,j)/Right(x,j) If (k > i && k > j) Return Mod(Left(x,k),Right(x,k)) StringGetPos i, x, @, R ; power If (i >= 0) Return Left(x,i)**Right(x,i) StringGetPos i1, x, abs, R ; no more operators StringGetPos i2, x, sqrt, R ; look for functions StringGetPos i3, x, floor, R ; insert further functions below m := Max1(i1,i2,i3) If (m = i1) ; apply the rightmost function Return abs(Right(x,i1+2)) ; only one function is applied Else If (m = i2) ; in one recursion Return sqrt(Right(x,i2+3)) Else If (m = i3) Return floor(Right(x,i3+4)) ; offset j + StrLen(func) - 2 Return x } Left(x,i) { StringLeft x, x, i Return Eval@(x) } Right(x,i) { StringTrimLeft x, x, i+1 Return Eval@(x) } Max1(x0,x1="",x2="",x3="",x4="",x5="",x6="",x7="" ,x8="",x9="",x10="",x11="",x12="",x13="",x14="" ,x15="",x16="",x17="",x18="",x19="",x20="") { x := x0 Loop 20 { IfEqual x%A_Index%,, Break IfGreater x%A_Index%, %x% x := x%A_Index% } IfLess x,0, Return -2 ; prevent match with -1 Return %x% } ; used for OnMessage('someMsg', "ExitMsg")... ExitMsg() { exitApp } ;searches a reagion of the screen for digits 0-9 (and the decimal point) ; and puts them together to the correct number ;used for image matching in PotStars() ; dir: directory of images; ex: e.g. 'bmp' (no point) ; shades: shades of variation DigitSearch(startX,startY,endX,endY,win,dir,ex="", shades=100) { If ex = ex = bmp batchlines = %A_BatchLines% SetBatchLines -1 WinGetPos,Xwin,Ywin,,,ahk_id%win% CoordMode, Pixel, Screen Loop, 11 { i = %a_index% If i = 10 i = 0 else if i = 11 i = -1 lastXpos := startX + winX Loop { ImageSearch, lastXpos,, lastXpos + 1 , startY + Ywin, endX + Xwin, endY + Ywin , *%shades% %dir%\%i%.%ex% If ( errorLevel ) break p++ p%p% = %lastXpos% If i = -1 t = . else t = %i% c%lastXpos% = %t% } } Loop, %p% p_all := p_all "," p%a_index% Sort, p_all, N D, U Loop, Parse, p_all, `, amount := amount "" c%a_loopfield% CoordMode, Pixel, Relative SetBatchLines %batchlines% return amount } ;comment ;Juks rocks PostLeftClick(x, y, table_id, activate=1) { ; ### JUK: Send the down left click, then the mouse-up messages. ; NOTE: This is relative to the top left of the client area and NOT the top left of the ; window (ie: It *doesn't* include the title-bar like AHK's MouseClick does!!!). If activate WinActivate, ahk_id%table_id% PostMessage, 0x201, 0x0001, ((y<<16)^x), , ahk_id%table_id% PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id% } ; a elegant way of communicating with your users [img]/images/graemlins/smile.gif[/img] ; ( 'osd'= on screen display ) ; to destroy the gui/message, call the function without ; any parameters osd(msg="", options="", font="", gui=92) { options := options ? options : "s30 bold cWhite" font := font ? font : "Comic Sans MS" Gui, %gui%: Default Gui, Destroy If ( msg="" ) return Gui, +Lastfound +Toolwindow +AlwaysOnTop Gui, Color, Black WinSet, TransColor, Black Gui -Caption Gui, Margin, 0, 0 Gui, Font, %options%, %font% Gui, Add, Text,, %msg% SysGet, wa, MonitorWorkArea Gui, Show, Hide WinGetPos,,,w, h x := a_screenwidth/2-w/2 y := waBottom-h-20 Gui, Show, x%x% y%y% NoActivate } ; similar to osd(), but the position is meant to be spedified here ; to destroy the gui/message, call the function without ; any parameters osdEx(msg="", options="", font="", x=0, y=0, gui=91) { global osdEx_msg options := a_space . options . a_space size := StrEnd(options, "s") size := size ? size : 30 bold := InStr(options, " bold ") ? "bold" : "" italic := InStr(options, " italic ") ? "italic" : "" color := StrEnd(options, "c") color := color ? color : "white" theme = s%size% c%color% %bold% %italic% font := font ? font : "Comic Sans MS" width := StrEnd(options, "w") width := width ? width : a_screenwidth center := InStr(options, " center ") ? "center" : "" Gui, %gui%: Default If ( msg="" ) { Gui, Destroy return } Gui +LastfoundExist If WinExist() { Gui, Show, x%x% y%y% NoActivate GuiControl,, osdEx_msg, %msg% return } Gui, +Lastfound +Toolwindow +AlwaysOnTop Gui, Color, Black WinSet, TransColor, Black Gui -Caption Gui, Margin, 0, 0 Gui, Font, %theme%, %font% Gui, Add, Text, vosdEx_msg w%width% %center%, %msg% Gui, Show, x%x% y%y% NoActivate } ; see http://www.autohotkey.com/forum/view...tegerataddress InsertIntegerAtAddress(pInteger, pAddress, pOffset = 0, pSize = 4) { mask := 0xFF ; This serves to isolate each byte, one by one. Loop %pSize% { ; Copy each byte in the integer into the structure as raw binary data. DllCall("RtlFillMemory", UInt, pAddress + pOffset + A_Index - 1, UInt, 1 , UChar, (pInteger & mask) >> 8 * (A_Index - 1)) mask := mask << 8 ; Set it up for isolation of the next byte. } } ; the idea is to merge text color, text size ; as well as 'bold' and 'italic' to a single 'theme' (e.g. 'cFFFFFF s10 italic') ; and store theme, background color & font in a new section ; the section to convert is usually created by the Font() function ; and is typically only converted if the user hits Submit in a configuration gui SectionToTheme( ini, section ) { name := StrRep(section, "Font") IniRead, bgColor, %ini%, %section%, bgColor, %a_space% IniRead, txtColor, %ini%, %section%, txtColor, 000000 IniRead, size, %ini%, %section%, size, 8 IniRead, bold, %ini%, %section%, bold, 0 IniRead, italic, %ini%, %section%, italic, 0 IniRead, font, %ini%, %section%, font, %a_space% bold := bold ? "bold" : "" italic := italic ? "italic" : "" theme = s%size% c%txtColor% %bold% %italic% IniWrite, % font, %ini%, %name%, font%name% IniWrite, % bgColor, %ini%, %name%, bgColor%name% IniWrite, % theme, %ini%, %name%, theme%name% } ; the opposite of the above... ThemeToSection( ini, section ) { IniRead, font, %ini%, %section%, font%section% IniRead, bgColor, %ini%, %section%, bgColor%section% IniRead, theme, %ini%, %section%, theme%section% theme := " " theme " " size := StrEnd(theme, "s") txtcolor := StrEnd(theme, "c") bold := InStr(theme, " bold ") ? 1 : 0 italic := InStr(theme, " italic ") ? 1 : 0 section = Font%section% IniWrite, % bgColor, %ini%, %section%, bgColor IniWrite, % txtColor, %ini%, %section%, txtColor IniWrite, % size, %ini%, %section%, size IniWrite, % bold, %ini%, %section%, bold IniWrite, % italic, %ini%, %section%, italic IniWrite, % font, %ini%, %section%, font } ; see http://www.autohotkey.com/forum/viewtopi...me&start=60 ProcessCreationTime( PID ) { ; by Skan VarSetCapacity(PrCT,16) , VarSetCapacity(Dummy,16) , VarSetCapacity(SysT,16) AccessRights := 1040 ; PROCESS_QUERY_INFORMATION = 1024, PROCESS_VM_READ = 16 hPr:=DllCall( "OpenProcess", Int,AccessRights, Int,0, Int,PID ) DllCall( "GetProcessTimes" , Int,hPr, Int,&PrCT, Int,&Dummy, Int,&Dummy, Int,&Dummy) DllCall("CloseHandle" , Int,hPr) DllCall( "FileTimeToLocalFileTime" , Int,&PrCT, Int,&PrCT ) ; PrCT is Creation time DllCall( "FileTimeToSystemTime" , Int,&PrCt, Int,&SysT ) ; SysT is System Time Loop 16 { ; Extracting and concatenating 8 words from a SYSTEMTIME structure Word := Mod(A_Index-1,2) ? "" : *( &SysT +A_Index-1 ) + ( *(&SysT +A_Index) << 8 ) Time .= StrLen(Word) = 1 ? ( "0" . Word ) : Word ; Prefixing "0" for single digits } Return SubStr(Time,1,6) . SubStr(Time,9,8) ; YYYYMMDD24MISS } ; see http://www.autohotkey.com/forum/viewtopi...me&start=30 ; if no param is passed, the scripts own priority is retrieved GetPriority(process="") { ;by Skan Process, Exist, %process% PID := ErrorLevel IfLessOrEqual, PID, 0, Return, "Error!" hProcess := DllCall("OpenProcess", Int,1024, Int,0, Int,PID) Priority := DllCall("GetPriorityClass", Int,hProcess) DllCall("CloseHandle", Int,hProcess) IfEqual, Priority, 64 , Return, "Low" IfEqual, Priority, 16384, Return, "BelowNormal" IfEqual, Priority, 32 , Return, "Normal" IfEqual, Priority, 32768, Return, "AboveNormal" IfEqual, Priority, 128 , Return, "High" IfEqual, Priority, 256 , Return, "Realtime" Return "" } ; WARNING: CAN CAUSE SERIOUS DAMAGE TO DATABASE! ; Please refer to http://www.overcards.com/wiki/moin.c...tgresFunctions ; for instructions psql(sql, database="", debug=0, host="", username="") { ; by _dave_ database := database ? database : "PTPGSQL1" host := host ? host : "localhost" username := username ? username : "postgres" stamp = %A_Now% Random, r, 1000, 9999 file1 := stamp . "_" . A_ScriptName . "_" . r . "_in.txt" file2 := stamp . "_" . A_ScriptName . "_" . r . "_out.txt" file3 := stamp . "_" . A_ScriptName . "_" . r . "_error.txt" command := "psql.exe -A -t -h " . host . " -p 5432 -U " . username . " -d """ . database . """ -f " . file1 . " -o " . file2 . " 2> " . file3 ; . " 2>&1" Loop 3 FileDelete, % file%a_index% FileAppend, \f '\t'`n, %file1% FileAppend, %sql%`n, %file1% FileAppend, \q`n, %file1% RunWait, %comspec% /c %command%, , Hide FileGetSize, errorsize, %file3% If ( errorsize > 0 ) { FileRead, errortext, %File3% FileRead, errorcause, %File1% Loop 3 FileDelete, % file%a_index% if (debug) { Msgbox, %errorcause%`n`n`n%errortext% ExitApp } else { FileAppend, ( join %A_Now% - An Error Occured:`n`nInput:`n%errorcause%`n `nOutput:`n%errortext%`n`n`n`n ), %A_Scriptname%_Error_Log.txt } } FileRead, sqlout, %File2% Loop 3 FileDelete, % file%a_index% StringTrimRight, sqlout, sqlout, 2 return %sqlout% } /* CaptureScreen(aRect, bCursor, sFileTo) 1) If the optional parameter bCursor is True, captures the cursor too. 2) If the optional parameter sFileTo is empty, saves to screen.bmp in the script folder, otherwise to sFileTo which can be BMP/JPG/PNG/GIF/TIF. 3) If aRect is 0/1/2, captures the screen/active window/client area of active window. 4) aRect can be comma delimited sequence of coordinates, e.g., "Left, Top, Right, Bottom" or "Left, Top, Right, Bottom, Width_Zoomed, Height_Zoomed". In this case, only that portion of the rectangle will be captured. Additionally, in the latter case, zoomed to the new width/height, Width_Zoomed/Height_Zoomed. Example: CaptureScreen(0) CaptureScreen(1) CaptureScreen(2) CaptureScreen("100, 100, 200, 200") CaptureScreen("100, 100, 200, 200, 400, 400") ; Zoomed */ /* Convert(sFileFr, sFileTo) Convert("C:\image.bmp", "C:\image.jpg") Convert(0, "C:\clip.png") ; Save the bitmap in the clipboard to sFileTo if sFileFr is "" or 0. */ ; http://www.autohotkey.com/forum/viewtopic.php?t=18146 CaptureScreen(aRect, bCursor = False, sFile = "") { If !sFile sFile := A_ScriptDir . "\screen.bmp" If !aRect { SysGet, Mon, Monitor, 1 nL := MonLeft nT := MonTop nW := MonRight - MonLeft nH := MonBottom - MonTop } Else If aRect = 1 WinGetPos, nL, nT, nW, nH, A Else If aRect = 2 { WinGet, hWnd, ID, A VarSetCapacity(rt, 16) DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt) DllCall("ClientToScreen", "Uint", hWnd, "int64P", pt) nL := pt & 0xFFFFFFFF nT := pt >> 32 & 0xFFFFFFFF nW := DecodeInteger(&rt + 8) nH := DecodeInteger(&rt +12) } Else { StringSplit, rt, aRect, `, nL := rt1 nT := rt2 nW := rt3 - rt1 nH := rt4 - rt2 znW := rt5 znH := rt6 } hDC := DllCall("GetDC", "Uint", 0) mDC := DllCall("CreateCompatibleDC", "Uint", hDC) hBM := DllCall("CreateCompatibleBitmap", "Uint", hDC, "int", nW, "int", nH) DllCall("SelectObject", "Uint", mDC, "Uint", hBM) DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH , "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020) ; CAPTUREBLT = 0x40000000 If bCursor CaptureCursor(mDC, nL, nT) If znW && znH { Zoomed := Zoomer(hDC, mDC, hBM, nW, nH, znW, znH) StringSplit, Mag, Zoomed, `, hBM := Mag1 mDC := Mag2 } Convert(hBM, sFile) DllCall("ReleaseDC", "Uint", 0, "Uint", hDC) DllCall("DeleteDC", "Uint", mDC) DllCall("DeleteObject", "Uint", hBM) } CaptureCursor(hDC, nL, nT) { VarSetCapacity(mi, 20, 0) mi := Chr(20) DllCall("GetCursorInfo", "Uint", &mi) bShow := DecodeInteger(&mi + 4) hCursor := DecodeInteger(&mi + 8) xCursor := DecodeInteger(&mi +12) yCursor := DecodeInteger(&mi +16) VarSetCapacity(ni, 20, 0) DllCall("GetIconInfo", "Uint", hCursor, "Uint", &ni) xHotspot := DecodeInteger(&ni + 4) yHotspot := DecodeInteger(&ni + 8) hBMMask := DecodeInteger(&ni +12) hBMColor := DecodeInteger(&ni +16) If bShow DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL , "int", yCursor - yHotspot - nT, "Uint", hCursor) If hBMMask DllCall("DeleteObject", "Uint", hBMMask) If hBMColor DllCall("DeleteObject", "Uint", hBMColor) } Zoomer(hDC, mDC, hBM, nW, nH, znW, znH) { zmDC := DllCall("CreateCompatibleDC", "Uint", hDC) zhBM := DllCall("CreateCompatibleBitmap", "Uint", hDC, "int", znW, "int", znH) DllCall("SelectObject", "Uint", zmDC, "Uint", zhBM) DllCall("SetStretchBltMode", "Uint", zmDC, "int", 4) DllCall("StretchBlt", "Uint", zmDC, "int", 0, "int", 0, "int", znW, "int", znH , "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020) DllCall("DeleteDC", "Uint", mDC) DllCall("DeleteObject", "Uint", hBM) Return zhBM . "," . zmDC } Convert(sFileFr, sFileTo) { SplitPath, sFileTo, , , sExtTo hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll") VarSetCapacity(si, 16, 0) si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0) DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize) VarSetCapacity(ci, nSize) DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci) Loop, %nCount% { pTypes := DecodeInteger(&ci + 76 * (A_Index - 1) + 44) Unicode2Ansi(pTypes, sTypes) If !InStr(sTypes, "." . sExtTo) Continue pCodec := &ci + 76 * (A_Index - 1) Break } If !sFileFr { DllCall("OpenClipboard", "Uint", 0) hBM := DllCall("GetClipboardData", "Uint", 2) DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage) DllCall("CloseClipboard") } Else If sFileFr Is Integer DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage) Else { Ansi2Unicode(sFileFr, wFileFr) DllCall("gdiplus\GdipLoadImageFromFile", "Uint", &wFileFr, "UintP", pImage) } Ansi2Unicode(sFileTo, wFileTo) DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage , "Uint", &wFileTo, "Uint", pCodec, "Uint", 0) DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken) DllCall("FreeLibrary", "Uint", hGdiPlus) } DecodeInteger(ptr) { Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24 } Ansi2Unicode(ByRef sString, ByRef wString, nSize = 0) { nSize .= !nSize ? DllCall("MultiByteToWideChar", "Uint", 0 , "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0): VarSetCapacity(wString, nSize * 2 + 1) DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0 , "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize) } Unicode2Ansi(ByRef wString, ByRef sString, nSize = 0) { pString := wString + 0 > 65535 ? wString : &wString nSize .= !nSize ? DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0 , "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0): VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString , "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0) } ; ### Mouse ### mouseGetX() { MouseGetPos, x return x } mouseGetY() { MouseGetPos,, y return y } mouseGetWin() { MouseGetPos,,,win return win } mouseGetCtrl() { MouseGetPos,,,,ctrl return ctrl } ; returns 0 if hidden, 1 if visible toggleCursor() { static show:=1 show:=!show return DllCall("user32.dll\ShowCursor", "Int", show)+1 } ; ### Gui ### ; turns Gui #'gui' into a child window of 'win' SetParent(win, gui) { Gui, %gui%: +LastFound return DllCall("SetParent", "uint", WinExist(), "uint", win) } LV_GetTxt(row,column=1) { LV_GetText(var, row, column) return var } TV_GetTxt(id) { TV_GetText(var,id) return var } ; finds the next free gui FreeGui() { Loop 99 { Gui, %a_index%: +LastfoundExist If ! WinExist() return a_index } } ; forces a Gui to be shown completely on screen ; Note: this function operates on the default window number (a_gui)! ForceOS(x="", y="", title="", NA=0, offsetX=0, offsetY=0, hide=0) { Gui +Lastfound WinGetPos, wx, wy x := x!="" ? x : wx y := y!="" ? y : wy title := title ? title : WinGetTitle(WinExist()) Gui, Show, x%x% y%y% Hide, %title% WinGetPos, x, y, w, h SysGet, sw, 78 ;SM_CXVIRTUALSCREEN SysGet, sh, 79 ;SM_CYVIRTUALSCREEN If ( x+w > sw ) x := sw-w-offSetX If ( y+h > sh ) y := sh-h-offSetY noActivate := NA ? "NoActivate" : "" hide := hide ? "hide" : "" Gui, Show, x%x% y%y% %hide% %noActivate%, %title% return WinExist() } ; shows the default gui relative to 'owner' ; omit x and y to center it on it's owner ; note: operates on default gui SetGuiPos(owner, x="",y="", hide=0) { If ( ! owner ) { Gui, Show return } Gui, %owner%: +Lastfound WinGetPos, ox, oy, ow, oh Gui, +Lastfound Gui, Show, hide WinGetPos,,, w, h If (x!="" && y!="" ) { px := ox+x py := oy+y } else { Gui, %owner%: +Lastfound WinGetPos, ox, oy, ow, oh Gui, +Lastfound WinGetPos,,, w, h px := ox + ( ow/2 - w/2 ) py := oy + ( oh/2 - h/2 ) } hide := hide ? "hide" : "" Gui, Show, x%px% y%py% %hide% } ; handles setting the owner for the Msgbox() funcion etc. ; has to be called BEFORE the gui is created ; note: operates on the default Gui ; options can be one or more of the following: ; -owner: the gui will not be owned ; ownerN: sets GuiN as the owner ; -modal: the gui will be owned, but it's owner will not be disabled ; if an owner is not specified, A_Gui, or, if A_Gui, is blank, 1 will be used, ; unless the owner does not exist SetOwner(options="") { If InStr(options, "-owner") return 0 owner := StrEnd(options, "owner") owner := owner ? owner : ( a_gui ? a_gui : 1 ) Gui, %owner%: +LastfoundExist If ! WinExist() return 0 If ! InStr(options, "-modal") Gui, %owner%: +disabled Gui, +Owner%owner% return owner } ; used when imitating a button control ; with two images - returns true ; if the user released the left mouse button while ; still over the control, false if he moved he mouse away before ; releasing - see http://www.autohotkey.com/forum/view...?p=59899#59899 MouseOver() { ; by Skan (formerly known as Goyya) ctrl := MouseGetCtrl() Loop { If ! GetKeyState("LButton", "p") break If ( MouseGetCtrl() != ctrl ) return 0 } return ( MouseGetCtrl()=ctrl ? 1 : 0 ) } ; adds a custom frame to a gui ; see http://www.autohotkey.com/forum/view...?p=64185#64185 ; and http://www.autohotkey.com/forum/view...?p=61081#61081 ; for techniques involved. Thanks to Skan @AHK forums. ; iPaths: 'caption.bmp|border.bmp' AddCustomFrame(iPaths, title="", toolwindow=0, resize=0, pIcon="") { global borderL,borderR,borderB,Icon ,Close0,Close1,Min0,Min1,caption ,title0,title1 StringLeft, caption, iPaths, InStr(iPaths, "|")-1 StringTrimLeft, border, iPaths, InStr(iPaths, "|") c_h := toolwindow ? 20 : 27 b_w := resize ? 4 : 3 f_s := toolwindow ? 8 : 10 closeY := toolwindow ? 2 : 4 closeH := toolwindow ? 14 : 16 title0X := toolwindow ? 10 : 35 title1X := title0X - ( toolwindow ? 1 : 2 ) title0Y := toolwindow ? 3 : 5 title1Y := title0Y - ( toolwindow ? 1 : 2 ) Gui, Add, Pic, vborderL x0 y%c_h% w%b_w% h30, %border% Gui, Add, Pic, vborderR y%c_h% w%b_w% h30, %border% Gui, Add, Pic, vborderB x%b_w% h%b_w% w30, %border% Gui, Add, Pic, vClose0 y%closeY% h%closeH% w-1 gClose, Images\Close0.ico Gui, Add, Pic, vClose1 y%closeY% h%closeH% w-1 gClose, Images\Close1.ico If ( ! toolwindow ) { Gui, Add, Pic, vIcon x5 y5 w16 h-1 gSysMenu, %pIcon% Gui, Add, Pic, vMin0 y%closeY% h%closeH% w-1 gMinimize, Images\Minimize0.ico Gui, Add, Pic, vMin1 y%closeY% h%closeH% w-1 gMinimize, Images\Minimize1.ico } Gui, Add, Pic, vcaption x0 y0 w30 h%c_h% 0x4000000 gGuiMove, %caption% Gui, Font, s%f_s% Gui, Add, Text, vtitle0 x%title0X% y%title0Y% backgroundTrans cDEDEDE, %title% Gui, Add, Text, vtitle1 x%title1X% y%title1Y% backgroundTrans, %title% } ; ### Strings ### StrRep(str,char,rep_char="",all=1) { StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0 return str } ; extracts a substring from between str1 and str2 ; I find this function to be convenient and quite powerful ; take a close look at it to see how it works StrMid(str, str1, str2, sP1=1, sP2=1, cS=0) { sP1 := ( sP1="" ) ? 1 : sP1 sP2 := ( sP2="" ) ? 1 : sP2 StringTrimLeft, s, str, InStr(str, str1, cS, sP1) + StrLen(str1)-1 StringLeft, s, s, InStr(s, str2, cS, sP2)-1 return s } ;StringLeft as a function StrLeft(str, count) { If count = 0 return str StringLeft, s, str, % count return s } ; supposed to slice up text into blocks of maximum lenght %len% ; seems buggy StrSlice(str, len, del="") { del := ( del ) ? del : "|" StringReplace, str, str, %a_space%, |, 1 Loop % StrLen(str)/len { newStr = num = 0 Loop, Parse, str, | { num += StrLen(a_loopfield) + 1 If num > %len% break newStr = %newStr%%a_space%%a_loopfield% } returnStr = %returnStr%%del%%newStr% StringTrimLeft, str, str, StrLen(newStr) + 1 } StringReplace, str, str, |, %a_space%, 1 returnStr = %returnStr%%del%%str% StringTrimLeft, returnStr, returnStr, 1 return returnStr } ; trims any whitespace off the beginning and ; end of %str% TrimWhiteSpace(str) { Loop { StringLeft, isSpace, str, 1 If isSpace is not space break If ( isSpace = "" ) return StringTrimLeft, str, str, 1 } Loop { StringRight, isSpace, str, 1 If isSpace is not space break If ( isSpace = "" ) return StringTrimRight, str, str, 1 } return str } ;turns tabs at the beginning of a line into a_space each TabsToSpaces(c, spaces=2) { Loop % spaces rep := AddToList(rep, a_space, " ") Loop, Parse, c, `n { a := a_loopfield Loop { If ( InStr(a, a_tab) = 1 ) StringReplace, a, a, %a_tab%, %rep% else break } code = %code%`n%a% } StringTrimLeft, code, code, 1 return code } ;extracts the numeric part of a string, starting at %start% ;it can handle floating point numbers such as 1.25 etc. ExtractNum(str,start=0) { StringTrimLeft, str, str, start - 1 Loop, Parse, str { If a_loopfield is not integer { If check = 1 return num "0" else if count { check = 1 num = %num%. continue } else continue } count = 1 num = %num%%a_loopfield% } return num } ;this function extracts the trailing characters of a string ;(for instance "White" from BackgroundWhite etc.) StrEnd(O,str) { IfNotInString, O, %a_space%%str% return StringMid, e, O, InStr(O, " " str) + StrLen(str) + 1 , InStr(O, a_space, "", InStr(O, " " str) + 1) - InStr(O, " " str) - StrLen(str) - 1 return e } ; converts str to uppercase StrUpper(str) { StringUpper, str, str return str } ; converts str to lower case StrLower(str) { StringLower, str, str return str } ; see http://www.autohotkey.com/forum/view...ghlight=varize varize(var, autofix = true) { ; by Titan Loop, Parse, var { c = %A_LoopField% x := Asc(c) If (x > 47 and x < 58) or (x > 64 and x < 91) or (x > 96 and x < 123) or c = "#" or c = "_" or c = "@" or c = "$" or c = "?" or c = "[" or c = "]" IfEqual, autofix, 1, SetEnv, nv, %nv%%c% Else er++ } If StrLen(var) > 254 IfEqual, autofix, 1, StringLeft, var, var, 254 Else er++ IfEqual, autofix, 1, Return, nv Else Return, er } ; see http://www.autohotkey.com/forum/view...ghlight=instrx InStrX(h, n, LR# = "", of = 0) { ; by Titan AutoTrim, Off If InStr(LR#, "R") { StringReplace, LR#x, LR#, R, L, All Loop, Parse, h hx = %A_LoopField%%hx% h = %hx% Loop, Parse, n nx = %A_LoopField%%nx% n = %nx% } Else LR#x = %LR#% StringReplace, nx, n, ?, *, All ofx = %of% Loop, Parse, nx, * If (A_Index > 1) { y = %A_LoopField% StringGetPos, cx, nx, *, % "L" . A_Index - 1 StringMid, c, n, cx + 1, 1 StringGetPos, prex, h, %x%, %LR#x%, %ofx% StringLeft, pre, h, StrLen(x) + prex StringTrimLeft, hx, h, StrLen(x) + prex Loop { StringMid, t, hx, A_Index, 1, L If (t != y) { t := A_Index - 2 Break } } StringGetPos, postx, hx, %y%, , %t% StringLeft, post, hx, %postx% StringGetPos, ix, h, %x%%post%%y%, %LR#x%, %of% If ErrorLevel or (c = "?" and StrLen(post) != 1) i = -1 Else l += StrLen(x) + StrLen(post) If (i = "" or ix < i) and i != -1 i = %ix% ofx += StrLen(post) + StrLen(pre) x = %y% } Else x = %A_LoopField% If !InStr(nx, "*") { StringGetPos, i, h, %n%, %LR#x%, %of% If ErrorLevel i = -1 l := StrLen(n) } ErrorLevel := l + StrLen(y) If InStr(LR#, "R") Return, StrLen(h) - ErrorLevel - i + 1 Else Return, i + 1 } ; converts the AHK hotkey symbols to ; regular abbreviations... SymbolsToKeys(s) { If s not contains <^,>^,^,<^!,>!,!,<+,>+,+,<#,& gt;#,# return StrRep(s, " & ", "+") StringRight, isPlus, s, 1 If ( isPlus = "+" ) { StringTrimRight, s, s, 1 s := s "PLUS" } StringReplace, s, s, <^, LControl_ StringReplace, s, s, >^, RControl_ StringReplace, s, s, ^, Control_ StringReplace, s, s, <!, LAlt_ StringReplace, s, s, >!, RAlt_ StringReplace, s, s, !, Alt_ StringReplace, s, s, <+, LShift_ StringReplace, s, s, >+, RShift_ StringReplace, s, s, +, Shift_ StringReplace, s, s, <#, LWin_ StringReplace, s, s, >#, RWin_ StringReplace, s, s, #, Win_ StringReplace, s, s, _, +, 1 StringReplace, s, s, PLUS, + return s } ; ### Lists ### ;adds said item to the end of said list addToList(list,item,del="") { del := del="" ? "," : del return ( list ? ( list . del . item ) : item ) } listAdd(byRef list, item, del=",") { list := ( list!="" ? ( list . del . item ) : item ) return list } ;return item at said position in said list exFromList(list,pos=1,del="") { del := del="" ? "," : del StringSplit, item, list, %del% return item%pos% } ;removes said item from said list removeFromList(list,item=1,del="") { del := del="" ? "," : del If InStr(list, item . del) return StrRep(list, item . del, "", 0) else if InStr(list, del . item, "", 0) return StrRep(list, del . item, "", 0) else if (item = list) return "" else return list } ;removes the nth item from said list RemoveItemNFromList(list,n,del="") { del := del="" ? "," : del return RemoveFromList(list, ExFromList(list,n,del)) } ;returns the position of said item in said list ;(0 if not in list) GetItemPos(list,item,del="") { del := del="" ? "," : del StringSplit, array, list, %del% Loop %array0% { If array%a_index% = %item% return a_index } return 0 } ;inserts said item at said position in said list InsertItem(list,item,pos,del="") { del := del="" ? "," : del StringSplit,array,list,%del% Loop % IIf( ( pos < array0 ), array0, pos ) { thisItem := array%a_index% If ( a_index != pos ) newList = %newList%%del%%thisItem% else newList = %newList%%del%%item%%del%%thisItem% } If ( InStr(newList, ",",0,0) = StrLen(newList) ) StringTrimRight, newList, newList, 1 StringTrimLeft, newList, newList, 1 return newList } ;removes empty items (and trailing delimiters) CleanList(list, del="") { del := del="" ? "," : del Loop { StringReplace, list, list, %del%%del%, %del%, UseErrorLevel If ! ErrorLevel break } If InStr(list, del) = 1 StringTrimLeft, list, list, 1 If InStr(list, del,0,0) = StrLen(list) StringTrimRight, list, list, 1 return list } List_longest(list, del="") { del := del="" ? "," : del longest = 0 Loop, Parse, list, %del% { If (longest < StrLen(a_loopfield)) longest := StrLen(a_loopfield) } return longest } max(list, del="") { del := del ? del : "," Sort, list, N D%del% StringTrimLeft, max, list, InStr(list, del, 1, 0) return max } min(list, del="") { del := del ? del : "," Sort, list, N D%del% StringLeft, max, list, InStr(list, del)-1 return max } ; ### Controls ### CtrlGetTxt(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGetText, text, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return text } IsVisCtrl(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGet, vis, Visible,, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return vis } IsDisabledCtrl(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGet, enabled, Enabled,, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return !enabled } CtrlGetHwnd(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGet, hwnd, Hwnd,, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return hwnd } CtrlGetExStyle(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGet, Exstyle, Exstyle,, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return Exstyle } CtrlGetStyle(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGet, style, style,, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return style } ToggleCheckbox(ctrl, win, matchMode=1) { If IsCheckedCtrl(ctrl, win, matchMode) Control, Uncheck,, %ctrl%, ahk_id%win% else Control, Check,, %ctrl%, ahk_id%win% } IsCheckedCtrl(ctrl, win, matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlGet, checked, checked,, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% return checked } FocusedCtrl() { ControlGetFocus, ctrl, A return ctrl } CtrlWaitVis(ctrl,win="",timeout="") { If ( ! win) win := WinExist() Loop { If IsVisCtrl(ctrl,win) { errorLevel = 0 return } Sleep 10 x += 10 If ( timout != "" && x >= timeout ) { errorLevel = 1 return } } } CtrlClick(ctrl,win,matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% ControlClick, %ctrl%, ahk_id%win% SetTitleMatchMode %mm% } CtrlCheck(ctrl, win, matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% Loop { Control, Check,, %ctrl%, ahk_id%win% If ( errorLevel || IsCheckedCtrl(ctrl, win) ) break } SetTitleMatchMode %mm% } CtrlUncheck(ctrl, win, matchMode=1) { mm = %a_titleMatchMode% SetTitleMatchMode %matchMode% Loop { Control, Uncheck,, %ctrl%, ahk_id%win% If ( errorLevel || ! IsCheckedCtrl(ctrl, win, mm) ) break } SetTitleMatchMode %mm% } FrameAroundCtrl(ctrl,win,frame="",width=5,color="" ) { frame := frame ? frame : "*" color := color ? color : "0xFF0000" WinGetPos,wx,wy,,,ahk_id%win% ControlGetPos,x,y,w,h, %ctrl%, ahk_id%win% return DrawFrame(frame, wx+x-width,wy+y-width,w+width*2,h+width*2,width,color) } ; ### Files ### FileRead(file) { FileRead, t, %file% return t } FileReadLine(file,line) { FileReadLine, var, %file%, %line% return var } FileSelectFile(Options="",RootDir="",Prompt="",Fil ter="") { FileSelectFile, file, %Options%, %RootDir%, %Prompt%, %Filter% return file } IniRead(file,section,key,def="") { IniRead, var, %file%, %section%, %key%, %def% If var = ERROR ErrorLevel = 1 return var } CreateCustomFile(file,dir) { del = `n#----------`n IfExist %file% FileDelete %file% Loop, %dir%\*.txt { FileRead, notes, %A_LoopFileFullPath% StringTrimRight, name, a_loopfilename, 4 FileAppend, %name%:`n%notes%%del%, %file% num++ } return num } SplitCustomFile(file,dir) { del = #---------- IfNotExist %file% return IfNotExist %dir% FileCreateDir %dir% FileRead, str, %file% Loop, Parse, str, `n, `r`n { If (InStr(a_loopfield, del) = 1) { StringTrimLeft, value, value, 1 num_notes++ IfExist %dir%\%key%.txt FileDelete %dir%\%key%.txt FileAppend, %value%, %dir%\%key%.txt value = count = 0 continue } count++ If (count = 1) { StringTrimRight, key, a_loopfield, 1 continue } value = %value%`n%a_loopfield% } return num_notes } ;url: http://www.autohotkey.com/forum/view...57&start=0 WriteFile(file,data) { ; by corrupt Handle := DllCall("CreateFile","str",file,"Uint",0x40000000 ,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0) Loop { if strlen(data) = 0 break StringLeft, Hex, data, 2 StringTrimLeft, data, data, 2 Hex = 0x%Hex% DllCall("WriteFile","UInt", Handle,"UChar *", Hex ,"UInt",1,"UInt *",UnusedVariable,"UInt",0) } DllCall("CloseHandle", "Uint", Handle) return } DePCmp1(Pic1) { format = %A_FormatInteger% SetFormat, integer, d TcNt:=42 Loop, 48 TcXp:=TcXp . Chr(A_Index + 127) Loop, 213 { TcXp2= If (TcNt > 126 AND TcNt < 177) { TcNt += 1 Continue } TcXp3 = %A_Index% Loop, 48 TcXp2 := TcXp2 . Chr(TcNt) Loop, Parse, TcXp { TcXp6 := 51 - A_Index StringRight, TcXp4, TcXp2, %TcXp6% TcXp5 := Chr(TcNt) . A_LoopField StringReplace, Pic1, Pic1, %TcXp5%, %TcXp4%, All } TcNt += 1 } SetFormat, integer, h Pic2 = %Pic1% Pic1= Loop, Parse, Pic2 { tC1 := Asc(A_LoopField) If !(tC1 > 0x7e AND tC1 < 0xb1) If !(tC1 > 0x2f AND tC1 < 0x3A) If !(tC1 > 0x40 AND tC1 < 0x47) If !(tC1 > 0x60 AND tC1 < 0x67) { StringRight, tC1, tC1, 2 StringReplace, tC1, tC1, x, 0 Pic1 = %Pic1%%tC1% Continue } Pic1 = %Pic1%%A_LoopField% } SetFormat Integer, %format% Return Pic1 } FileSave(str, file) { FileDelete, %file% FileAppend, %str%, %file% } ; ### Pixel ### ; PixelGetColor as a function PixelGetColor(x,y,options="") { PixelGetColor, color, x, y, %options% return color } ; finds number of specified pixels in a region GetPixelCount(x1,y1,x2,y2,color,options="") { pixels := (x2 - x1 + 1)*(y2 - y1 + 1) If ( pixels <= 0 ) { ErrorLevel = 1 return } count = 0 x = %x1% Loop { If ( x > x2 ) break y = %y1% Loop { If ( y > y2 ) break PixelGetColor, c, x, y, %options% If ( c = color ) count++ y++ } x++ } return count } ; finds the predomatinate color in a region GetPredominateColor(x1,y1,x2,y2,options="") { pixels := (x2 - x1 + 1)*(y2 - y1 + 1) If ( pixels <= 0 ) { ErrorLevel = -1 return } x = %x1% Loop { If ( x > x2 ) break y = %y1% Loop { If ( y > y2 ) break PixelGetColor, c, x, y, %options% num%c%++ all_colors = %all_colors%|%c% y++ ;done++ ;Tooltip % Floor((done/pixels)*100) "%" } x++ } StringTrimLeft, all_colors, all_colors, 1 num%pred_c% = 0 Loop, Parse, all_colors, | { If ( num%a_loopfield% > num%pred_c% ) pred_c = %a_loopfield% } ErrorLevel := num%pred_c% return pred_c } ; ...or the other way round, of course BGRToRGB(c) { If InStr(c, "0x") StringTrimLeft, c, c, 2 StringLeft, bb, c, 2 StringMid, gg, c, 3, 2 StringRight, rr, c, 2 return "0x" rr . gg . bb } ; ### Windows ###; ### Windows ### ; get minmax info ; see WinGet, MinMax for more info WinMinMax(id) { WinGet, info, MinMax, ahk_id%id% return info } ; waits for a window to 'hold still' ; int: inte |
#19
|
|||
|
|||
Re: ipoker skins and scripts?
funktioniert das Ding zuverlässig?
|
#20
|
|||
|
|||
Re: ipoker skins and scripts?
also beide in einen ordner und dann mit autohotkey das erste script laden, ja?
|
|
|