Script: Mark Current Hand
will have something by next week
meanwhile I got a key. I have to apologize btw, I took so long because I confused my email accounts
You can download and use the trial version:
http://www.holdemmanager.com/downloa...er_2_Setup.exe
http://www.holdemmanager.com/downloa...er_2_Setup.exe
great job ttr, am lloking forward to functionality with hm2
Make it work for party, please.
I had this working fine but then had a HEM / Postgre problem. When I set up a new database, I gave it a two word name (with a space in the middle). Is this likely to cause a problem with the script as I can't seem to get it working right now?
The gamenumbers.txt file has hand numbers in it but sending it to my HEM database doesn't seem to work. The pop up window asks for my password but when I type it in, it says it's incorrect but only refers to the second word of my database name.
I hope that makes sense! Does the script need tweaking or does my database need renaming?
The gamenumbers.txt file has hand numbers in it but sending it to my HEM database doesn't seem to work. The pop up window asks for my password but when I type it in, it says it's incorrect but only refers to the second word of my database name.
I hope that makes sense! Does the script need tweaking or does my database need renaming?
update for hm2?
+1
having to hold of using hem2 till i get this working
having to hold of using hem2 till i get this working
sorry have been really busy.
I still need to fix a couple of things, you will get an error message on the first start, when there is no ini-file yet. Just click okay and move on. The HM2 related stuff should work though. Btw in HM2 you can choose a categories to mark your hands in and even create new categories. Obviously the script marks a hand "for review".
I still need to fix a couple of things, you will get an error message on the first start, when there is no ini-file yet. Just click okay and move on. The HM2 related stuff should work though. Btw in HM2 you can choose a categories to mark your hands in and even create new categories. Obviously the script marks a hand "for review".
Code:
#noenv #SingleInstance, Force SetWinDelay,-1 settitlematchmode,2 StringTrimRight, thisahk, A_ScriptName, 4 SetWorkingDir %A_ScriptDir% Menu, Tray, NoStandard Menu, Tray, Add, Reload, Reload Menu, Tray, Add, Change Settings, GetMHSettings() Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey Menu, Tray, Add, Exit, Exit Gui, Submit IniRead, StarsHHLogFolderPath, %thisahk%.ini, LogFolder, StarsHHPath, %A_Space% IniRead, FullTiltHHLogFolderPath, %thisahk%.ini, LogFolder, FullTiltHHPath, %A_Space% IniRead, PostgresLogPath, %thisahk%.ini, LogFolder, postgrespath, %A_Space% IniRead, postgresuser, %thisahk%.ini, LogFolder, postgresuser, %A_Space% IniRead, postgresdb, %thisahk%.ini, LogFolder, postgresdb, %A_Space% IniRead, HK_mark, %thisahk%.ini, LogFolder, HK_mark, %A_Space% IniRead, HK_sql , %thisahk%.ini, LogFolder, HK_sql , %A_Space% If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb or !HK_mark or !HK_sql) gosub GetMHSettings() HotKey, %HK_mark%, l_markhand HotKey, %HK_sql%, l_processsql IfExist, gamenumbers.txt { MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No) IfMsgBox Yes FileDelete, gamenumbers.txt } settimer,checksize,100 return ^2:: Suspend Return l_markhand: winget,id,id,A wingetclass,class,ahk_id%id% if class=PokerStarsTableFrameClass { site=Stars dir:=StarsHHLogFolderPath } else if class=QWidget { site=FullTilt dir:=FullTiltHHLogFolderPath } else site= if site { filename:=HHFile(id, dir ,site) FileGetSize, FileSize, % filename if !FileSize FileSize:=0 listadd(filelist, id . "-" . FileSize) } return l_processsql: IfExist, temp.txt FileDelete, temp.txt IfExist, temp.bat FileDelete, temp.bat IfExist, %PostgresLogPath%\temp.txt FileDelete, %PostgresLogPath%\temp.txt IfExist, %PostgresLogPath%\temp.bat FileDelete, %PostgresLogPath%\temp.bat FileRead, numbers, gamenumbers.txt sql1=insert into hand_markings (marking_id, gamenumber, site_id) sql2= select 1, gamenumber, pokersite_id from pokerhands sql3= Where gamenumber = sql4=and (1, gamenumber) not in (select marking_id, gamenumber from hand_markings); sql5=update hand_markings set marking_id = 1 where gamenumber = sq16=; Loop, Parse, numbers, `n, { if A_loopField { FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4% %sql5% %A_loopField% %sq16% `n, temp.txt } } FileAppend, cd %PostgresLogPath%`npsql.exe %postgresdb% %postgresuser% <temp.txt`npause`n, temp.bat Filemove, temp.txt, %PostgresLogPath% Filemove, temp.bat, %PostgresLogPath% run %PostgresLogPath%\temp.bat return ;----------------------------------------------------------------------------------------------------- checksize: Loop, Parse, filelist, `, { stringsplit,tab,A_loopField,- wingetclass,class,ahk_id%tab1% if class=PokerStarsTableFrameClass { site=Stars dir:=StarsHHLogFolderPath } else if class=QWidget { site=FullTilt dir:=FullTiltHHLogFolderPath } filename:=HHFile(tab1, dir ,site) FileGetSize, FileSize, % filename if FileSize if FileSize!=%tab2% { num:=gethhnumber(tab1,site) FileAppend, %num%`n, gamenumbers.txt listDelItem(filelist, A_loopField) } } return ;----------------------------------------------------------------------------------------------------- gethhnumber(winid,site) { global StarsHHLogFolderPath,FullTiltHHLogFolderPath if site=Stars path=%StarsHHLogFolderPath% else path=%FullTiltHHLogFolderPath% hh:=LastHH(winid,path,site) Loop, Parse, hh, `n { if instr(A_loopfield,"Game #") { stringtrimleft,num,A_loopfield,instr(A_loopfield,"#") stringleft,num,num,instr(num,":")-1 break } } return num } ;----------------------------------------------------------------------------------------------------- HHFile(win, dir, site) { if site=Stars ext=HH else ext=FT title := WinGetTitle(win) if !(instr(title,"Tournament")>0 OR instr(title,"Sit & Go")>0) { stringleft,file,title, InStr(title, "-","",0)-2 file := ext . SubStr(a_now, 1, 8) . A_space . file StringReplace, file, file, /,-, if site=Stars { StringReplace, file, file, USD -,- USD, StringReplace, file, file, EUR -,- EUR, } } else if site=Stars { stringtrimleft,file,title,instr(title,"Tournament")+10 stringleft,file,file,InStr(file, A_space)-1 } else { stringtrimleft,file,title,instr(title,"(")-1 stringleft,file,file,InStr(file, "-")-2 } loop %dir%\*.txt { if instr(A_LoopFileName,file)>0 & !instr(A_LoopFileName,"Summary")>0 return dir "\" A_LoopFileName } EnvAdd, date, -1, d stringleft,file,title, InStr(title, "-","",0)-2 file := ext . SubStr(date, 1, 8) . A_space . file StringReplace, file, file, /,-, if site=Stars { StringReplace, file, file, USD -,- USD, StringReplace, file, file, EUR -,- EUR, } loop %dir%\*.txt { if instr(A_LoopFileName,file) return dir "\" A_LoopFileName } EnvAdd, date, +1, d stringleft,file,title, InStr(title, "-","",0)-2 file := ext . SubStr(date, 1, 8) . A_space . file StringReplace, file, file, /,-, if site=Stars { StringReplace, file, file, USD -,- USD, StringReplace, file, file, EUR -,- EUR, } loop %dir%\*.txt { if instr(A_LoopFileName,file) return dir "\" A_LoopFileName } } return ;----------------------------------------------------------------------------------------------------- LastHH(win, dir, site) { if site=Stars game=PokerStars Game # else game=Full Tilt Poker Game # file@name:=HHFile(win, dir ,site) FileRead, hh, %file@name% if !instr(hh,"seat") { FileGetSize file@size, %file@name% FileRead file@buffer, %file@name% VarSetCapacity(hh, file@size / 2 + 1, 0) r := DllCall("WideCharToMultiByte" , "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001 , "UInt", 0 ; dwFlags , "Str", file?buffer ; LPCWSTR lpWideCharStr , "Int", file@size / 2 ; cchWideChar: -1=null terminated , "Str", hh ; LPSTR lpMultiByteStr , "Int", file@size / 2 + 1 ; cbMultiByte: 0 to get required size , "UInt",0 ; LPCSTR lpDefaultChar , "UInt", 0) ; LPBOOL lpUsedDefaultChar } StringTrimLeft, hh, hh, InStr(hh, game, "", 0)-1 if instr(hh,"SUMMARY") Stringleft, hh, hh, InStr(hh, "*** SUMMARY", "", 0)-1 return hh } ;----------------------------------------------------------------------------------------------------- WinGetTitle(win) { WinGetTitle, title, ahk_id%win% return title } ;----------------------------------------------------------------------------------------------------- StrRep(str,char,rep_char="",all=1) { StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0 return str } ;----------------------------------------------------------------------------------------------------- StarsHHFolderSelect: FileSelectFolder, SelectedFolder, *%ProgramFiles%\PokerStars\,, Select the folder with the PokerStars handhistory files Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present. If SelectedFolder <> ;the user selected a folder { GuiControl,, StarsHHLogFolderPath, %SelectedFolder% StarsHHLogFolderPath := SelectedFolder IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath Gui, Submit, NoHide } return ;----------------------------------------------------------------------------------------------------- FullTiltHHFolderSelect: FileSelectFolder, SelectedFolder, *%ProgramFiles%\Full Tilt Poker\,, Select the folder with the FullTilt handhistory files Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present. If SelectedFolder <> ;the user selected a folder { GuiControl,, FullTiltHHLogFolderPath, %SelectedFolder% FullTiltHHLogFolderPath := SelectedFolder IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath Gui, Submit, NoHide } return ;----------------------------------------------------------------------------------------------------- PostgresBinFolderSelect: FileSelectFolder, SelectedFolder, *%ProgramFiles%\PostgreSQL\,, Select the folder with the Postgres binary files Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present. If SelectedFolder <> ;the user selected a folder { GuiControl,, PostgresLogPath, %SelectedFolder% PostgresLogPath := SelectedFolder IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath Gui, Submit, NoHide } return ;----------------------------------------------------------------------------------------------------- postgresuserselect: InputBox, postgresuser,, enter Postgres Username IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser return ;----------------------------------------------------------------------------------------------------- postgresdbselect: InputBox, postgresdb,, enter Postgres Datbase Name IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb return ;----------------------------------------------------------------------------------------------------- GetMHSettings(): { Gui, Add, Text, x10 y5 w120 h20 Center, Select Folder Location Gui, Add, Text, x140 y5 w150 h20 Center, Folder Location Gui, Add, Button, x5 y20 w150 h20 gPostgresBinFolderSelect center, Postgres Binary Folder Gui, Add, Edit, x160 y20 w520 h20 vPostgresLogpath, %PostgresLogpath% Gui, Add, Button, x5 y40 w150 h20 gStarsHHFolderSelect center, Poker Stars HH Folder Gui, Add, Edit, x160 y40 w520 h20 vStarsHHLogFolderPath, %StarsHHLogFolderPath% Gui, Add, Button, x5 y60 w150 h20 gFullTiltHHFolderSelect center, Full Tilt HH Folder Gui, Add, Edit, x160 y60 w520 h20 vFullTiltHHLogFolderPath, %FullTiltHHLogFolderPath% Gui, Add, Text, x5 y120 w150 h20 right, Postgres User Name: Gui, Add, Edit, x160 y120 w100 h20 vpostgresuser, %postgresuser% Gui, Add, Text, x5 y140 w150 h20 right, Postgres Database: Gui, Add, Edit, x160 y140 w100 h20 vpostgresdb, %postgresdb% Gui, Add, Text, x5 y160 w150 h20 right, Hotkey "mark current Hand" : Gui, Add, HotKey, x160 y160 w100 h20 vHK_mark, %HK_mark% Gui, Add, Text, x5 y180 w150 h20 right, Hotkey "process sql": Gui, Add, HotKey, x160 y180 w100 h20 vHK_sql, %HK_sql% Gui, Add, Button, x360 y180 w40 h30, OK ; The label ButtonOK (if it exists) will be run when the button is pressed. Gui, Show,, Markhand return ButtonOK: GuiClose: GuiEscape: Gui, Submit IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath IniWrite, %HK_sql%, %thisahk%.ini, LogFolder, HK_sql IniWrite, %HK_mark%, %thisahk%.ini, LogFolder, HK_mark Gui, Destroy return } ;----------------------------------------------------------------------------------------------------- SuspendHotkey: SendInPut, {CTRLDOWN}2{CTRLUP} return ;----------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------- listAdd( byRef list, item, del="," ) { list:=( list!="" ? ( list . del . item ) : item ) return list } ;----------------------------------------------------------------------------------------------------- listDelItem( byRef list, item, del=",") { ifEqual, item,, return list list:=del . list . del StringReplace, list, list, %item%%del% StringTrimLeft, list, list, 1 StringTrimRight, list, list, 1 return list } ;----------------------------------------------------------------------------------------------------- reload: reload return ;----------------------------------------------------------------------------------------------------- Exit: exitapp return ;-----------------------------------------------------------------------------------------------------
Please help, dosnt work anymore for me:
Its after pokerstars changed the hhs from "Game" to "Hand".
Can someone fix this?
Its after pokerstars changed the hhs from "Game" to "Hand".
Can someone fix this?
Anyone? ^^^^
@mckrogh
what are these changes? i don't seem to have these changes in my hhs, i don't have any problems with the script either
and can you please you if there is file gamenumbers.txt in the script-folder and if it has some hh-numbers in it?
what are these changes? i don't seem to have these changes in my hhs, i don't have any problems with the script either
and can you please you if there is file gamenumbers.txt in the script-folder and if it has some hh-numbers in it?
PokerStars Game #72945354692: Tournament #491395187, $6.42+$0.58 USD Hold'em No Limit - Level I (10/20) - 2011/12/29 12:12:50 CET [2011/12/29 6:12:50 ET]
PokerStars Hand #73432218019: Tournament #496189867, $13.78+$1.22 USD Hold'em No Limit - Level I (10/20) - 2012/01/07 13:13:09 CET [2012/01/07 7:13:09 ET]
So i assume it still works on ps.com, but can u fix this so it is working for ps.dk?
I am having the same issue described. any fix /?
I am using pokerstars.com from the uk
currently using hem1
I am using pokerstars.com from the uk
currently using hem1
The file gamenumbers.txt exists in the script folder although there aren't no hh-numbers on it.. its empty.
But there's a temp.txt file that contains several lines like this one:
Update pokerhands Set mark_id = 1 Where gamenumber = AND handtimestamp > localtimestamp - interval '1 days';
Update pokerhands_hero Set mark_id = 1 Where gamenumber = AND handtimestamp > localtimestamp - interval '1 days';
Update pokerhands_hero Set mark_id = 1 Where gamenumber = AND handtimestamp > localtimestamp - interval '1 days';
Why can't you search and replace "Game" with "Hand" in the script?
Sigh, same problem
#noenv
#SingleInstance, Force
SetWinDelay,-1
settitlematchmode,2
StringTrimRight, thisahk, A_ScriptName, 4
SetWorkingDir %A_ScriptDir%
Menu, Tray, NoStandard
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Change Settings, GetMHSettings()
Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey
Menu, Tray, Add, Exit, Exit
Gui, Submit
IniRead, StarsHHLogFolderPath, %thisahk%.ini, LogFolder, StarsHHPath, %A_Space%
IniRead, FullTiltHHLogFolderPath, %thisahk%.ini, LogFolder, FullTiltHHPath, %A_Space%
IniRead, PostgresLogPath, %thisahk%.ini, LogFolder, postgrespath, %A_Space%
IniRead, postgresuser, %thisahk%.ini, LogFolder, postgresuser, %A_Space%
IniRead, postgresdb, %thisahk%.ini, LogFolder, postgresdb, %A_Space%
IniRead, HK_mark, %thisahk%.ini, LogFolder, HK_mark, %A_Space%
IniRead, HK_sql , %thisahk%.ini, LogFolder, HK_sql , %A_Space%
If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb or !HK_mark or !HK_sql)
gosub GetMHSettings()
HotKey, %HK_mark%, l_markhand
HotKey, %HK_sql%, l_processsql
IfExist, gamenumbers.txt
{
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
FileDelete, gamenumbers.txt
}
settimer,checksize,100
return
^2::
Suspend
Return
l_markhand:
winget,id,id,A
wingetclass,class,ahk_id%id%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
else
site=
if site
{
filename:=HHFile(id, dir ,site)
FileGetSize, FileSize, % filename
if !FileSize
FileSize:=0
listadd(filelist, id . "-" . FileSize)
}
return
l_processsql:
IfExist, temp.txt
FileDelete, temp.txt
IfExist, temp.bat
FileDelete, temp.bat
IfExist, %PostgresLogPath%\temp.txt
FileDelete, %PostgresLogPath%\temp.txt
IfExist, %PostgresLogPath%\temp.bat
FileDelete, %PostgresLogPath%\temp.bat
FileRead, numbers, gamenumbers.txt
sql1=Update pokerhands
sql2= Set mark_id = 1
sql3= Where gamenumber =
sql4=AND handtimestamp > localtimestamp - interval '5 days';
sql5=Update pokerhands_hero
Loop, Parse, numbers, `n,
{
if A_loopField
{
FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
FileAppend, %sql5% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
}
}
FileAppend, cd %PostgresLogPath%`npsql.exe %postgresdb% %postgresuser% <temp.txt`npause`n, temp.bat
Filemove, temp.txt, %PostgresLogPath%
Filemove, temp.bat, %PostgresLogPath%
run %PostgresLogPath%\temp.bat
return
;-----------------------------------------------------------------------------------------------------
checksize:
Loop, Parse, filelist, `,
{
stringsplit,tab,A_loopField,-
wingetclass,class,ahk_id%tab1%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
filename:=HHFile(tab1, dir ,site)
FileGetSize, FileSize, % filename
if FileSize
if FileSize!=%tab2%
{
num:=gethhnumber(tab1,site)
FileAppend, %num%`n, gamenumbers.txt
listDelItem(filelist, A_loopField)
}
}
return
;-----------------------------------------------------------------------------------------------------
gethhnumber(winid,site)
{
global StarsHHLogFolderPath,FullTiltHHLogFolderPath
if site=Stars
path=%StarsHHLogFolderPath%
else
path=%FullTiltHHLogFolderPath%
hh:=LastHH(winid,path,site)
Loop, Parse, hh, `n
{
if instr(A_loopfield,"Hand #")
{
stringtrimleft,num,A_loopfield,instr(A_loopfield," #")
stringleft,num,num,instr(num,":")-1
break
}
}
return num
}
;-----------------------------------------------------------------------------------------------------
HHFile(win, dir, site) {
if site=Stars
ext=HH
else
ext=FT
title := WinGetTitle(win)
if !(instr(title,"Tournament")>0 OR instr(title,"Sit & Go")>0)
{
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(a_now, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
}
else
if site=Stars
{
stringtrimleft,file,title,instr(title,"Tournament" )+10
stringleft,file,file,InStr(file, A_space)-1
}
else
{
stringtrimleft,file,title,instr(title,"(")-1
stringleft,file,file,InStr(file, "-")-2
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)>0 & !instr(A_LoopFileName,"Summary")>0
return dir "\" A_LoopFileName
}
EnvAdd, date, -1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
EnvAdd, date, +1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
}
return
;-----------------------------------------------------------------------------------------------------
LastHH(win, dir, site) {
if site=Stars
hand=PokerStars Hand #
else
game=Full Tilt Poker Game #
file@name:=HHFile(win, dir ,site)
FileRead, hh, %file@name%
if !instr(hh,"seat")
{
FileGetSize file@size, %file@name%
FileRead file@buffer, %file@name%
VarSetCapacity(hh, file@size / 2 + 1, 0)
r := DllCall("WideCharToMultiByte"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "Str", file?buffer ; LPCWSTR lpWideCharStr
, "Int", file@size / 2 ; cchWideChar: -1=null terminated
, "Str", hh ; LPSTR lpMultiByteStr
, "Int", file@size / 2 + 1 ; cbMultiByte: 0 to get required size
, "UInt",0 ; LPCSTR lpDefaultChar
, "UInt", 0) ; LPBOOL lpUsedDefaultChar
}
StringTrimLeft, hh, hh, InStr(hh, hand, "", 0)-1
if instr(hh,"SUMMARY")
Stringleft, hh, hh, InStr(hh, "*** SUMMARY", "", 0)-1
return hh
}
;-----------------------------------------------------------------------------------------------------
WinGetTitle(win) {
WinGetTitle, title, ahk_id%win%
return title
}
;-----------------------------------------------------------------------------------------------------
StrRep(str,char,rep_char="",all=1) {
StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0
return str
}
;-----------------------------------------------------------------------------------------------------
StarsHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PokerStars\,, Select the folder with the PokerStars handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, StarsHHLogFolderPath, %SelectedFolder%
StarsHHLogFolderPath := SelectedFolder
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
FullTiltHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\Full Tilt Poker\,, Select the folder with the FullTilt handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, FullTiltHHLogFolderPath, %SelectedFolder%
FullTiltHHLogFolderPath := SelectedFolder
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
PostgresBinFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PostgreSQL\,, Select the folder with the Postgres binary files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, PostgresLogPath, %SelectedFolder%
PostgresLogPath := SelectedFolder
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
postgresuserselect:
InputBox, postgresuser,, enter Postgres Username
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
return
;-----------------------------------------------------------------------------------------------------
postgresdbselect:
InputBox, postgresdb,, enter Postgres Datbase Name
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
return
;-----------------------------------------------------------------------------------------------------
GetMHSettings():
{
Gui, Add, Text, x10 y5 w120 h20 Center, Select Folder Location
Gui, Add, Text, x140 y5 w150 h20 Center, Folder Location
Gui, Add, Button, x5 y20 w150 h20 gPostgresBinFolderSelect center, Postgres Binary Folder
Gui, Add, Edit, x160 y20 w520 h20 vPostgresLogpath, %PostgresLogpath%
Gui, Add, Button, x5 y40 w150 h20 gStarsHHFolderSelect center, Poker Stars HH Folder
Gui, Add, Edit, x160 y40 w520 h20 vStarsHHLogFolderPath, %StarsHHLogFolderPath%
Gui, Add, Button, x5 y60 w150 h20 gFullTiltHHFolderSelect center, Full Tilt HH Folder
Gui, Add, Edit, x160 y60 w520 h20 vFullTiltHHLogFolderPath, %FullTiltHHLogFolderPath%
Gui, Add, Text, x5 y120 w150 h20 right, Postgres User Name:
Gui, Add, Edit, x160 y120 w100 h20 vpostgresuser, %postgresuser%
Gui, Add, Text, x5 y140 w150 h20 right, Postgres Database:
Gui, Add, Edit, x160 y140 w100 h20 vpostgresdb, %postgresdb%
Gui, Add, Text, x5 y160 w150 h20 right, Hotkey "mark current Hand" :
Gui, Add, HotKey, x160 y160 w100 h20 vHK_mark, %HK_mark%
Gui, Add, Text, x5 y180 w150 h20 right, Hotkey "process sql":
Gui, Add, HotKey, x160 y180 w100 h20 vHK_sql, %HK_sql%
Gui, Add, Button, x360 y180 w40 h30, OK ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Markhand
return
ButtonOK:
GuiClose:
GuiEscape:
Gui, Submit
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
IniWrite, %HK_sql%, %thisahk%.ini, LogFolder, HK_sql
IniWrite, %HK_mark%, %thisahk%.ini, LogFolder, HK_mark
Gui, Destroy
return
}
;-----------------------------------------------------------------------------------------------------
SuspendHotkey:
SendInPut, {CTRLDOWN}2{CTRLUP}
return
;-----------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------
listAdd( byRef list, item, del="," ) {
list:=( list!="" ? ( list . del . item ) : item )
return list
}
;-----------------------------------------------------------------------------------------------------
listDelItem( byRef list, item, del=",") {
ifEqual, item,, return list
list:=del . list . del
StringReplace, list, list, %item%%del%
StringTrimLeft, list, list, 1
StringTrimRight, list, list, 1
return list
}
;-----------------------------------------------------------------------------------------------------
reload:
reload
return
;-----------------------------------------------------------------------------------------------------
Exit:
exitapp
return
;-----------------------------------------------------------------------------------------------------
#SingleInstance, Force
SetWinDelay,-1
settitlematchmode,2
StringTrimRight, thisahk, A_ScriptName, 4
SetWorkingDir %A_ScriptDir%
Menu, Tray, NoStandard
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Change Settings, GetMHSettings()
Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey
Menu, Tray, Add, Exit, Exit
Gui, Submit
IniRead, StarsHHLogFolderPath, %thisahk%.ini, LogFolder, StarsHHPath, %A_Space%
IniRead, FullTiltHHLogFolderPath, %thisahk%.ini, LogFolder, FullTiltHHPath, %A_Space%
IniRead, PostgresLogPath, %thisahk%.ini, LogFolder, postgrespath, %A_Space%
IniRead, postgresuser, %thisahk%.ini, LogFolder, postgresuser, %A_Space%
IniRead, postgresdb, %thisahk%.ini, LogFolder, postgresdb, %A_Space%
IniRead, HK_mark, %thisahk%.ini, LogFolder, HK_mark, %A_Space%
IniRead, HK_sql , %thisahk%.ini, LogFolder, HK_sql , %A_Space%
If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb or !HK_mark or !HK_sql)
gosub GetMHSettings()
HotKey, %HK_mark%, l_markhand
HotKey, %HK_sql%, l_processsql
IfExist, gamenumbers.txt
{
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
FileDelete, gamenumbers.txt
}
settimer,checksize,100
return
^2::
Suspend
Return
l_markhand:
winget,id,id,A
wingetclass,class,ahk_id%id%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
else
site=
if site
{
filename:=HHFile(id, dir ,site)
FileGetSize, FileSize, % filename
if !FileSize
FileSize:=0
listadd(filelist, id . "-" . FileSize)
}
return
l_processsql:
IfExist, temp.txt
FileDelete, temp.txt
IfExist, temp.bat
FileDelete, temp.bat
IfExist, %PostgresLogPath%\temp.txt
FileDelete, %PostgresLogPath%\temp.txt
IfExist, %PostgresLogPath%\temp.bat
FileDelete, %PostgresLogPath%\temp.bat
FileRead, numbers, gamenumbers.txt
sql1=Update pokerhands
sql2= Set mark_id = 1
sql3= Where gamenumber =
sql4=AND handtimestamp > localtimestamp - interval '5 days';
sql5=Update pokerhands_hero
Loop, Parse, numbers, `n,
{
if A_loopField
{
FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
FileAppend, %sql5% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
}
}
FileAppend, cd %PostgresLogPath%`npsql.exe %postgresdb% %postgresuser% <temp.txt`npause`n, temp.bat
Filemove, temp.txt, %PostgresLogPath%
Filemove, temp.bat, %PostgresLogPath%
run %PostgresLogPath%\temp.bat
return
;-----------------------------------------------------------------------------------------------------
checksize:
Loop, Parse, filelist, `,
{
stringsplit,tab,A_loopField,-
wingetclass,class,ahk_id%tab1%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
filename:=HHFile(tab1, dir ,site)
FileGetSize, FileSize, % filename
if FileSize
if FileSize!=%tab2%
{
num:=gethhnumber(tab1,site)
FileAppend, %num%`n, gamenumbers.txt
listDelItem(filelist, A_loopField)
}
}
return
;-----------------------------------------------------------------------------------------------------
gethhnumber(winid,site)
{
global StarsHHLogFolderPath,FullTiltHHLogFolderPath
if site=Stars
path=%StarsHHLogFolderPath%
else
path=%FullTiltHHLogFolderPath%
hh:=LastHH(winid,path,site)
Loop, Parse, hh, `n
{
if instr(A_loopfield,"Hand #")
{
stringtrimleft,num,A_loopfield,instr(A_loopfield," #")
stringleft,num,num,instr(num,":")-1
break
}
}
return num
}
;-----------------------------------------------------------------------------------------------------
HHFile(win, dir, site) {
if site=Stars
ext=HH
else
ext=FT
title := WinGetTitle(win)
if !(instr(title,"Tournament")>0 OR instr(title,"Sit & Go")>0)
{
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(a_now, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
}
else
if site=Stars
{
stringtrimleft,file,title,instr(title,"Tournament" )+10
stringleft,file,file,InStr(file, A_space)-1
}
else
{
stringtrimleft,file,title,instr(title,"(")-1
stringleft,file,file,InStr(file, "-")-2
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)>0 & !instr(A_LoopFileName,"Summary")>0
return dir "\" A_LoopFileName
}
EnvAdd, date, -1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
EnvAdd, date, +1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
}
return
;-----------------------------------------------------------------------------------------------------
LastHH(win, dir, site) {
if site=Stars
hand=PokerStars Hand #
else
game=Full Tilt Poker Game #
file@name:=HHFile(win, dir ,site)
FileRead, hh, %file@name%
if !instr(hh,"seat")
{
FileGetSize file@size, %file@name%
FileRead file@buffer, %file@name%
VarSetCapacity(hh, file@size / 2 + 1, 0)
r := DllCall("WideCharToMultiByte"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "Str", file?buffer ; LPCWSTR lpWideCharStr
, "Int", file@size / 2 ; cchWideChar: -1=null terminated
, "Str", hh ; LPSTR lpMultiByteStr
, "Int", file@size / 2 + 1 ; cbMultiByte: 0 to get required size
, "UInt",0 ; LPCSTR lpDefaultChar
, "UInt", 0) ; LPBOOL lpUsedDefaultChar
}
StringTrimLeft, hh, hh, InStr(hh, hand, "", 0)-1
if instr(hh,"SUMMARY")
Stringleft, hh, hh, InStr(hh, "*** SUMMARY", "", 0)-1
return hh
}
;-----------------------------------------------------------------------------------------------------
WinGetTitle(win) {
WinGetTitle, title, ahk_id%win%
return title
}
;-----------------------------------------------------------------------------------------------------
StrRep(str,char,rep_char="",all=1) {
StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0
return str
}
;-----------------------------------------------------------------------------------------------------
StarsHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PokerStars\,, Select the folder with the PokerStars handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, StarsHHLogFolderPath, %SelectedFolder%
StarsHHLogFolderPath := SelectedFolder
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
FullTiltHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\Full Tilt Poker\,, Select the folder with the FullTilt handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, FullTiltHHLogFolderPath, %SelectedFolder%
FullTiltHHLogFolderPath := SelectedFolder
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
PostgresBinFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PostgreSQL\,, Select the folder with the Postgres binary files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, PostgresLogPath, %SelectedFolder%
PostgresLogPath := SelectedFolder
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
postgresuserselect:
InputBox, postgresuser,, enter Postgres Username
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
return
;-----------------------------------------------------------------------------------------------------
postgresdbselect:
InputBox, postgresdb,, enter Postgres Datbase Name
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
return
;-----------------------------------------------------------------------------------------------------
GetMHSettings():
{
Gui, Add, Text, x10 y5 w120 h20 Center, Select Folder Location
Gui, Add, Text, x140 y5 w150 h20 Center, Folder Location
Gui, Add, Button, x5 y20 w150 h20 gPostgresBinFolderSelect center, Postgres Binary Folder
Gui, Add, Edit, x160 y20 w520 h20 vPostgresLogpath, %PostgresLogpath%
Gui, Add, Button, x5 y40 w150 h20 gStarsHHFolderSelect center, Poker Stars HH Folder
Gui, Add, Edit, x160 y40 w520 h20 vStarsHHLogFolderPath, %StarsHHLogFolderPath%
Gui, Add, Button, x5 y60 w150 h20 gFullTiltHHFolderSelect center, Full Tilt HH Folder
Gui, Add, Edit, x160 y60 w520 h20 vFullTiltHHLogFolderPath, %FullTiltHHLogFolderPath%
Gui, Add, Text, x5 y120 w150 h20 right, Postgres User Name:
Gui, Add, Edit, x160 y120 w100 h20 vpostgresuser, %postgresuser%
Gui, Add, Text, x5 y140 w150 h20 right, Postgres Database:
Gui, Add, Edit, x160 y140 w100 h20 vpostgresdb, %postgresdb%
Gui, Add, Text, x5 y160 w150 h20 right, Hotkey "mark current Hand" :
Gui, Add, HotKey, x160 y160 w100 h20 vHK_mark, %HK_mark%
Gui, Add, Text, x5 y180 w150 h20 right, Hotkey "process sql":
Gui, Add, HotKey, x160 y180 w100 h20 vHK_sql, %HK_sql%
Gui, Add, Button, x360 y180 w40 h30, OK ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Markhand
return
ButtonOK:
GuiClose:
GuiEscape:
Gui, Submit
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
IniWrite, %HK_sql%, %thisahk%.ini, LogFolder, HK_sql
IniWrite, %HK_mark%, %thisahk%.ini, LogFolder, HK_mark
Gui, Destroy
return
}
;-----------------------------------------------------------------------------------------------------
SuspendHotkey:
SendInPut, {CTRLDOWN}2{CTRLUP}
return
;-----------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------
listAdd( byRef list, item, del="," ) {
list:=( list!="" ? ( list . del . item ) : item )
return list
}
;-----------------------------------------------------------------------------------------------------
listDelItem( byRef list, item, del=",") {
ifEqual, item,, return list
list:=del . list . del
StringReplace, list, list, %item%%del%
StringTrimLeft, list, list, 1
StringTrimRight, list, list, 1
return list
}
;-----------------------------------------------------------------------------------------------------
reload:
reload
return
;-----------------------------------------------------------------------------------------------------
Exit:
exitapp
return
;-----------------------------------------------------------------------------------------------------
thx mckrogh but still ain't working... same error. :/
It's not the same error. This works to mark the hand, it's just including the hash symbol erroneously. Simply continue to mark the hands as per normal with this script, then when you want to process the gamenumbers.txt to mark them in HEM, edit the gamenumbers.txt to remove all of the hash tags before the hand number. Works fine then. A quick and dirty solution until I/someone else gets around to get the script to drop the hash tag.
This should return just the hand number without the hash symbol. Simulated debug test says it will work, about to go live with it to test.
Shoutout to Excedrin for the fix!
Shoutout to Excedrin for the fix!
#noenv
#SingleInstance, Force
SetWinDelay,-1
settitlematchmode,2
StringTrimRight, thisahk, A_ScriptName, 4
SetWorkingDir %A_ScriptDir%
Menu, Tray, NoStandard
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Change Settings, GetMHSettings()
Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey
Menu, Tray, Add, Exit, Exit
Gui, Submit
IniRead, StarsHHLogFolderPath, %thisahk%.ini, LogFolder, StarsHHPath, %A_Space%
IniRead, FullTiltHHLogFolderPath, %thisahk%.ini, LogFolder, FullTiltHHPath, %A_Space%
IniRead, PostgresLogPath, %thisahk%.ini, LogFolder, postgrespath, %A_Space%
IniRead, postgresuser, %thisahk%.ini, LogFolder, postgresuser, %A_Space%
IniRead, postgresdb, %thisahk%.ini, LogFolder, postgresdb, %A_Space%
IniRead, HK_mark, %thisahk%.ini, LogFolder, HK_mark, %A_Space%
IniRead, HK_sql , %thisahk%.ini, LogFolder, HK_sql , %A_Space%
If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb or !HK_mark or !HK_sql)
gosub GetMHSettings()
HotKey, %HK_mark%, l_markhand
HotKey, %HK_sql%, l_processsql
IfExist, gamenumbers.txt
{
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
FileDelete, gamenumbers.txt
}
settimer,checksize,100
return
^2::
Suspend
Return
l_markhand:
winget,id,id,A
wingetclass,class,ahk_id%id%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
else
site=
if site
{
filename:=HHFile(id, dir ,site)
FileGetSize, FileSize, % filename
if !FileSize
FileSize:=0
listadd(filelist, id . "-" . FileSize)
}
return
l_processsql:
IfExist, temp.txt
FileDelete, temp.txt
IfExist, temp.bat
FileDelete, temp.bat
IfExist, %PostgresLogPath%\temp.txt
FileDelete, %PostgresLogPath%\temp.txt
IfExist, %PostgresLogPath%\temp.bat
FileDelete, %PostgresLogPath%\temp.bat
FileRead, numbers, gamenumbers.txt
sql1=Update pokerhands
sql2= Set mark_id = 1
sql3= Where gamenumber =
sql4=AND handtimestamp > localtimestamp - interval '5 days';
sql5=Update pokerhands_hero
Loop, Parse, numbers, `n,
{
if A_loopField
{
FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
FileAppend, %sql5% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
}
}
FileAppend, cd %PostgresLogPath%`npsql.exe %postgresdb% %postgresuser% <temp.txt`npause`n, temp.bat
Filemove, temp.txt, %PostgresLogPath%
Filemove, temp.bat, %PostgresLogPath%
run %PostgresLogPath%\temp.bat
return
;-----------------------------------------------------------------------------------------------------
checksize:
Loop, Parse, filelist, `,
{
stringsplit,tab,A_loopField,-
wingetclass,class,ahk_id%tab1%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
filename:=HHFile(tab1, dir ,site)
FileGetSize, FileSize, % filename
if FileSize
if FileSize!=%tab2%
{
num:=gethhnumber(tab1,site)
FileAppend, %num%`n, gamenumbers.txt
listDelItem(filelist, A_loopField)
}
}
return
;-----------------------------------------------------------------------------------------------------
gethhnumber(winid,site)
{
global StarsHHLogFolderPath,FullTiltHHLogFolderPath
if site=Stars
path=%StarsHHLogFolderPath%
else
path=%FullTiltHHLogFolderPath%
hh:=LastHH(winid,path,site)
Loop, Parse, hh, `n
{
if instr(A_loopfield,"Hand #")
{
stringtrimleft,num,A_loopfield,instr(A_loopfield," #")
num := SubStr(num, 2, instr(num, ":") - 2)
break
}
}
return num
}
;-----------------------------------------------------------------------------------------------------
HHFile(win, dir, site) {
if site=Stars
ext=HH
else
ext=FT
title := WinGetTitle(win)
if !(instr(title,"Tournament")>0 OR instr(title,"Sit & Go")>0)
{
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(a_now, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
}
else
if site=Stars
{
stringtrimleft,file,title,instr(title,"Tournament" )+10
stringleft,file,file,InStr(file, A_space)-1
}
else
{
stringtrimleft,file,title,instr(title,"(")-1
stringleft,file,file,InStr(file, "-")-2
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)>0 & !instr(A_LoopFileName,"Summary")>0
return dir "\" A_LoopFileName
}
EnvAdd, date, -1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
EnvAdd, date, +1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
}
return
;-----------------------------------------------------------------------------------------------------
LastHH(win, dir, site) {
if site=Stars
hand=PokerStars Hand #
else
game=Full Tilt Poker Game #
file@name:=HHFile(win, dir ,site)
FileRead, hh, %file@name%
if !instr(hh,"seat")
{
FileGetSize file@size, %file@name%
FileRead file@buffer, %file@name%
VarSetCapacity(hh, file@size / 2 + 1, 0)
r := DllCall("WideCharToMultiByte"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "Str", file?buffer ; LPCWSTR lpWideCharStr
, "Int", file@size / 2 ; cchWideChar: -1=null terminated
, "Str", hh ; LPSTR lpMultiByteStr
, "Int", file@size / 2 + 1 ; cbMultiByte: 0 to get required size
, "UInt",0 ; LPCSTR lpDefaultChar
, "UInt", 0) ; LPBOOL lpUsedDefaultChar
}
StringTrimLeft, hh, hh, InStr(hh, hand, "", 0)-1
if instr(hh,"SUMMARY")
Stringleft, hh, hh, InStr(hh, "*** SUMMARY", "", 0)-1
return hh
}
;-----------------------------------------------------------------------------------------------------
WinGetTitle(win) {
WinGetTitle, title, ahk_id%win%
return title
}
;-----------------------------------------------------------------------------------------------------
StrRep(str,char,rep_char="",all=1) {
StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0
return str
}
;-----------------------------------------------------------------------------------------------------
StarsHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PokerStars\,, Select the folder with the PokerStars handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, StarsHHLogFolderPath, %SelectedFolder%
StarsHHLogFolderPath := SelectedFolder
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
FullTiltHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\Full Tilt Poker\,, Select the folder with the FullTilt handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, FullTiltHHLogFolderPath, %SelectedFolder%
FullTiltHHLogFolderPath := SelectedFolder
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
PostgresBinFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PostgreSQL\,, Select the folder with the Postgres binary files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, PostgresLogPath, %SelectedFolder%
PostgresLogPath := SelectedFolder
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
postgresuserselect:
InputBox, postgresuser,, enter Postgres Username
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
return
;-----------------------------------------------------------------------------------------------------
postgresdbselect:
InputBox, postgresdb,, enter Postgres Datbase Name
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
return
;-----------------------------------------------------------------------------------------------------
GetMHSettings():
{
Gui, Add, Text, x10 y5 w120 h20 Center, Select Folder Location
Gui, Add, Text, x140 y5 w150 h20 Center, Folder Location
Gui, Add, Button, x5 y20 w150 h20 gPostgresBinFolderSelect center, Postgres Binary Folder
Gui, Add, Edit, x160 y20 w520 h20 vPostgresLogpath, %PostgresLogpath%
Gui, Add, Button, x5 y40 w150 h20 gStarsHHFolderSelect center, Poker Stars HH Folder
Gui, Add, Edit, x160 y40 w520 h20 vStarsHHLogFolderPath, %StarsHHLogFolderPath%
Gui, Add, Button, x5 y60 w150 h20 gFullTiltHHFolderSelect center, Full Tilt HH Folder
Gui, Add, Edit, x160 y60 w520 h20 vFullTiltHHLogFolderPath, %FullTiltHHLogFolderPath%
Gui, Add, Text, x5 y120 w150 h20 right, Postgres User Name:
Gui, Add, Edit, x160 y120 w100 h20 vpostgresuser, %postgresuser%
Gui, Add, Text, x5 y140 w150 h20 right, Postgres Database:
Gui, Add, Edit, x160 y140 w100 h20 vpostgresdb, %postgresdb%
Gui, Add, Text, x5 y160 w150 h20 right, Hotkey "mark current Hand" :
Gui, Add, HotKey, x160 y160 w100 h20 vHK_mark, %HK_mark%
Gui, Add, Text, x5 y180 w150 h20 right, Hotkey "process sql":
Gui, Add, HotKey, x160 y180 w100 h20 vHK_sql, %HK_sql%
Gui, Add, Button, x360 y180 w40 h30, OK ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Markhand
return
ButtonOK:
GuiClose:
GuiEscape:
Gui, Submit
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
IniWrite, %HK_sql%, %thisahk%.ini, LogFolder, HK_sql
IniWrite, %HK_mark%, %thisahk%.ini, LogFolder, HK_mark
Gui, Destroy
return
}
;-----------------------------------------------------------------------------------------------------
SuspendHotkey:
SendInPut, {CTRLDOWN}2{CTRLUP}
return
;-----------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------
listAdd( byRef list, item, del="," ) {
list:=( list!="" ? ( list . del . item ) : item )
return list
}
;-----------------------------------------------------------------------------------------------------
listDelItem( byRef list, item, del=",") {
ifEqual, item,, return list
list:=del . list . del
StringReplace, list, list, %item%%del%
StringTrimLeft, list, list, 1
StringTrimRight, list, list, 1
return list
}
;-----------------------------------------------------------------------------------------------------
reload:
reload
return
;-----------------------------------------------------------------------------------------------------
Exit:
exitapp
return
;-----------------------------------------------------------------------------------------------------
#SingleInstance, Force
SetWinDelay,-1
settitlematchmode,2
StringTrimRight, thisahk, A_ScriptName, 4
SetWorkingDir %A_ScriptDir%
Menu, Tray, NoStandard
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Change Settings, GetMHSettings()
Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey
Menu, Tray, Add, Exit, Exit
Gui, Submit
IniRead, StarsHHLogFolderPath, %thisahk%.ini, LogFolder, StarsHHPath, %A_Space%
IniRead, FullTiltHHLogFolderPath, %thisahk%.ini, LogFolder, FullTiltHHPath, %A_Space%
IniRead, PostgresLogPath, %thisahk%.ini, LogFolder, postgrespath, %A_Space%
IniRead, postgresuser, %thisahk%.ini, LogFolder, postgresuser, %A_Space%
IniRead, postgresdb, %thisahk%.ini, LogFolder, postgresdb, %A_Space%
IniRead, HK_mark, %thisahk%.ini, LogFolder, HK_mark, %A_Space%
IniRead, HK_sql , %thisahk%.ini, LogFolder, HK_sql , %A_Space%
If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb or !HK_mark or !HK_sql)
gosub GetMHSettings()
HotKey, %HK_mark%, l_markhand
HotKey, %HK_sql%, l_processsql
IfExist, gamenumbers.txt
{
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
FileDelete, gamenumbers.txt
}
settimer,checksize,100
return
^2::
Suspend
Return
l_markhand:
winget,id,id,A
wingetclass,class,ahk_id%id%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
else
site=
if site
{
filename:=HHFile(id, dir ,site)
FileGetSize, FileSize, % filename
if !FileSize
FileSize:=0
listadd(filelist, id . "-" . FileSize)
}
return
l_processsql:
IfExist, temp.txt
FileDelete, temp.txt
IfExist, temp.bat
FileDelete, temp.bat
IfExist, %PostgresLogPath%\temp.txt
FileDelete, %PostgresLogPath%\temp.txt
IfExist, %PostgresLogPath%\temp.bat
FileDelete, %PostgresLogPath%\temp.bat
FileRead, numbers, gamenumbers.txt
sql1=Update pokerhands
sql2= Set mark_id = 1
sql3= Where gamenumber =
sql4=AND handtimestamp > localtimestamp - interval '5 days';
sql5=Update pokerhands_hero
Loop, Parse, numbers, `n,
{
if A_loopField
{
FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
FileAppend, %sql5% %sql2% %sql3% %A_loopField% %sql4%`n, temp.txt
}
}
FileAppend, cd %PostgresLogPath%`npsql.exe %postgresdb% %postgresuser% <temp.txt`npause`n, temp.bat
Filemove, temp.txt, %PostgresLogPath%
Filemove, temp.bat, %PostgresLogPath%
run %PostgresLogPath%\temp.bat
return
;-----------------------------------------------------------------------------------------------------
checksize:
Loop, Parse, filelist, `,
{
stringsplit,tab,A_loopField,-
wingetclass,class,ahk_id%tab1%
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
filename:=HHFile(tab1, dir ,site)
FileGetSize, FileSize, % filename
if FileSize
if FileSize!=%tab2%
{
num:=gethhnumber(tab1,site)
FileAppend, %num%`n, gamenumbers.txt
listDelItem(filelist, A_loopField)
}
}
return
;-----------------------------------------------------------------------------------------------------
gethhnumber(winid,site)
{
global StarsHHLogFolderPath,FullTiltHHLogFolderPath
if site=Stars
path=%StarsHHLogFolderPath%
else
path=%FullTiltHHLogFolderPath%
hh:=LastHH(winid,path,site)
Loop, Parse, hh, `n
{
if instr(A_loopfield,"Hand #")
{
stringtrimleft,num,A_loopfield,instr(A_loopfield," #")
num := SubStr(num, 2, instr(num, ":") - 2)
break
}
}
return num
}
;-----------------------------------------------------------------------------------------------------
HHFile(win, dir, site) {
if site=Stars
ext=HH
else
ext=FT
title := WinGetTitle(win)
if !(instr(title,"Tournament")>0 OR instr(title,"Sit & Go")>0)
{
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(a_now, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
}
else
if site=Stars
{
stringtrimleft,file,title,instr(title,"Tournament" )+10
stringleft,file,file,InStr(file, A_space)-1
}
else
{
stringtrimleft,file,title,instr(title,"(")-1
stringleft,file,file,InStr(file, "-")-2
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)>0 & !instr(A_LoopFileName,"Summary")>0
return dir "\" A_LoopFileName
}
EnvAdd, date, -1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
EnvAdd, date, +1, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
StringReplace, file, file, USD -,- USD,
StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
}
return
;-----------------------------------------------------------------------------------------------------
LastHH(win, dir, site) {
if site=Stars
hand=PokerStars Hand #
else
game=Full Tilt Poker Game #
file@name:=HHFile(win, dir ,site)
FileRead, hh, %file@name%
if !instr(hh,"seat")
{
FileGetSize file@size, %file@name%
FileRead file@buffer, %file@name%
VarSetCapacity(hh, file@size / 2 + 1, 0)
r := DllCall("WideCharToMultiByte"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "Str", file?buffer ; LPCWSTR lpWideCharStr
, "Int", file@size / 2 ; cchWideChar: -1=null terminated
, "Str", hh ; LPSTR lpMultiByteStr
, "Int", file@size / 2 + 1 ; cbMultiByte: 0 to get required size
, "UInt",0 ; LPCSTR lpDefaultChar
, "UInt", 0) ; LPBOOL lpUsedDefaultChar
}
StringTrimLeft, hh, hh, InStr(hh, hand, "", 0)-1
if instr(hh,"SUMMARY")
Stringleft, hh, hh, InStr(hh, "*** SUMMARY", "", 0)-1
return hh
}
;-----------------------------------------------------------------------------------------------------
WinGetTitle(win) {
WinGetTitle, title, ahk_id%win%
return title
}
;-----------------------------------------------------------------------------------------------------
StrRep(str,char,rep_char="",all=1) {
StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0
return str
}
;-----------------------------------------------------------------------------------------------------
StarsHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PokerStars\,, Select the folder with the PokerStars handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, StarsHHLogFolderPath, %SelectedFolder%
StarsHHLogFolderPath := SelectedFolder
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
FullTiltHHFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\Full Tilt Poker\,, Select the folder with the FullTilt handhistory files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, FullTiltHHLogFolderPath, %SelectedFolder%
FullTiltHHLogFolderPath := SelectedFolder
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
PostgresBinFolderSelect:
FileSelectFolder, SelectedFolder, *%ProgramFiles%\PostgreSQL\,, Select the folder with the Postgres binary files
Folder := RegExReplace(Folder, "\\$") ; Removes the trailing backslash, if present.
If SelectedFolder <> ;the user selected a folder
{
GuiControl,, PostgresLogPath, %SelectedFolder%
PostgresLogPath := SelectedFolder
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
Gui, Submit, NoHide
}
return
;-----------------------------------------------------------------------------------------------------
postgresuserselect:
InputBox, postgresuser,, enter Postgres Username
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
return
;-----------------------------------------------------------------------------------------------------
postgresdbselect:
InputBox, postgresdb,, enter Postgres Datbase Name
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
return
;-----------------------------------------------------------------------------------------------------
GetMHSettings():
{
Gui, Add, Text, x10 y5 w120 h20 Center, Select Folder Location
Gui, Add, Text, x140 y5 w150 h20 Center, Folder Location
Gui, Add, Button, x5 y20 w150 h20 gPostgresBinFolderSelect center, Postgres Binary Folder
Gui, Add, Edit, x160 y20 w520 h20 vPostgresLogpath, %PostgresLogpath%
Gui, Add, Button, x5 y40 w150 h20 gStarsHHFolderSelect center, Poker Stars HH Folder
Gui, Add, Edit, x160 y40 w520 h20 vStarsHHLogFolderPath, %StarsHHLogFolderPath%
Gui, Add, Button, x5 y60 w150 h20 gFullTiltHHFolderSelect center, Full Tilt HH Folder
Gui, Add, Edit, x160 y60 w520 h20 vFullTiltHHLogFolderPath, %FullTiltHHLogFolderPath%
Gui, Add, Text, x5 y120 w150 h20 right, Postgres User Name:
Gui, Add, Edit, x160 y120 w100 h20 vpostgresuser, %postgresuser%
Gui, Add, Text, x5 y140 w150 h20 right, Postgres Database:
Gui, Add, Edit, x160 y140 w100 h20 vpostgresdb, %postgresdb%
Gui, Add, Text, x5 y160 w150 h20 right, Hotkey "mark current Hand" :
Gui, Add, HotKey, x160 y160 w100 h20 vHK_mark, %HK_mark%
Gui, Add, Text, x5 y180 w150 h20 right, Hotkey "process sql":
Gui, Add, HotKey, x160 y180 w100 h20 vHK_sql, %HK_sql%
Gui, Add, Button, x360 y180 w40 h30, OK ; The label ButtonOK (if it exists) will be run when the button is pressed.
Gui, Show,, Markhand
return
ButtonOK:
GuiClose:
GuiEscape:
Gui, Submit
IniWrite, %postgresdb%, %thisahk%.ini, LogFolder, postgresdb
IniWrite, %postgresuser%, %thisahk%.ini, LogFolder, postgresuser
IniWrite, %PostgresLogPath%, %thisahk%.ini, LogFolder, postgrespath
IniWrite, %FullTiltHHLogFolderPath%, %thisahk%.ini, LogFolder, FullTiltHHPath
IniWrite, %StarsHHLogFolderPath%, %thisahk%.ini, LogFolder, StarsHHPath
IniWrite, %HK_sql%, %thisahk%.ini, LogFolder, HK_sql
IniWrite, %HK_mark%, %thisahk%.ini, LogFolder, HK_mark
Gui, Destroy
return
}
;-----------------------------------------------------------------------------------------------------
SuspendHotkey:
SendInPut, {CTRLDOWN}2{CTRLUP}
return
;-----------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------
listAdd( byRef list, item, del="," ) {
list:=( list!="" ? ( list . del . item ) : item )
return list
}
;-----------------------------------------------------------------------------------------------------
listDelItem( byRef list, item, del=",") {
ifEqual, item,, return list
list:=del . list . del
StringReplace, list, list, %item%%del%
StringTrimLeft, list, list, 1
StringTrimRight, list, list, 1
return list
}
;-----------------------------------------------------------------------------------------------------
reload:
reload
return
;-----------------------------------------------------------------------------------------------------
Exit:
exitapp
return
;-----------------------------------------------------------------------------------------------------
Okay this is weird. Im not getting any errors at all. Working fine at my computer after making the changes.
is the above script working for hem1? hem2? or both?
Mine is for HM1. Wonder if anyone use it with HM2?
anyone got a script working in hem2 yet?
Feedback is used for internal purposes. LEARN MORE