Script: Mark Current Hand
This scripts allows you to mark hands that are currently in play
How it works:
On pressing hotkey#1 this script grabs the windowtitles of the active table, waits for the current hand to be written to the HH-file and extracts the handnumber. All collected handnumbers are continuously written to a txt-file. With hotkey#2 , which you should press when you are done collecting hands (i.e. playing) the handnumbers are compiled to a little sql-script, which will be executed in you postgres-folder- Afterwards HEM will show those hand as marked.
Settings:
On the very first start of the program you will be asked for some settings, like folders and hotkeys you want to use
Currently the program will not allow you to use Hotkeys with windows-key or mouse-buttons
Download-Link:
http://rapidshare.com/files/410100979/markhand.zip.html
comes with standard-ini-file you also can just copy/paste the code
Code:
big thx to Max1mums
How it works:
On pressing hotkey#1 this script grabs the windowtitles of the active table, waits for the current hand to be written to the HH-file and extracts the handnumber. All collected handnumbers are continuously written to a txt-file. With hotkey#2 , which you should press when you are done collecting hands (i.e. playing) the handnumbers are compiled to a little sql-script, which will be executed in you postgres-folder- Afterwards HEM will show those hand as marked.
Settings:
On the very first start of the program you will be asked for some settings, like folders and hotkeys you want to use
Currently the program will not allow you to use Hotkeys with windows-key or mouse-buttons
Download-Link:
http://rapidshare.com/files/410100979/markhand.zip.html
comes with standard-ini-file you also can just copy/paste the code
Code:
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=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, 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(): { gosub SuspendHotkey 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 gosub reload 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 ;-----------------------------------------------------------------------------------------------------
I thought this thread was in an archive where replies don't get displayed. How has nobody commented on this?!?
The concept is amazing!
I had to move the script into the posgre bin directory thought because the CD command in the bat didn't seem to work.
It seems that either I'm interrupting it or it's not working too well right now.
I've had a look at the source code but I'm more of a Autoit fan and with no commenting at all it's pretty difficult to read.
Is it working reliably for you? I'd absolutely love it if you could get this to work.
Thanks for the effort!
The concept is amazing!
I had to move the script into the posgre bin directory thought because the CD command in the bat didn't seem to work.
It seems that either I'm interrupting it or it's not working too well right now.
I've had a look at the source code but I'm more of a Autoit fan and with no commenting at all it's pretty difficult to read.
Is it working reliably for you? I'd absolutely love it if you could get this to work.
Thanks for the effort!
Whoa, I completely missed this thread so I assume many others did as well. That would be the only reason this thread hasn't got lots of love.
TTR was so kind as the let me try this out a few weeks back and it is working exactly as described.
The only issue I come up with has nothing to do with anything wrong with this script itself (it's my setup). I play on two different computers in two different locations and they both share the same HEM DB. When I'm on the desktop that has the HEM DB on it, it works PERFECT. When I'm on my laptop that connects remotely to the desktop and my HEM DB, it works to store the hands, but I have wait until I get back to my desktop to actually mark the hands in HEM.
So for most players that play on computers that also have their HEM DB on it, this should work awesome.
A BIG thumbs up from me to TTR and Max1mums for writing this!!!
TTR was so kind as the let me try this out a few weeks back and it is working exactly as described.
The only issue I come up with has nothing to do with anything wrong with this script itself (it's my setup). I play on two different computers in two different locations and they both share the same HEM DB. When I'm on the desktop that has the HEM DB on it, it works PERFECT. When I'm on my laptop that connects remotely to the desktop and my HEM DB, it works to store the hands, but I have wait until I get back to my desktop to actually mark the hands in HEM.
So for most players that play on computers that also have their HEM DB on it, this should work awesome.
A BIG thumbs up from me to TTR and Max1mums for writing this!!!
What games are you playing? Maybe the title format is differen for super turbo sngs. I am super keen on getting this to work. Any other suggenstions?
I just tried playing a ring game to see if that works and it doesn't. My database isn't in the default folder. Might that be a problem?
I've got Windows 7 and the lates HM with 8.4 postgre. AHK is being run as admin with latest version.
I'm not sure at which point the scripts writes the hand numbers into the text file but it doesn't happen instantly and just then I played a whole SNG and at the end of it the same number had been save over and over rather than different hands...
Cheers
I just tried playing a ring game to see if that works and it doesn't. My database isn't in the default folder. Might that be a problem?
I've got Windows 7 and the lates HM with 8.4 postgre. AHK is being run as admin with latest version.
I'm not sure at which point the scripts writes the hand numbers into the text file but it doesn't happen instantly and just then I played a whole SNG and at the end of it the same number had been save over and over rather than different hands...
Cheers
I hate double posting but well, I can't edit. This is what I've done to make it work:
1. I've copied the script into the bin folder, because the CD command in the batch file doesn't get executed.
2. I've changed the line in the source code that identifies SNGs windows to match those of SuperTurbos as well as other SNGs.
Thanks again for this awesome tool!
1. I've copied the script into the bin folder, because the CD command in the batch file doesn't get executed.
2. I've changed the line in the source code that identifies SNGs windows to match those of SuperTurbos as well as other SNGs.
Thanks again for this awesome tool!
Thank you very much! It seem a very useful script. I will try in my next session. But I see a problem: you can't configure the postgres database pass.
There is a prompt for the password that you have to enter manually.
You can change method to "trust" for localhost in pg_hba.conf file so entering password won't be needed, eg
Code:
# TYPE DATABASE USER CIDR-ADDRESS METHOD # IPv4 local connections: host all all 127.0.0.1/32 trust
Thanks for that, good knowledge! Come one people, this is an epic tool, a little more enthusiasm please
2. I've changed the line in the source code that identifies SNGs windows to match those of SuperTurbos as well as other SNGs.
I had to move the script into the posgre bin directory thought because the CD command in the bat didn't seem to work.
btw: what i forget to mention: you have to process the sql script within the next 2 days after collecting the #. Put this in for not causing any troubles in DBs, where FT and PS Hands have the same. Tough I wasn't sure if this is possible.
Pitch the idea to tableninja or something like that, and get some moneyz for your work imo...
^^ I agree. Imagine if HoldemManager offered TTR (and Max1mums) some moniez for this awesome script. It would be great to have it integrated and work directly with HEM.
Oh', and I use it for SuperTurbos with no issues at all.
I'm amazed this thread is not getting WAY more love.
Incredible script!!!
Oh', and I use it for SuperTurbos with no issues at all.
I'm amazed this thread is not getting WAY more love.
Incredible script!!!
just in case anyone wants to donate $$ for the script -> Max1mums
HEM have had numerous requests to improve the accessibility of the mark hand for review feature. It obviously should be easy for them to implement especially when people offer open source solutions for free like in this case.
In SuperTurbos SNGs the title is different to other SNGs. I removed the space from the words to look for in the title:
"Sit&Go" rather than "Sit & Go" seemed to do the trick for me.
In SuperTurbos SNGs the title is different to other SNGs. I removed the space from the words to look for in the title:
"Sit&Go" rather than "Sit & Go" seemed to do the trick for me.
btw i linked to this thread in my own request threads in HEM and TN forums ;-)
I doubt there is much money to be made from this particular script, I agree (especially since you published the source code, which I think is the way forward anyways).
Cant get this to work, when i press the hotkey to send hands to HM a black screen pops up:
---------------------------------------------------------------------
C:\Users\Jamie\Desktop>cd C:\Program Files\PostgreSQL\8.3\bin
C:\Program Files\PostgreSQL\8.3\bin>psql.exe HM postgres 0<temp.txt
The system cannot find the file specified.
C:\Program Files\PostgreSQL\8.3\bin>pause
Press any key to continue . . .
----------------------------------------------------------------------
Any idea's what i need to do to get it working?
Cheers
---------------------------------------------------------------------
C:\Users\Jamie\Desktop>cd C:\Program Files\PostgreSQL\8.3\bin
C:\Program Files\PostgreSQL\8.3\bin>psql.exe HM postgres 0<temp.txt
The system cannot find the file specified.
C:\Program Files\PostgreSQL\8.3\bin>pause
Press any key to continue . . .
----------------------------------------------------------------------
Any idea's what i need to do to get it working?
Cheers
Try putting all the files intor the "C:\Program Files\PostgreSQL\8.3\bin" folder. I've had the same problem.
Just tryed that but im still getting the same black window as quoted above.
I've added support for superturbos and a possible fix for "file was not found" problem, try running script as admin if this problem persists.
Code:
#noenv #SingleInstance, Force SetWinDelay,-1 settitlematchmode,2 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% If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb) { 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, Button, 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 return } 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 F1:: 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 ^F1:: 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 '1 days'; sql5=Update pokerhands_hero Loop, Parse, numbers, `n, { if A_loopField { FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4%`n, %PostgresLogPath%\temp.txt FileAppend, %sql5% %sql2% %sql3% %A_loopField% %sql4%`n, %PostgresLogPath%\temp.txt } } FileAppend, cd %PostgresLogPath%`npsql.exe %postgresdb% %postgresuser% <temp.txt`npause`n, %PostgresLogPath%\temp.bat 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 OR instr(title,"Sit&Go")>0 OR instr(title,"table")>0 OR 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 { 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 ;----------------------------------------------------------------------------------------------------- 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 ;-----------------------------------------------------------------------------------------------------
Max, that recent 1 has no options to asign the hotkeys for mark/send.
Still cant get this to work.
Still cant get this to work.
timed@44, F1 - save number of current hand, ctrl+F1 - mark all hands from gamenumbers.txt file (you can change them manually, "F1::" and "^F1::" lines)
What goes wrong exactly, which step?
What goes wrong exactly, which step?
I've reintegrated the Hotkey assignment and did some tweaks to the traymenu.
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, GetMHSettings() 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% If (!StarsHHLogFolderPath or !FullTiltHHLogFolderPath or !PostgresLogPath or !postgresuser or !postgresdb) { gosub GetMHSettings() } HotKey, %HK_mark%, l_markhand HotKey, %HK_sql%, l_processsql IfExist, gamenumbers.txt gosub deletetext 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, %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 '1 days'; sql5=Update pokerhands_hero Loop, Parse, numbers, `n, { if A_loopField { FileAppend, %sql1% %sql2% %sql3% %A_loopField% %sql4%`n, %PostgresLogPath%\temp.txt FileAppend, %sql5% %sql2% %sql3% %A_loopField% %sql4%`n, %PostgresLogPath%\temp.txt } } FileAppend, cd %PostgresLogPath%`npsql.exe "%postgresdb%" "%postgresuser%" <temp.txt`npause`n, %PostgresLogPath%\temp.bat run %PostgresLogPath%\temp.bat gosub deletetext 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 TrayTip, Hand Marked, %Site% Hand #%num%, 2, 17 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 OR instr(title,"Sit&Go")>0 OR instr(title,"table")>0 OR 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 { 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 ;----------------------------------------------------------------------------------------------------- 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: SendInPut, {CTRLDOWN}2{CTRLUP} 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, 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 return } ;--------------------------------------------------------------------------------------------------- deletetext: MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No) IfMsgBox Yes FileDelete, gamenumbers.txt return
----------------------------------------------------------------------------------
C:\Users\Jamie\Desktop>cd C:\Program Files\PostgreSQL\8.4\bin
C:\Program Files\PostgreSQL\8.4\bin>psql.exe HOLDEM MANAGER postgres 0<temp.txt
The system cannot find the file specified.
C:\Program Files\PostgreSQL\8.4\bin>pause
Press any key to continue . . .
----------------------------------------------------------------------------------
I dont think the f1 key is saving the hands for me. I've checked that the paths are correct so i dont know what i'm doing wrong.
I don't know what's the problem here, teamviewer session with someone having this problem would be helpful.
Feedback is used for internal purposes. LEARN MORE