Open Side Menu Go to the Top

02-11-2014 , 09:26 PM
No, it doesn't matter how many tables you play, they just have to be all the same size, and the button has to be in the same place on every table - hence, table relative (ie. "in active window") coords:



- activate you PokerStars table and hover over the button
- the "in active window" coords are your IconX, IconY coords

As soon as you click the button, I assume the dropdown menu should become the active window; its ahk_class is your DropdownClass.

I suck at explaining but HTH. IF you run into troubles, just PM me please to avoid further cluttering of this thread.

Last edited by Baobhan-Sith; 02-11-2014 at 09:36 PM.
Script: Mark Current Hand Quote
Script: Mark Current Hand
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
Script: Mark Current Hand
02-11-2014 , 10:48 PM
Think i finally got it but got this error



This is what i have atm


Last edited by onlinepokerwiz; 02-11-2014 at 11:09 PM.
Script: Mark Current Hand Quote
02-12-2014 , 01:30 AM
Error is because of the typo -> MouseClick

Also I doubt your offset values are correct as they seem way too high.

Quote:
http://www.autohotkey.com/docs/commands/MouseMove.htm

"... the X and Y coordinates will be treated as offsets from the current mouse position. In other words, the cursor will be moved from its current position by X pixels to the right (left if negative) and Y pixels down (up if negative)."
Ie. starting from the button coords you go TagMenuX pixels to the right and TagMenuY pixels down to the "tag hand in progress" menu item, perform a click, then from there go TagItemX pixels to the right and TagItemY pixels down to the actual tag label. WindowSpy doesn't show them directly, you have to figure them out by yourself (eg. calculate them using the on screen coords as a reference).

edit: you can increase the MenuDelay to like 2000 (=2sec) for testing purposes so you can see where the mouse actually moves (or jumps, to be precise)

edit: In case you just have to hover over the "tag hand in progress" menu item to expand the labels menu, use this, and adjust the MenuDelay accordingly:
Code:
IfWinActive, ahk_class %TableClass%
	{
	id := WinExist("A")
	MouseGetPos, x, y
	MouseClick, left, %IconX%, %IconY%
	MouseMove, %TagMenuX%, %TagMenuY%,, R
	Sleep %MenuDelay%
   	IfWinActive, ahk_class %DropdownClass%
	    {
	    MouseMove, %TagItemX%, %TagItemY%,, R
	    MouseClick, left
	    WinActivate, ahk_id%id%
	    MouseMove, %x%, %y%
	    }
	}

Last edited by Baobhan-Sith; 02-12-2014 at 01:57 AM.
Script: Mark Current Hand Quote
02-12-2014 , 08:11 AM
Quote:
Originally Posted by Baobhan-Sith
Error is because of the typo -> MouseClick
Got it

Quote:
Also I doubt your offset values are correct as they seem way too high
Thats what WindowSpy showed me

Quote:
WindowSpy doesn't show them directly, you have to figure them out by yourself (eg. calculate them using the on screen coords as a reference).
This is a bit dissapointing

Quote:
edit: you can increase the MenuDelay to like 2000 (=2sec) for testing purposes so you can see where the mouse actually moves (or jumps, to be precise)
will try this

Quote:
edit: In case you just have to hover over the "tag hand in progress" menu item to expand the labels menu, use this, and adjust the MenuDelay accordingly:
Code:
IfWinActive, ahk_class %TableClass%
	{
	id := WinExist("A")
	MouseGetPos, x, y
	MouseClick, left, %IconX%, %IconY%
	MouseMove, %TagMenuX%, %TagMenuY%,, R
	Sleep %MenuDelay%
   	IfWinActive, ahk_class %DropdownClass%
	    {
	    MouseMove, %TagItemX%, %TagItemY%,, R
	    MouseClick, left
	    WinActivate, ahk_id%id%
	    MouseMove, %x%, %y%
	    }
	}
Modified

Ok, will try this and let u know
Script: Mark Current Hand Quote
02-12-2014 , 11:52 PM
the script appareantly is up and running doesnt give me any message error but now im wondering, what key do i press to activate it? :P
Script: Mark Current Hand Quote
02-13-2014 , 12:14 AM
Code:
;-------- CONFIG---------

...

^Numpad0::     ;CTRL+Numpad0

;------------------------
http://www.autohotkey.com/docs/Hotkeys.htm
Script: Mark Current Hand Quote
02-13-2014 , 07:16 AM
could you post the code please? I hope I can use it too.
Script: Mark Current Hand Quote
02-13-2014 , 01:31 PM
K, I just downloaded the PT4 trial and tested it myself. Unfortunately it seems to be impossible to get away with fewer or shorter delays.

Make sure to adjust coords and offsets accordingly; the Label offset I used directs to the 3rd label from the top.

Code:
#NoEnv  
SendMode Input 
CoordMode, Mouse, relative
#SingleInstance, force


;-------- CONFIG---------

TableClass = PokerStarsTableFrameClass
DropdownClass = ptTableCoverClass 

;Tag Icon COORDS (table relative):
IconX = 390
IconY = 40

;Menu Item "Tag Hand In Progress" OFFSETS (relative to above coord):
MenuX = 40
MenuY = 70

;"Review" Label OFFSETS (relative to above coord+offset):
LabelX = 300
LabelY = 40

MenuDelay = 500		;msec

^Numpad0::		;CTRL+Numpad0

;------------------------
    IfWinActive, ahk_class %TableClass%
	{
	id := WinExist("A")
	MouseGetPos, x, y
	MouseMove, %IconX%, %IconY%
	Sleep %MenuDelay%
	MouseClick, left
	Sleep %MenuDelay%
	MouseMove, %MenuX%, %MenuY%,, R
	Sleep %MenuDelay%
   	IfWinActive, ahk_class %DropdownClass%
	    {
	    MouseMove, %LabelX%, %LabelY%,, R
	    MouseClick, left
	    WinActivate, ahk_id%id%
	    MouseMove, %x%, %y%
	    }
	}
    else, Send {0}
return
This is the best I can offer, it's prolly not very reliable and could perform misclicks if interrupted so be careful, especally when masstabling. It's probably better to wait for (or pay) someone skilled enough to implement PT4 compatibility to the original script.


over and out
Script: Mark Current Hand Quote
02-17-2014 , 07:51 AM
@Baobhan-Sith thank you it works very well
Script: Mark Current Hand Quote
02-17-2014 , 09:20 AM
Sript for PT4 not will work
different coordinates





need more action for "Review" Label OFFSETS
Script: Mark Current Hand Quote
02-17-2014 , 02:05 PM
ok I invested some hours for the PT4 extension.

I replaced HM2 for PT4. HM1 is not tested, but it should work too, because I didnt changed anything.
For PT4 I´ve made a small test and it works, but there is no check for double entrys!


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, PT4, %thisahk%.ini, Settings, PT4, 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
}
}
}
else
if PT4
{

sql1=INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) 
sql2=VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='
sql3='), 'H', 't', '1', 'f');
sql4=UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='
sql5=';
Loop, Parse,numbers,`n,
{
if A_loopField
FileAppend, %sql1% %sql2%%A_loopField%%sql3% %sql4%%A_loopField%%sql5% `n, temp.txt
}
}
FileAppend, "%PostgresLogPath%\psql.exe"%A_space%"%postgresdb%"%A_space%"%postgresuser%"%A_space%<"%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, Radio, x60 y90 w50 h20 Checked%HM1% vHM1, HM1
   Gui, Add, Radio, x115 y90 w50 h20 Checked%PT4% vPT4, PT4

   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 PT4
IniWrite, %PT4%, %thisahk%.ini, Settings, PT4
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
02-17-2014 , 09:07 PM
What are the hotkeys in this?
Script: Mark Current Hand Quote
02-18-2014 , 03:54 AM
you can set it in the gui, also you must set the path to pokerstars hh and to postgresql
Script: Mark Current Hand Quote
02-18-2014 , 07:10 PM
Just an FYI for HM2 users: the built-in HM2 hotkey for marking hands has apparently been fixed.
Script: Mark Current Hand Quote
02-20-2014 , 05:01 PM
hmm I have still problems with the code for PT4.

this is how I generate the postgres command:
Code:
if PT4
{
sql1=INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) 
sql2=VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='
sql3='), 'H', 't', '1', 'f');`n
sql4=UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='
sql5=';`n
Loop, Parse,numbers,`n,
{
if A_loopField
FileAppend, %sql1% %sql2%%A_loopField%%sql3% %sql4%%A_loopField%%sql5% `n, temp.txt
But I only receive this:

Code:
INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='112135731497
'), 'H', 't', '1', 'f');
 UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='112135731497
';
I have no idea why he put the code in the next line and this is the problem.

The last hand works, also if I import only one hand.
Script: Mark Current Hand Quote
02-20-2014 , 06:38 PM
chaosad, hand number was containing a new line symbol probably, try this
Code:
if PT4
{
sql1=INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) 
sql2=VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='
sql3='), 'H', 't', '1', 'f');`n
sql4=UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='
sql5=';`n
Loop, Parse,numbers,`n,
{
if A_loopField
{
stringreplace,number,A_loopField,`n,,All
stringreplace,number,number,`r,,All
FileAppend, %sql1% %sql2% %number% %sql3% %sql4% %number% %sql5% `n, temp.txt
}
Script: Mark Current Hand Quote
02-21-2014 , 05:19 AM
wow great thank you
Script: Mark Current Hand Quote
03-14-2014 , 01:22 PM
hey, was hoping anyone can help me here. i got a new laptop with windows 8 and cant get markhand to run. friend told me i need to run the ahk to exe thing to be able to run it as admin, where do i find that on windows 8?
Script: Mark Current Hand Quote
03-14-2014 , 03:06 PM
You guys might be interested in this, which is in free beta...

EasyStreet by ProPokerHUDs: HUD switching, effortless hand marking and other tracker controls by PT4 & HEM2

http://forumserver.twoplustwo.com/45...trols-1422041/
Script: Mark Current Hand Quote
04-06-2014 , 08:40 AM
So is there a script for marking hands in pt4 yet or not, couldnt understand between all this posts was it made or has some bugs or whats up
Script: Mark Current Hand Quote
10-22-2014 , 09:48 AM
Yeah im down with Don on this, any chance u AHK gurus can modify this script so it will run for PT4?
Script: Mark Current Hand Quote
10-22-2014 , 10:02 AM
Quote:
Originally Posted by chaosad
ok I invested some hours for the PT4 extension.

I replaced HM2 for PT4. HM1 is not tested, but it should work too, because I didnt changed anything.
For PT4 I´ve made a small test and it works, but there is no check for double entrys!


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, PT4, %thisahk%.ini, Settings, PT4, 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
}
}
}
else
if PT4
{

sql1=INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) 
sql2=VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='
sql3='), 'H', 't', '1', 'f');
sql4=UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='
sql5=';
Loop, Parse,numbers,`n,
{
if A_loopField
FileAppend, %sql1% %sql2%%A_loopField%%sql3% %sql4%%A_loopField%%sql5% `n, temp.txt
}
}
FileAppend, "%PostgresLogPath%\psql.exe"%A_space%"%postgresdb%"%A_space%"%postgresuser%"%A_space%<"%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, Radio, x60 y90 w50 h20 Checked%HM1% vHM1, HM1
   Gui, Add, Radio, x115 y90 w50 h20 Checked%PT4% vPT4, PT4

   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 PT4
IniWrite, %PT4%, %thisahk%.ini, Settings, PT4
Gui,Cancel
return
;---------------------------------------------------------------------------------------------------
deletetext:
MsgBox, 4,, Delete existing file gamenumbers.txt? (press Yes or No)
IfMsgBox Yes
    FileDelete, gamenumbers.txt
return
;---------------------------------------------------------------------------------------------------
Quote:
Originally Posted by Max1mums
chaosad, hand number was containing a new line symbol probably, try this
Code:
if PT4
{
sql1=INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) 
sql2=VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='
sql3='), 'H', 't', '1', 'f');`n
sql4=UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='
sql5=';`n
Loop, Parse,numbers,`n,
{
if A_loopField
{
stringreplace,number,A_loopField,`n,,All
stringreplace,number,number,`r,,All
FileAppend, %sql1% %sql2% %number% %sql3% %sql4% %number% %sql5% `n, temp.txt
}
Got this to run but it works only for PokerStars and FTP and i play on others sites so it would be posible to make like an universal hand marking script? Maybe modifying the script so it takes the info of the hand we want to mark and just use PT4 databse info without having to go through the HH folder from each site? Anyway PT4 is going to be importing the hh to its folder either way so...anyone?
Script: Mark Current Hand Quote
12-26-2014 , 03:28 PM
I haven't had any success getting this to work with PokerStars and HM1 are there any other options out there?
Script: Mark Current Hand Quote
09-17-2015 , 07:35 AM
Hey,

I try to get the script work for PT4 but I get a errorcode:

Code:
ERROR: null value in column "id_x" violates not-null constraint
UPDATE 0
I guess there is a Problem with the information in the HHs from stars, correct?

.ini
Code:
[LogFolder]
postgrespath=D:\PostgreSQL\bin
StarsHHPath=C:\Users\Gigabyte\AppData\Local\PokerStars.EU\HandHistory\Annuit20
postgresdb=PT4_2014_02_10_180721
postgresuser=postgres
FullTiltHHPath=
[Hotkeys]
HK_sql=F5
HK_mark=F4
[Settings]
PT4=1
Script:
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, PT4, %thisahk%.ini, Settings, PT4, 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
}
}
}
else
if PT4
{
sql1=INSERT INTO tags (id_x, enum_type, flg_tournament, id_tag, flg_auto) 
sql2=VALUES ((SELECT id_hand FROM tourney_hand_summary WHERE hand_no='
sql3='), 'H', 't', '1', 'f');`n
sql4=UPDATE tourney_hand_summary SET flg_tag='t' WHERE hand_no='
sql5=';`n
Loop, Parse,numbers,`n,
{
if A_loopField
{
stringreplace,number,A_loopField,`n,,All
stringreplace,number,number,`r,,All
FileAppend, %sql1% %sql2% %number% %sql3% %sql4% %number% %sql5% `n, temp.txt
}
}
}
FileAppend, "%PostgresLogPath%\psql.exe"%A_space%"%postgresdb%"%A_space%"%postgresuser%"%A_space%<"%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, Radio, x60 y90 w50 h20 Checked%HM1% vHM1, HM1
   Gui, Add, Radio, x115 y90 w50 h20 Checked%PT4% vPT4, PT4

   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 PT4
IniWrite, %PT4%, %thisahk%.ini, Settings, PT4
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
02-28-2016 , 12:25 PM
What version is actually working (HM2 user)? Thanks
Script: Mark Current Hand Quote
Script: Mark Current Hand
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
Script: Mark Current Hand

      
m