Open Side Menu Go to the Top
Register
Script: Mark Current Hand Script: Mark Current Hand

11-04-2011 , 06:01 PM
Quote:
Originally Posted by TTR
though I was alpha testing they seem to be unable to get me a beta-license. Will tell you asap.
You can download and use the trial version:

http://www.holdemmanager.com/downloa...er_2_Setup.exe
Script: Mark Current Hand Quote
11-04-2011 , 06:55 PM
Quote:
Originally Posted by mypkrstuff
any update on hm2 compatability?
will have something by next week


Quote:
Originally Posted by udbrky
You can download and use the trial version:

http://www.holdemmanager.com/downloa...er_2_Setup.exe
meanwhile I got a key. I have to apologize btw, I took so long because I confused my email accounts
Script: Mark Current Hand Quote
11-04-2011 , 07:40 PM
great job ttr, am lloking forward to functionality with hm2
Script: Mark Current Hand Quote
11-05-2011 , 07:41 PM
Make it work for party, please.
Script: Mark Current Hand Quote
11-24-2011 , 07:46 PM
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?
Script: Mark Current Hand Quote
12-06-2011 , 06:36 AM
update for hm2?
Script: Mark Current Hand Quote
12-14-2011 , 07:58 AM
Quote:
Originally Posted by mckrogh
update for hm2?
+1

having to hold of using hem2 till i get this working
Script: Mark Current Hand Quote
12-29-2011 , 07:24 PM
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".

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
;-----------------------------------------------------------------------------------------------------
Script: Mark Current Hand Quote
12-29-2011 , 07:25 PM
Quote:
Originally Posted by Pilch
... my database need renaming?
pretty sure this will do the trick
Script: Mark Current Hand Quote
01-04-2012 , 06:23 PM
Please help, dosnt work anymore for me:





Its after pokerstars changed the hhs from "Game" to "Hand".

Can someone fix this?
Script: Mark Current Hand Quote
01-05-2012 , 04:36 PM
Anyone? ^^^^
Script: Mark Current Hand Quote
01-08-2012 , 10:43 AM
@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?
Script: Mark Current Hand Quote
01-08-2012 , 11:52 AM
Quote:
Originally Posted by TTR
@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?
They change from this

Quote:
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]
to this

Quote:
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]
They have done that for all pokestars the do not end on .com

So i assume it still works on ps.com, but can u fix this so it is working for ps.dk?
Script: Mark Current Hand Quote
01-09-2012 , 06:16 PM
I am having the same issue described. any fix /?
I am using pokerstars.com from the uk
currently using hem1
Script: Mark Current Hand Quote
01-09-2012 , 09:01 PM
Quote:
Originally Posted by mypkrstuff
I am having the same issue described. any fix /?
I am using pokerstars.com from
currently using hem1
+1

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:

Quote:
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';
Any ideas ? It was working perfectly until pokerstars update today.
Script: Mark Current Hand Quote
01-09-2012 , 09:54 PM
Why can't you search and replace "Game" with "Hand" in the script?
Script: Mark Current Hand Quote
01-10-2012 , 04:09 PM
Sigh, same problem
Script: Mark Current Hand Quote
01-10-2012 , 06:09 PM
Quote:
#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
;-----------------------------------------------------------------------------------------------------
This should work. I have changed it for the new hhs format. Hope it works for u guys to.
Script: Mark Current Hand Quote
01-10-2012 , 09:12 PM
thx mckrogh but still ain't working... same error. :/
Script: Mark Current Hand Quote
01-10-2012 , 09:28 PM
Quote:
Originally Posted by Goos
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.
Script: Mark Current Hand Quote
01-10-2012 , 09:56 PM
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!
Quote:
#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
;-----------------------------------------------------------------------------------------------------

Last edited by JechtSphere; 01-10-2012 at 10:17 PM.
Script: Mark Current Hand Quote
01-11-2012 , 04:10 AM
Okay this is weird. Im not getting any errors at all. Working fine at my computer after making the changes.
Script: Mark Current Hand Quote
01-15-2012 , 06:35 PM
is the above script working for hem1? hem2? or both?
Script: Mark Current Hand Quote
01-17-2012 , 05:50 AM
Mine is for HM1. Wonder if anyone use it with HM2?
Script: Mark Current Hand Quote
01-20-2012 , 11:07 AM
anyone got a script working in hem2 yet?
Script: Mark Current Hand Quote

      
m