Hi,
I meant to post this a while back when SpellOfMaya sent it to me, didn't get round to it yet but here goes.
Spellofmaya / Max1mums edited version:
(will auto-close tables after sit-out next BB - Also will locate correct log folder on vista, possibly win7?)
Code:
#NoEnv
#Persistent
SetBatchLines -1
CheckTime := 500 ; Check every n MilliSeconds
sitin_x := 532
sitin_y := 468
timebank_x := 520
timebank_y := 460
If A_OSVersion in WIN_VISTA
{
_FILE := A_AppData . "\PokerStars\PokerStars.log.0"
IfNotExist %_FILE%
stringreplace,_FILE,_FILE,Roaming,Local
IfNotExist %_FILE%
{
msgbox, PokerStars.log.0 file was not found
return
}
}
else
_FILE := A_ProgramFiles . "\PokerStars\PokerStars.log.0"
;_FILE := "E:\sitout.txt"
SysGet, border, 32
SysGet, caption, 4
SetTimer, FILE_CHECK, %CheckTime%
return
FILE_CHECK:
If (_NEWLINES := CheckFile(_FILE))
{
;msgbox, %_NEWLINES%
Loop, Parse, _NEWLINES, `n
{
if(regExMatch(a_loopfield, "MSG_TABLE_FORCE_SITOUT\s(\w{8})\s1", m))
{
;msgbox, %m1%
;PostStarsClick(sitin_x, sitin_y, ("0x" . m1))
id:="0x" . m1
winclose,ahk_id%id%
winwait,Table ahk_class #32770,,1
{
ControlFocus,Button1,
Sleep, -1
ControlSend,Button1,{SPACE},
}
}
else if (regExMatch(a_loopfield, "MSG_TABLE_TIMEBANK\s(\w{8})\stime=", m))
{
;msgbox, %m1%
PostStarsClick(timebank_x, timebank_y, ("0x" . m1))
}
}
;msgbox, %m1%
}
Return
CheckFile(File) {
; THX Sean for File.ahk : http://www.autohotkey.com/forum/post-124759.html
Static CF := "" ; Current File
Static FP := 0 ; File Pointer
Static OPEN_EXISTING := 3
Static GENERIC_READ := 0x80000000
Static FILE_SHARE_READ := 1
Static FILE_SHARE_WRITE := 2
Static FILE_SHARE_DELETE := 4
Static FILE_BEGIN := 0
BatchLines := A_BatchLines
SetBatchLines, -1
If (File != CF) {
CF := File
FP := 0
}
hFile := DllCall("CreateFile"
, "Str", File
, "Uint", GENERIC_READ
, "Uint", FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE
, "Uint", 0
, "Uint", OPEN_EXISTING
, "Uint", 0
, "Uint", 0)
If (!hFile) {
CF := ""
FP := 0
SetBatchLines, %BatchLines%
Return False
}
DllCall("GetFileSizeEx"
, "Uint", hFile
, "Int64P", nSize)
If (FP = 0 Or nSize <= FP) {
FP := nSize
SetBatchLines, %BatchLines%
DllCall("CloseHandle", "Uint", hFile) ; close file
Return False
}
DllCall("SetFilePointerEx"
, "Uint", hFile
, "Int64", FP
, "Uint", 0
, "Uint", FILE_BEGIN)
VarSetCapacity(Tail, Length := nSize - FP, 0)
DllCall("ReadFile"
, "Uint", hFile
, "Str", Tail
, "Uint", Length
, "UintP", Length
, "Uint", 0)
DllCall("CloseHandle", "Uint", hFile)
VarSetCapacity(Tail, -1)
FP := nSize
SetBatchLines, %BatchLines%
Return Tail
}
relStarsClientPoint(id, ByRef x, ByRef y)
{
global border
global caption
rw := 792
rh := 546
WinGetPos, , , w, h, ahk_id%id%
w := w - (2*border)
h := h - (2*border) - caption
x := Floor( (x / rw ) * w )
y := Floor( (y / rh) * h )
}
;Juks rocks
PostLeftClick(x, y, table_id, activate=0) {
; ### 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%
}
PostStarsClick(x, y, id)
{
relStarsClientPoint(id, x, y)
PostLeftClick(x, y, id)
}