PokerGaming.cz > Poker obecně > markhand.ahk

markhand.ahk

  9dTd9dTd  obraz 9.5.2011 20:19, Příspěvků: 410   Poslat PM Poslat PM   Handy uživatele Hands 

Konecne se mi podarilo rozchodit script na markovani hand pomoci klavesove zkratky, tak bych se s vami o tuto funkci chtel podelit, protoze si myslim, ze by ji spousta z vas mohla vyuzit a imho docela usnadni praci.. Funguje pouze na hernach PokerStars a FullTilt v kombinaci s programem Holdem Manager.


Zde je jednoduchy navod:

1. Instalace programu AutoHotkey -> http://www.autohotkey.com/download/ (Installer for AutoHotkey Basic)

2. Zdrojovy kod ze spoileru zkopirovat do notepadu a ulozit pod nazvem "markhand.ahk" (ne markhand.ahk.txt!!!)

#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

;-----------------------------------------------------------------------------------------------------

Soubor markhand.ahk lze taky stahnout odsud:

3. Umistit tento soubor do korenoveho adresare disku (jeho adresa bude tedy C:\markhand.ahk - doporuceno, ja mam soubor umisteny jeste v podslozce C:\markhand\markhand.ahk a funguje taky bez problemu)

4. Spustit tento soubor dvojklikem

5. Vyplnit nastaveni dle obrazku ve spoileru (prvni radek zustane stejny, v druhem a tretim nastavit adresu na disku, kam si klient herny uklada hand history - NE konecne umisteni HH po autoimportu do HEMu. Ostatni snad bez komentare).

6. Potvrdit OK -> script se spusti do traye a je pripraven markovat

7. Pri stisknuti prednastavene klavesy (u me je to klavesa "M") se v adresari scriptu automaticky vytvori textovy soubor "gamenumbers.txt" do ktereho se znaci cisla markovanych hand). Po skonceni session stisknete druhou prednastavenou klavesovou zkratku (u me klavesa "Q") a vyskoci DOSovske okno, kde je jen potreba vyplnit heslo postgres databaze (std byva "postgrespass") a oznacene handy se prenesou do SQL databaze. V HM uz pak lze lehce vyfiltrovat "Only Show Marked Hands")

8. V pripade spokojenosti zaslat autorovi nejaky drobak na podporu dobre veci :)


Jeste bych dodal, ze aby program fungoval, je nutne mit behem session spusteny autoimport v HEMu, avsak neni nutne mit zapnuty HUD (coz se mi na nem prave libi).

Nezastiram, ze vse co jsem tady popsal jsem odkoukal z 2+2, ale i tak mi trvalo docela dlouho nez jsem narazil na opravdu funkcni postup (ackoliv je opravdu jednoduchy), proto jsem si rikal, ze by tohle mohlo usetrit cas lamam jako jsem ja :)
Btw doufam ze nevadi, ze jsem kvuli tomu zalozil samostatne vlakno, ale myslim, ze v threadu HM by se to v tom mnozstvi prispevku brzo ztratilo.

http://forumserver.twoplustwo.com/45/software/script-mark-current-hand-845894/

twitter.com/obr4z Upraveno 7.2.2012 1:08 by obraz
#1   7d7h7d7h  danielito 9.5.2011 21:56, Příspěvků: 821   Poslat PM Poslat PM   Handy uživatele Hands 

diky moc spravil som všetko ale netestoval som ešte ale hodi sa to určite

Odsudzujú čo nechápu.
#2   AdminAdmin  Dante 9.5.2011 22:14, Příspěvků: 3694   Poslat PM Poslat PM   Handy uživatele Hands 

GJ, pridano do Rozcestniku. {#emotions_dlg.hi}

Life of lively to live to life of full life thx to shield battery
#3   9dTd9dTd  Kostej 11.5.2011 13:50, Příspěvků: 329   Poslat PM Poslat PM   Handy uživatele Hands 

udelalse vsechno podle toho ale stejne to nefunguje proste pri stisknuti klavesy to nic neudela:(

#4   JhJdJhJd  AsDoMg 11.5.2011 18:46, Příspěvků: 2565   Poslat PM Poslat PM   Handy uživatele Hands 

ono to nic nedela po stisku klavesy ;)

Don't stop me now, I'm having such a good time.
#5   TdThTdTh  JackHarkness 11.5.2011 23:22, Příspěvků: 2003   Poslat PM Poslat PM   Handy uživatele Hands 

presne, kdyz pak zmacknu tu databazi tak me to napise ze ten soubor v kterym sou ty handy neexistuje

I'm not crazy, my mother had me tested.
#6   ModerátorModerátor  xparez 12.5.2011 0:30, Příspěvků: 2361   Poslat PM Poslat PM   Handy uživatele Hands 

funguje to teda nikomu? dost by se mi neco podobnyho hodilo, takze se kdyztak ozvete .. :)

#7   AhKdAhKd  LastHero 12.5.2011 1:29, Příspěvků: 3793   Poslat PM Poslat PM   Handy uživatele Hands 

6 - zkus si dát něco s liškou, zkouknout dokument o 11. září, a pak to půjde.... xD

nice blog, gl
#8   9dTd9dTd  obraz 12.5.2011 4:39, Příspěvků: 410   Poslat PM Poslat PM   Handy uživatele Hands 

Na jake herne vam to nefunguje? Ja pouzivam na PS, na FT nehraju, takze nemam odzkouseno.. Pak me jeste napada - jakou pouzivate verzi SQL? Pokud jinou nez 8.4, bude se adresa slozky bin v prvnim radku samozrejme lisit, stejne tak se budou lisit i ty ostatni adresy dle verze windows (viz link na 2+2), tohle je standartni umisteni pro xp. Proste je potreba mit spravne vyplnene to gui rozhrani.. Vytvori se vam po stisknuti markovaci zkratky soubor "gamenumbers.txt" ve slozce s markhand.ahk?

twitter.com/obr4z
#9   7d7h7d7h  jaxyz00 17.11.2011 11:28, Příspěvků: 836   Poslat PM Poslat PM   Handy uživatele Hands 

jede to teda nekomu? mi se to nepodarilo zprovoznit

One time please!!!!!!!
#10   9dTd9dTd  obraz 17.11.2011 18:47, Příspěvků: 410   Poslat PM Poslat PM   Handy uživatele Hands 

Me to funguje a pouzivam to porad ;) Napis mi pm, zkusim ti s tim pomoct..

e: sorry, ted vidim ze uz jsi mi pm psal.. vzdycky to nejak prehlednu, chtelo by to nejak zvyraznit new message..

twitter.com/obr4z Upraveno 17.11.2011 18:49 by obraz
#11   7d7h7d7h  jaxyz00 18.11.2011 19:30, Příspěvků: 836   Poslat PM Poslat PM   Handy uživatele Hands 

tak se mi to podarilo rozjet na XP i WIN7  a uplna spokojenost

One time please!!!!!!!
#12   9dTd9dTd  obraz 25.1.2012 5:16, Příspěvků: 410   Poslat PM Poslat PM   Handy uživatele Hands 

Nedavno jsem instaloval markhand.ahk na novem pc (win 7) a ten zdrojovy kod ve spoileru funguje nejak spatne, ale sehnal jsem uz novejsi verzi, tak to behem zitrka opravim..

e: zdrojovy kod ve spoileru opraveny + pod spoiler s kodem jsem pridal i hotovou verzi ke stazeni - teoreticky by melo melo stacit tento soubor stahnout - rozbalit - spustit & nastavit a melo by vse fungovat, tuto verzi sam pouzivam a podarilo se mi rozbehnout ji hned napoprve, tak kdo jste s tim meli problem, snad vam tohle bude fungovat..

e2: az budu mit chvilku tak jestli bude zajem, doplnim jeste drobnou upravu jednoho souboru, diky ktere neni potreba zadavat pri kazdem preneseni marknutych hand do databaze heslo (postgrespass)

twitter.com/obr4z Upraveno 27.1.2012 20:23 by obraz
#13   7d7h7d7h  jaxyz00 6.2.2012 16:45, Příspěvků: 836   Poslat PM Poslat PM   Handy uživatele Hands 

nejak mi to blbne.  jede to ale kdyz se maji ukladat cisla hand do toho gamesnumber tak jakoby se ukladali, ale nejsou tam ty cisla tech hand.

nevi nekdo v cem by mohl byt problem? zaclo to blbnout cca pred tydnem +-

zkusil jsem to udelat i znovu s tim novym souborem, ale stejne to nejde. 

Nejaky napad? diky

One time please!!!!!!!
#14   9dTd9dTd  obraz 7.2.2012 0:58, Příspěvků: 410   Poslat PM Poslat PM   Handy uživatele Hands 

#13  dela mi to same.. napada me jedine jestli to neni tim poslednim updatem ps, myslim ze se prave nejak menila podoba handhistory a to by na to mohlo mit vliv.. na 2+2 jsem nasel nejake updaty, tak to vyzkousim a dam vedet.. je to kdyztak z toho odkazu na konci #0 pod navodem.

twitter.com/obr4z Upraveno 7.2.2012 1:10 by obraz
#15   9dTd9dTd  obraz 7.2.2012 1:10, Příspěvků: 410   Poslat PM Poslat PM   Handy uživatele Hands 

Tak ta posledni verze kodu funguje, opraveno ve spoileru i v hotove verzi pro stazeni.

twitter.com/obr4z
#16   7d7h7d7h  jaxyz00 7.2.2012 1:38, Příspěvků: 836   Poslat PM Poslat PM   Handy uživatele Hands 

jede to jak ma. Diky moc

One time please!!!!!!!
K přidání komentáře musíte být přihlášeni! (nebo nemáte dostatečná oprávnění)