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

01-31-2012 , 04:08 AM
not working for me, is this for cash games as well?
Script: Mark Current Hand Quote
02-16-2012 , 12:03 AM
Hey guys, was hoping someone could help me.

I have downloaded everything and installed, but when I come to end the session it first asks for my postgres pass (which I found from earlier posts), but then it comes up with:

"psql: FATAL: database "HoldemManager" does not exist"


Anybody got an idea of where I am going wrong?

I have my pokerstars handhistory folder saved to the desktop, would this affect it?

Thanks in advance
Script: Mark Current Hand Quote
02-16-2012 , 06:37 PM
Already got some help with it thanks
Script: Mark Current Hand Quote
02-18-2012 , 02:55 AM
is it possible to make AHK script - pot-odds on table for Ipoker and PokerStars?
Script: Mark Current Hand Quote
02-23-2012 , 06:59 AM
I'm sorry can anyone please tell me how do I install this script for HEM1? I mean i copy that script but where do I paste it?

Thank you
Script: Mark Current Hand Quote
03-03-2012 , 03:21 AM
Why is it asking me for a password for my database when i execute the script?
Script: Mark Current Hand Quote
03-13-2012 , 04:51 PM
Hello guys, thx for a the script. Last used it when FTP was alive (everything was fine back then) and now I copied last code source but somehow it marks random hands that I do not want to. During session I marked like 5 but it HEM it is like 30 )

I also use hot keys that PS provide from diff actions. Could someone help me?
Thanks in advance.
Script: Mark Current Hand Quote
03-26-2012 , 01:34 AM
It looks like this isn't going to work with the upcoming HEM1 1.12.10 version.

When I press the hotkey to get it to go through the hands I've marked it says:

"The system cannot find the file specified" which it seems is referring to "psql.exe holdemmanager postgres 0"

Any ideas? (beyond reverting to 1.12.09 obv)
Script: Mark Current Hand Quote
03-26-2012 , 08:43 AM
Quote:
Originally Posted by theMBK
It looks like this isn't going to work with the upcoming HEM1 1.12.10 version.

When I press the hotkey to get it to go through the hands I've marked it says:

"The system cannot find the file specified" which it seems is referring to "psql.exe holdemmanager postgres 0"

Any ideas? (beyond reverting to 1.12.09 obv)
Nm, new batch of hands worked fine
Script: Mark Current Hand Quote
03-29-2012 , 05:01 PM
L:\Markhands>cd C:\Program Files (x86)\PostgreSQL\8.4\bin

L:\Markhands>psql.exe 180 postgres 0<temp.txt
The system cannot find the file specified.

L:\Markhands>pause
Press any key to continue . . .


Getting this error , anyone to help ?
Script: Mark Current Hand Quote
03-30-2012 , 01:26 AM
Quote:
Originally Posted by clickys
L:\Markhands>cd C:\Program Files (x86)\PostgreSQL\8.4\bin

L:\Markhands>psql.exe 180 postgres 0<temp.txt
The system cannot find the file specified.

L:\Markhands>pause
Press any key to continue . . .


Getting this error , anyone to help ?
That's what I got, did you update HEM? All I know is it worked fine on my next batch of marked hands...
Script: Mark Current Hand Quote
03-30-2012 , 08:59 AM
My hem version is 1.12.09
Script: Mark Current Hand Quote
04-04-2012 , 10:17 AM
anyone ?
Script: Mark Current Hand Quote
04-04-2012 , 11:07 AM
This version works fine for me (HM1), run it as admin if you have Vista/W7.
Code:
#noenv 
#SingleInstance, Force
SetWinDelay,-1
settitlematchmode,2

Menu, Tray, NoStandard
;Menu, Tray, Icon, Markhands.ico,1,1
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Change Settings,  showgui
Menu, Tray, Default, Change Settings
Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey
Menu, Tray, Add
Menu, Tray, Add, Submit to Database, l_processsql
Menu, Tray, Add, Exit, Exit
Gui, Submit

StringTrimRight, thisahk, A_ScriptName, 4
SetWorkingDir %A_ScriptDir%

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%

gosub,buildgui
If (!HK_mark || !HK_sql)
{
  ; gosub GetMHSettings
 Gui, Show,, Markhand 
}

if HK_mark
HotKey, %HK_mark%, l_markhand
if HK_sql
HotKey, %HK_sql%, l_processsql

IfExist, gamenumbers.txt
  gosub deletetext


settimer,checksize,55
return


^2::
Suspend
Return

l_markhand:
winget,id,id,A
wingetclass,class,ahk_id%id%
class=PokerStarsTableFrameClass
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
else
site=
if site
{
 filename:=HHFile(id, dir ,site) 
 fileread,tempstr,%filename%
 tempstr=
 sleep,50
 FileGetSize, FileSize, % filename
 if !FileSize
 FileSize:=0
 if !instr(filelist,id) 
 listadd(filelist, id . "-" . FileSize)
}
return

l_processsql:
IfExist, temp.txt
FileDelete, temp.txt
IfExist, temp.bat
FileDelete, temp.bat
loop gamenumbers.*
FileRead, numbers, %A_LoopFileName%
if numbers
{
sql1=Update pokerhands
sql2=Set mark_id = 1
sql3=Where gamenumber = 
sql4=AND handtimestamp > localtimestamp - interval '1 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, "%PostgresLogPath%\psql.exe"%A_space%"%postgresdb%"%A_space%"%postgresuser%"%A_space%0<"%A_ScriptDir%\temp.txt"`r`npause`n, temp.bat
run temp.bat
}
else
msgbox, gamenumbers.txt file doesn't exist or file is empty.
numbers=
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) 
 fileread,tempstr,%filename%
 tempstr=
 sleep,50
 FileGetSize, FileSize, % filename
 if FileSize
 if FileSize!=%tab2%
 {
  num:=gethhnumber(tab1,site)
  fileread,tempnum,gamenumbers.txt
  if !instr(tempnum,num)
  FileAppend, %num%`n, gamenumbers.txt
  tempnum=
  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 || instr(title,"Sit & Go")>0 || instr(title,"Sit&Go")>0 || instr(title,"table")>0 || instr(title,"Satellite")>0) 
{
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(a_now, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
 if instr(file,"Cap")
 {
  stringmid,cap,file,instr(file,"-","",instr(file,"/")),instr(file,"-","",instr(file,"Cap","",0))-instr(file,"-","",instr(file,"/"))+2
  stringreplace,file,file,%cap%,
 }
 StringReplace, file, file, USD -,- USD,
 StringReplace, file, file, EUR -,- EUR,
}
}
else
{
if site=Stars
{
 stringtrimleft,file,title,instr(title,A_space,"",instr(title,"Tournament"))
 stringleft,file,file,instr(file,"Table","",0)-2
}
else
{
 stringleft,file,title,InStr(title, "-","",instr(title,"Table"))-2
 stringleft,file1,title,InStr(title, ")","",0)
}
}
loop %dir%\*.*
{
if (instr(A_LoopFileName,file)>0) && !(instr(A_LoopFileName,"Summary")>0)
return dir "\" A_LoopFileName
}
if instr(title,"Table")
{
if file1
{
 loop %dir%\*.txt
 {
  if instr(A_LoopFileName,file1)>0 & !instr(A_LoopFileName,"Summary")>0
  return dir "\" A_LoopFileName
 }
}
return 0
}
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
{
 if instr(file,"Cap")
 {
  stringmid,cap,file,instr(file,"-","",instr(file,"/")),instr(file,"-","",instr(file,"Cap","",0))-instr(file,"-","",instr(file,"/"))+2
  stringreplace,file,file,%cap%,
 }
 StringReplace, file, file, USD -,- USD,
 StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
EnvAdd, date, +2, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
 if instr(file,"Cap")
 {
  stringmid,cap,file,instr(file,"-","",instr(file,"/")),instr(file,"-","",instr(file,"Cap","",0))-instr(file,"-","",instr(file,"/"))+2
  stringreplace,file,file,%cap%,
 }
 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) {
wingettitle,title,ahk_id%win%
stringtrimleft,hero,title,instr(title,A_space,"",0)
if site=Stars
game=PokerStars Hand #
else
game=Full Tilt Poker Game #
file@name:=HHFile(win, dir ,site)
fileread,tempstr,%file@name%
tempstr=
sleep,50
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
SelectedFolder := RegExReplace(SelectedFolder, "\\$")  ; Removes the trailing backslash, if present.	
SelectedFolder := RegExReplace(SelectedFolder, "\$")
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
SelectedFolder := RegExReplace(SelectedFolder, "\\$")  ; Removes the trailing backslash, if present.	
SelectedFolder := RegExReplace(SelectedFolder, "\$")
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
SelectedFolder := RegExReplace(SelectedFolder, "\\$")  ; Removes the trailing backslash, if present.	
SelectedFolder := RegExReplace(SelectedFolder, "\$")
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
;-----------------------------------------------------------------------------------------------------
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
;-----------------------------------------------------------------------------------------------------
SuspendHotkey:
suspend,toggle
return
;-----------------------------------------------------------------------------------------------------
buildgui:
   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, w40 h30, OK  ; The label ButtonOK (if it exists) will be run when the button is pressed.
;Gui,+lastfound
;winget,id,id,
;if !DllCall( "IsWindowVisible", "UInt",id)
;Gui, Show,, Markhand 
return

showgui:
Gui, Show,, Markhand 
return

ButtonOK:
GuiClose:
GuiEscape:
Gui, Submit,nohide
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
if HK_mark
HotKey, %HK_mark%, l_markhand
if HK_sql
HotKey, %HK_sql%, l_processsql
Gui,Cancel
return
;---------------------------------------------------------------------------------------------------
deletetext:
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
    FileDelete, gamenumbers.txt
return
;---------------------------------------------------------------------------------------------------
Script: Mark Current Hand Quote
04-04-2012 , 04:57 PM
works for hem2 too ?
Script: Mark Current Hand Quote
04-04-2012 , 06:03 PM
clickys, no.
Script: Mark Current Hand Quote
04-23-2012 , 12:49 PM
Tried using it for the first time since September yesterday and it's not exporting anything to the gamenumbers text file. It creates the file if it's not already there but there's nothing inside it. However a 'temp' text file is created with lines reading...

'Update pokerhands Set mark_id = 1 Where gamenumber = AND handtimestamp > localtimestamp - interval '1 days';'

...for each hand I try to mark.

Any ideas?

Also, I might be being a complete idiot here but I can't seem to edit the script. From what I remember, I just right click the 'markhand' file and click 'edit script', but there is no 'edit script'. I think I might be missing out something obvious here.
Script: Mark Current Hand Quote
04-24-2012 , 04:43 AM
Cancel that, I just read through the thread and found the solution.
Script: Mark Current Hand Quote
05-25-2012 , 04:53 PM
I"m trying to run this script after awhile... but I always get message "gamenumbers.txt doesnt exist or file is empty"

I am playing on stars and I used script Max1mums posted few posts above (placed it in PostgreSQL\8.4\bin folder). System is Win7.
My PostgreSQL is running fine and my config is:
Code:
postgrespath=C:\Program Files (x86)\PostgreSQL\8.4\bin
StarsHHPath=C:\Users\XXX\AppData\Local\PokerStars\HandHistory
postgresdb=holdemmanager
postgresuser=postgres
FullTiltHHPath=
HK_sql=^F1
HK_mark=F1
I assume that gamenumbers.txt should be created after 1st hand is marked, but it failed to create.

Anyone knows what can be problem?
Script: Mark Current Hand Quote
05-25-2012 , 05:13 PM
Quote:
Originally Posted by Sokol
I"m trying to run this script after awhile... but I always get message "gamenumbers.txt doesnt exist or file is empty"

I am playing on stars and I used script Max1mums posted few posts above (placed it in PostgreSQL\8.4\bin folder). System is Win7.
My PostgreSQL is running fine and my config is:
Code:
postgrespath=C:\Program Files (x86)\PostgreSQL\8.4\bin
StarsHHPath=C:\Users\XXX\AppData\Local\PokerStars\HandHistory
postgresdb=holdemmanager
postgresuser=postgres
FullTiltHHPath=
HK_sql=^F1
HK_mark=F1
I assume that gamenumbers.txt should be created after 1st hand is marked, but it failed to create.

Anyone knows what can be problem?
You have to run it as administrator
Script: Mark Current Hand Quote
05-25-2012 , 05:39 PM
Hi, I don't have "Run as admin.." @right click on AKH scripts.
I tried to edit permissions and get full control, but w/no success.

I would really like to use this scrip again, so if anyone can help I will be much appreciate.
Script: Mark Current Hand Quote
05-25-2012 , 05:46 PM
Quote:
Originally Posted by Sokol
Hi, I don't have "Run as admin.." @right click on AKH scripts.
I tried to edit permissions and get full control, but w/no success.

I would really like to use this scrip again, so if anyone can help I will be much appreciate.
If you're running the file with the extension .ahk it won't show the admin dialogue. First you have to convert the .ahk to .exe.

Just hit the Windows button and search for "ahk" it should appear a program called "convert ahk to exe" use it to convert and try again.

(sorry if it's written in a strange english xD )
Script: Mark Current Hand Quote
05-26-2012 , 03:33 AM
Thank you very much!!

It works now.
Script: Mark Current Hand Quote
06-12-2012 , 12:27 PM
You can select if you want to use the script for HM1 or HM2 in this version
Code:
#noenv 
#SingleInstance, Force
SetWinDelay,-1
settitlematchmode,2

Menu, Tray, NoStandard
;Menu, Tray, Icon, Markhands.ico,1,1
Menu, Tray, Add, Reload, Reload
Menu, Tray, Add, Change Settings,  showgui
Menu, Tray, Default, Change Settings
Menu, Tray, Add, Suspend Hotkeys, SuspendHotkey
Menu, Tray, Add
Menu, Tray, Add, Submit to Database, l_processsql
Menu, Tray, Add, Exit, Exit
Gui, Submit

StringTrimRight, thisahk, A_ScriptName, 4
SetWorkingDir %A_ScriptDir%

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, Hotkeys, HK_mark, %A_Space%
IniRead, HK_sql , %thisahk%.ini, Hotkeys, HK_sql , %A_Space%
IniRead, HM1, %thisahk%.ini, Settings, HM1, 0
IniRead, HM2, %thisahk%.ini, Settings, HM2, 0

gosub,buildgui
If (!HK_mark || !HK_sql)
{
  ; gosub GetMHSettings
 Gui, Show,, Markhand 
}

if HK_mark
HotKey, %HK_mark%, l_markhand
if HK_sql
HotKey, %HK_sql%, l_processsql

IfExist, gamenumbers.txt
  gosub deletetext


settimer,checksize,55
return


^2::
Suspend
Return

l_markhand:
winget,id,id,A
wingetclass,class,ahk_id%id%
class=PokerStarsTableFrameClass
if class=PokerStarsTableFrameClass
{
site=Stars
dir:=StarsHHLogFolderPath
}
else
if class=QWidget
{
site=FullTilt
dir:=FullTiltHHLogFolderPath
}
else
site=
if site
{
 filename:=HHFile(id, dir ,site) 
 fileread,tempstr,%filename%
 tempstr=
 sleep,50
 FileGetSize, FileSize, % filename
 if !FileSize
 FileSize:=0
 if !instr(filelist,id) 
 listadd(filelist, id . "-" . FileSize)
}
return

l_processsql:
IfExist, temp.txt
FileDelete, temp.txt
IfExist, temp.bat
FileDelete, temp.bat
loop gamenumbers.*
FileRead, numbers, %A_LoopFileName%
if numbers
{
if HM1
{
sql1=Update pokerhands
sql2=Set mark_id = 1
sql3=Where gamenumber = 
sql4=AND handtimestamp > localtimestamp - interval '1 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, "%PostgresLogPath%\psql.exe"%A_space%"%postgresdb%"%A_space%"%postgresuser%"%A_space%0<"%A_ScriptDir%\temp.txt"`r`npause`n, temp.bat
}
else
if HM2
{
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
}
}
run temp.bat
}
else
msgbox, gamenumbers.txt file doesn't exist or file is empty.
numbers=
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) 
 fileread,tempstr,%filename%
 tempstr=
 sleep,50
 FileGetSize, FileSize, % filename
 if FileSize
 if FileSize!=%tab2%
 {
  num:=gethhnumber(tab1,site)
  fileread,tempnum,gamenumbers.txt
  if !instr(tempnum,num)
  FileAppend, %num%`n, gamenumbers.txt
  tempnum=
  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 || instr(title,"Sit & Go")>0 || instr(title,"Sit&Go")>0 || instr(title,"table")>0 || instr(title,"Satellite")>0) 
{
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(a_now, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
 if instr(file,"Cap")
 {
  stringmid,cap,file,instr(file,"-","",instr(file,"/")),instr(file,"-","",instr(file,"Cap","",0))-instr(file,"-","",instr(file,"/"))+2
  stringreplace,file,file,%cap%,
 }
 StringReplace, file, file, USD -,- USD,
 StringReplace, file, file, EUR -,- EUR,
}
}
else
{
if site=Stars
{
 stringtrimleft,file,title,instr(title,A_space,"",instr(title,"Tournament"))
 stringleft,file,file,instr(file,"Table","",0)-2
}
else
{
 stringleft,file,title,InStr(title, "-","",instr(title,"Table"))-2
 stringleft,file1,title,InStr(title, ")","",0)
}
}
loop %dir%\*.*
{
if (instr(A_LoopFileName,file)>0) && !(instr(A_LoopFileName,"Summary")>0)
return dir "\" A_LoopFileName
}
if instr(title,"Table")
{
if file1
{
 loop %dir%\*.txt
 {
  if instr(A_LoopFileName,file1)>0 & !instr(A_LoopFileName,"Summary")>0
  return dir "\" A_LoopFileName
 }
}
return 0
}
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
{
 if instr(file,"Cap")
 {
  stringmid,cap,file,instr(file,"-","",instr(file,"/")),instr(file,"-","",instr(file,"Cap","",0))-instr(file,"-","",instr(file,"/"))+2
  stringreplace,file,file,%cap%,
 }
 StringReplace, file, file, USD -,- USD,
 StringReplace, file, file, EUR -,- EUR,
}
loop %dir%\*.txt
{
if instr(A_LoopFileName,file)
return dir "\" A_LoopFileName
}
EnvAdd, date, +2, d
stringleft,file,title, InStr(title, "-","",0)-2
file := ext . SubStr(date, 1, 8) . A_space . file
StringReplace, file, file, /,-,
if site=Stars
{
 if instr(file,"Cap")
 {
  stringmid,cap,file,instr(file,"-","",instr(file,"/")),instr(file,"-","",instr(file,"Cap","",0))-instr(file,"-","",instr(file,"/"))+2
  stringreplace,file,file,%cap%,
 }
 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) {
wingettitle,title,ahk_id%win%
stringtrimleft,hero,title,instr(title,A_space,"",0)
if site=Stars
game=PokerStars Hand #
else
game=Full Tilt Poker Game #
file@name:=HHFile(win, dir ,site)
fileread,tempstr,%file@name%
tempstr=
sleep,50
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
SelectedFolder := RegExReplace(SelectedFolder, "\\$")  ; Removes the trailing backslash, if present.	
SelectedFolder := RegExReplace(SelectedFolder, "\$")
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
SelectedFolder := RegExReplace(SelectedFolder, "\\$")  ; Removes the trailing backslash, if present.	
SelectedFolder := RegExReplace(SelectedFolder, "\$")
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
SelectedFolder := RegExReplace(SelectedFolder, "\\$")  ; Removes the trailing backslash, if present.	
SelectedFolder := RegExReplace(SelectedFolder, "\$")
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
;-----------------------------------------------------------------------------------------------------
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
;-----------------------------------------------------------------------------------------------------
SuspendHotkey:
suspend,toggle
return
;-----------------------------------------------------------------------------------------------------
buildgui:
   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, Radio, x60 y90 w50 h20 Checked%HM1% vHM1, HM1
   Gui, Add, Radio, x115 y90 w50 h20 Checked%HM2% vHM2, HM2

   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, w40 h30, OK  ; The label ButtonOK (if it exists) will be run when the button is pressed.
return

showgui:
Gui, Show,, Markhand 
return

ButtonOK:
GuiClose:
GuiEscape:
Gui, Submit,nohide
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, Hotkeys, HK_sql
IniWrite, %HK_mark%, %thisahk%.ini, Hotkeys, HK_mark
if HK_mark
HotKey, %HK_mark%, l_markhand
if HK_sql
HotKey, %HK_sql%, l_processsql
if HM1
IniWrite, %HM1%, %thisahk%.ini, Settings, HM1
if HM2
IniWrite, %HM2%, %thisahk%.ini, Settings, HM2
Gui,Cancel
return
;---------------------------------------------------------------------------------------------------
deletetext:
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
    FileDelete, gamenumbers.txt
return
;---------------------------------------------------------------------------------------------------
Script: Mark Current Hand Quote
06-18-2012 , 05:07 PM
Any chance of having a full package re-released somewhere with all the new code? I think the download-link for the original .zip in the first post has gone cold. I'm having trouble getting the script to work and I think I might be missing something from the original package.
Script: Mark Current Hand Quote

      
m