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!
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!