PDA

View Full Version : My AHK for HEM: Replayer, Notes and mini history



Hood
03-12-2009, 11:51 AM
I posted this on 2+2 yesterday then thought it would make sense to crosspost here - it's my collection of functions of HEM with some hotkey bindings. I notice a similar script for the replayer here on this forum so this is a bit of a repetition, but it's got a few other features some might find useful.

See top of script for exact features/setup, but it's all done in functions so it should be easy to add/remove what you want to alter as required.



/*
HEM Shortcuts

Features:
- Replayer hotkeys
- MButton1 and 2 (side buttons) to skip through hands
- Mouse wheel to step through the action
- Middle button to start/stop the replayer
- right mouse button + scroll wheel changes speed

- h - to open the hand history viewer
- c - to copy the HH to clipboard
- m - marks (or unmarks if previously marked) a hand

- Escape to close window

- On the mini hand history review (both ingame and from hand review)
- Esc - closes window
- m - marks/unmarks hand
- c - copies hand to clipboard
- up/down cycles through hands

- on the notes window
- ESC
- this overrides the default behaviour (save) so that now
- if the text is blank, it clicks cancel - i.e. no changes are saved
the result is if you leave a note blank, it wont be saved with a note icon
- if there is text, then 'save' is clicked.
- alt-s forces a save (to save a blank with the icon)
- alt-x clears, and saves (so the note and icon are both blanked)
- alt-F1-F4 this changes the note icon to a specified note. Currently i have
this set to icons 1, 4, 6 and 8 (black, green, yellow and red), but it's easy
to add and change as required.

- Window movement of notes window and hand history window to a new location
and focuses the window (on notes txt box) after move and sets the cursor to the
end of the file

KnownIssues:
-

Notes:
-

ToDo:
- quick copy to clipboard shortcut in the hand list
- quick upload to weaktight.com
*/

; SETUP AND CONFIGURATION WHAT HO
; --------------------------------------------------------
;Script configuration
#NoEnv
#SingleInstance force
#Include %a_scriptDir%
SendMode Input
SetWorkingDir %a_scriptDir%

; Changes these to pixel x/y and width/height for the handhistory and notes windows
HANDHISTORY_X := 1210
HANDHISTORY_Y := 120

NOTES_X := 1210
NOTES_Y := 120
NOTES_W := 230
NOTES_H := 340

; Frequency to check for new windows to move them
SetTimer MoveWindowsLoop, 250

; Identifiers for each window.
GroupAdd, Replayer, Holdem Manager Replayer
GroupAdd, MiniHistories, , 2+2 ; Mini history titles change depending on if it's ingame or in replayer. We use the 2+2 button as an identifier.
GroupAdd, Notes, , asdfas ; In my version, the hidden text "asdfas" identifies all note window. Not sure if this is the case for versions, and may break in the future!

; note id consts
TOTAL_NOTES := 23
NOTES_PER_ROW := 8
ICON_WIDTH := 20
ICON_HEIGHT := 20

Menu Tray, Icon, hemshortcuts.ico ;make yourself a nice little icon and put it in the same location as the ahk script

return


; HOTKEYS
; --------------------------------------------------------
; Hotkeys for the replayer
#IfWinActive, ahk_group Replayer

Right::
XButton2::
replayerChangeHand()
return

Left::
XButton1::
replayerChangeHand(true)
return

Up::
MButton::
replayerStartStop()
return

WheelUp::
replayerMoveAction()
return

WheelDown::
replayerMoveAction(true)
return

RButton & WheelDown::
replayerChangeSpeed(true)
return

RButton & WheelUp::
replayerChangeSpeed()
return

h::
replayerClickHistory()
return

c::
replayerClickHistory()
historyCopyText()
historyClose()
WinActivate, ahk_group Replayer
return

m::
replayerClickHistory()
historyMark()
historyClose()
WinActivate, ahk_group Replayer
return

Esc::
WinClose, ahk_group Replayer
return

; MINI-HAND HISTORY HOTKEYS
; --------------------------------------------------------
#IfWinActive, ahk_group MiniHistories
Esc::
historyClose()
return

RButton & XButton1::
m::
historyMark()
return

c::
historyCopyText()
return

Up::
historyChangeHand()
return

Down::
historyChangeHand(true)
return

; NOTES HOTKEYS
; --------------------------------------------------------
#IfWinActive, ahk_group Notes
Esc::
if (noteGetText()) {
noteSave()
} else {
noteCancel()
}
return

!s::
noteSave()
return

!x::
noteClear()
noteSave()
return

!|::
selectNoteIcon(2)
return

!1::
selectNoteIcon(4)
return

!2::
selectNoteIcon(6)
return

!3::
selectNoteIcon(8)
return




; NOTES HOTKEYS
; --------------------------------------------------------
; WINDOW MOVEMENT
MoveWindowsLoop:
WinGet, id, ID, ahk_group MiniHistories
if (id) {
if (!movedhistory) {
movedhistory := true
WinMove ahk_id %id%,, %HANDHISTORY_X%, %HANDHISTORY_Y%
WinActivate, ahk_id %id%
}
} else {
movedhistory := false
}

WinGet, id, ID, ahk_group Notes
if (id) {
if (!movednotes) {
movednotes := true
WinMove ahk_id %id%,, %NOTES_X%, %NOTES_Y%, %NOTES_W%, %NOTES_H%
WinActivate, ahk_id %id%
ControlFocus, RichEdit20A1, ahk_id %id%
SetControlDelay, -1
ControlSend, RichEdit20A1, ^{End}, ahk_id %id%
}
} else {
movednotes := false
}
return



; REPLAYER FUNCTIONS
; All functions assume the active window is the replayer
; --------------------------------------------------------
; jumps either forward or back a hand
replayerChangeHand(goback=false) {
SetTitleMatchMode, 3
button := goback ? "<" : ">"
ControlGet, v, Visible, , ||
if (v) {
ControlClick, ||
ControlClick, %button%
ControlClick, GO
} else {
ControlClick, %button%
}
SetTitleMatchMode, 1
}

; Starts/stops the replayer
replayerStartStop() {
SetTitleMatchMode, 3
ControlGet, v, Visible, , ||
if (v) {
ControlClick, ||
} else {
ControlClick, GO
}
SetTitleMatchMode, 1
}

; Moves forwards and backwards in the action of the hand
replayerMoveAction(goback=false) {
if goback
ControlClick X186 Y596
else
ControlClick X474 Y597
}

; ; Changes the playback speed - set down to reduce speed.
replayerChangeSpeed(down=false) {
if down
ControlSend, WindowsForms10.msctls_trackbar32.app.0.33c0d9d1, {Down}, A
else
ControlSend, WindowsForms10.msctls_trackbar32.app.0.33c0d9d1, {Up}, A
}

; Opens the hand history viewer
replayerClickHistory() {
If (!WinExist("ahk_group MiniHistories")) {
MouseGetPos, x, y
Click, 64, 105
MouseMove, x, y, 0
WinWait, ahk_group MiniHistories, , 2
}
}

; MINI HANDHISTORY FUNCTIONS
; --------------------------------------------------------
; Clicks the "txt" button to copy text to clipboard
historyCopyText() {
SetControlDelay -1
clipboard := ""
ControlClick, Txt, ahk_group MiniHistories
ClipWait, 2
}

; Closes the history window
historyClose() {
WinClose, ahk_group MiniHistories
}

; Toggles the hand mark
historyMark() {
SetControlDelay -1
ControlClick, Button4, ahk_group MiniHistories
}

; Moves to the next or previous hand
historyChangeHand(prev=false) {
d := prev ? "{Down}" : "{Up}"
ControlFocus, ComboBox1, A
Send % d
}


; NOTES FUNCTIONS
; All functions assume note is active window
; --------------------------------------------------------
; Get the note text from window
noteGetText() {
ControlGetText, txt, RichEdit20A1, A
return txt
}

; Clicks the cancel button
noteCancel() {
SetControlDelay -1
ControlClick, Cancel, A
}

; Clicks the save button
noteSave() {
SetControlDelay -1
ControlClick, Save, A
}

; Clicks the clear button
noteClear() {
SetcontrolDelay -1
ControlClick, Clear
}

; Selects a specific note icon. Function takes icon - this
; should be a numerical value from 1 up to 23.
selectNoteIcon(icon) {
global TOTAL_NOTES, NOTES_PER_ROW, ICON_WIDTH, ICON_HEIGHT
SetcontrolDelay -1
ControlClick, Button4, A
y := 2 + ((icon - 1) // NOTES_PER_ROW) * ICON_HEIGHT
x := 2 + (mod(icon - 1, NOTES_PER_ROW)) * ICON_WIDTH
ControlClick, Button5, A,,,, x%x% y%y%
}


Note to roy / mike: in every note window there's the hidden text "asdfas", please keep this in future releases because it makes it much easier to identify a note window!

mrhobbeys
05-10-2009, 04:54 PM
Hi I really really want to use this but it is not working. Please help.

mrhobbeys
05-12-2009, 08:57 PM
Should I be posting errors, or is there a new version?

Hood
05-13-2009, 09:23 AM
What problem are you getting?

One thing is unless you create an icon, you need to delete (or comment out by putting a ; at the start) this line:

Menu Tray, Icon, hemshortcuts.ico ;make yourself a nice little icon and put it in the same location as the ahk script

Other than that it should still work fine let me know what prob you get.

GrumpyDadPoker
06-26-2009, 08:02 AM
Looks like something worht spending sometime on it, I'm going to have a detailed look, thanks for posting!

El Helado
01-13-2010, 11:47 AM
Its a SICK useful script and makes handreviewing extremly much more enjoyable since its so easy to scroll back and forth for the interesting action.

One new problem thou, just installed win7 and the script works and the forwardscroll but NOT the backwardscroll, extremly strange :S. (The back/downscroll works fine on other applications.)

What to do!?

Hood
01-13-2010, 12:00 PM
VERY QUICK ANSWER THAT MAY HAVE 60% SUCCESS RATE:

- edit the script file
- find line ControlClick X186 Y596
- change to ControlClick X482 Y606
- save, reload, does that work?

LONG ANSWER:

The problem will be that the co-ordinates that 'click' to hit the back button are now missing target area. This could be for 2 reasons:

- With windows 7, i think with the aero skin the window is a different size and the co-ordinates are now inaccurate.

- HEM made the replayer resizeable; perhaps you've inadvertently resized from the default window position so now the co-ordinates are wrong.

I haven't worked out a more accurate way to set these co-ordinates to work on all installs. I am running windows 7 and i have it set to X482 Y606 and that works, so try that. if it doesn't, you will need to find the co-ordinates yourself.

Brief explanation on how to do this:

http://forumserver.twoplustwo.com/showpost.php?p=15546280&postcount=21

Longer explanation - see part "How do I quickly mark hands whilst Iím playing?". It explains using window spy in more detail:

http://www.sickread.com/blog/article/few-faqs-how-to-learn-good/

Fwiw, i maintain this script now on my blog:
http://www.sickread.com/blog/article/ahk-script-holdem-manager-shortcuts/

El Helado
01-13-2010, 12:05 PM
VERY QUICK ANSWER THAT MAY HAVE 60% SUCCESS RATE:

- edit the script file
- find line ControlClick X186 Y596
- change to ControlClick X482 Y606
- save, reload, does that work?

LONG ANSWER:

The problem will be that the co-ordinates that 'click' to hit the back button are now missing target area. This could be for 2 reasons:

- With windows 7, i think with the aero skin the window is a different size and the co-ordinates are now inaccurate.

- HEM made the replayer resizeable; perhaps you've inadvertently resized from the default window position so now the co-ordinates are wrong.

I haven't worked out a more accurate way to set these co-ordinates to work on all installs. I am running windows 7 and i have it set to X482 Y606 and that works, so try that. if it doesn't, you will need to find the co-ordinates yourself.

Brief explanation on how to do this:

http://forumserver.twoplustwo.com/showpost.php?p=15546280&postcount=21

Longer explanation - see part "How do I quickly mark hands whilst Iím playing?". It explains using window spy in more detail:

http://www.sickread.com/blog/article/few-faqs-how-to-learn-good/

Fwiw, i maintain this script now on my blog:
http://www.sickread.com/blog/article/ahk-script-holdem-manager-shortcuts/

Now both backward and forwardscroll forwards the action!

El Helado
01-13-2010, 12:11 PM
VERY QUICK ANSWER THAT MAY HAVE 60% SUCCESS RATE:

- edit the script file
- find line ControlClick X186 Y596
- change to ControlClick X482 Y606
- save, reload, does that work?

LONG ANSWER:

The problem will be that the co-ordinates that 'click' to hit the back button are now missing target area. This could be for 2 reasons:

- With windows 7, i think with the aero skin the window is a different size and the co-ordinates are now inaccurate.

- HEM made the replayer resizeable; perhaps you've inadvertently resized from the default window position so now the co-ordinates are wrong.

I haven't worked out a more accurate way to set these co-ordinates to work on all installs. I am running windows 7 and i have it set to X482 Y606 and that works, so try that. if it doesn't, you will need to find the co-ordinates yourself.

Brief explanation on how to do this:

http://forumserver.twoplustwo.com/showpost.php?p=15546280&postcount=21

Longer explanation - see part "How do I quickly mark hands whilst I’m playing?". It explains using window spy in more detail:

http://www.sickread.com/blog/article/few-faqs-how-to-learn-good/

Fwiw, i maintain this script now on my blog:
http://www.sickread.com/blog/article/ahk-script-holdem-manager-shortcuts/

Windows spy was sweet, I found out that x186, x606 worked for me. Sweet, maybe I can find out how I can fix the broken PokerPad-links.

Btw, how does coordinates like that work when its resizeable windows? There is a lot of hotkeysscripts to work on resizeable tables so it cannot be impossible.

Hood
01-13-2010, 12:17 PM
Btw, how does coordinates like that work when its resizeable windows? There is a lot of hotkeysscripts to work on resizeable tables so it cannot be impossible.

It doesn't.

Scripts work by not using exact co-ordinates. They may instead use the ButtonClick command and use the name of the control. That's not possible here because these buttons arent windows controls (you'll notice where possible, the other replayer hotkeys use this method).

Other scripts do clever stuff like working out the relative positions of the contorls by looking at the windows size and working out button location as a fraction of that. That is entirely possible here, but beyond the goal of the script (it's my own personal script i did to just get working, and others were interested so i released it. this was before HEM had resizeable windows)

El Helado
01-13-2010, 12:51 PM
It doesn't.

Scripts work by not using exact co-ordinates. They may instead use the ButtonClick command and use the name of the control. That's not possible here because these buttons arent windows controls (you'll notice where possible, the other replayer hotkeys use this method).

Other scripts do clever stuff like working out the relative positions of the contorls by looking at the windows size and working out button location as a fraction of that. That is entirely possible here, but beyond the goal of the script (it's my own personal script i did to just get working, and others were interested so i released it. this was before HEM had resizeable windows)

Yeah I understand, its just that I realize that I could probably work out a fix for other AHK-scripts that have become incompatible with updates. That would be nice since I have no clue how to write my own AHKs etc.

lucky_river
08-17-2011, 06:57 PM
great work, its working for me(unlike the other one code in second thread), thx :)

mrbambocha
08-24-2011, 11:46 PM
Is this the same AHK like this one: http://forums.holdemmanager.com/3rd-party-programs-compatible-holdem-manager/4838-replayer-enhancer-free-ahk-program-2.html

Which one is working?