|
#1
|
|||
|
|||
TableNavigator
Okay, I decided to check out this mousless poker thing the other day because my mouse seemed kinda slow and it was pissing me off. Apparently I’m too stupid to play in the activated table only though - lots of misclicks - so I needed something to navigate from table to table.
I found a script that does exactly that - MrMoos - but figured using the standard table size would be problematic with resizing tables and all; besides, I find the idea of having the cursor jumping around all the time when playing “mousless” kinda unappealing (I’m a perfectionist [img]/images/graemlins/wink.gif[/img]). Lastly, I wanted some kind of visible cue as to what table I was actually playing in, because I’m really slow. So I wrote this script. It places a colored bar on the title bar of a table (similar to what MTH does) which you can move from table to table using the up-down-left-right keys. The variable “def_t” (for default_table) in the script always contains the unique ID of the table under the bar; it should be easy to modify existing clicking scripts to use the ahk_id instead of the window title (ControlClick, <SomeControl>, ahk_id%def_t%). The script assumes that the tables are all roughly the same size (like when you use the “tile”-button on the Beta), that you’re playing without overlap and that you’re setup looks something like this: T - T - T T - T - T T - T - T i.e. that there are no more that three tables in one row or column. It also assumes that you are playing no more that 9 tables (because that’s the number you can have without overlap on a 1600x1200 screen; I only have one screen, so if you want to use this on a multi-screen setup or for more that 9 tables you’ll have to modify the script). That said, it’s pretty flexible so just play around with it a bit and see what it will do. Okay, that’s about it. Keep in mind that I haven’t tested this extensively or anything so it’s far from bug free. Any ideas for improvement welcome. I didn’t post it as code because that loses the linefeeds for some reason (when you c&p). I hope somebody likes it: ;__________________________Table Navigator_____________________ ; AutoHotkey Version: 1.0.41.02 ; Platform: WinXP ; Author: Roland SysGet, size_caption, 4 SysGet, size_boarder, 32 size_titlebar := size_caption + size_boarder ;I wanted the GUI to be the same height as the titlebar and this seems to do the trick Gui, +alwaysontop +Lastfound +Owner Gui, Color, 00008B ;a dark blue I quite like. Change it to whatever you want WinSet, Transparent, 200 ;make the GUI slightly transparent - looks better that way Gui, -Caption Gosub, get_table_list ;get the table list without waiting for the timer. That way we can... def_t = %table_1% ;... make table_1 the default table to have a starting point SetTimer, get_table_list, 1000 ;update table_list every second WinGetPos, x, y, , , ahk_id%def_t% Gui, Show, w800 h%size_titlebar% x%x% y%y% NoActivate, table_navigator ;show the GUI on table_1 SetTimer, show_hide, 200 return ;_________end of auto-execute section___________ ;_________subroutines: get_table_list: table_list := Update_tables() ; the function returns a comma seperated list of unique window IDs Loop, Parse, table_list, `, ;assign these IDs to the variables "table_1", "table_2" etc. { table_%A_Index% = %A_LoopField% } return show_hide: ;hide the GUI if a) def_t doesn't exist, b) def_t is minimized or c) the active window is maximized IfWinExist, ahk_id%def_t% { WinGet, is_maximised_active, MinMax, A WinGet, is_minimized_def_t, MinMax, ahk_id%def_t% If (is_maximised_active = 1 or is_minimized_def_t = -1) Gui, Hide else Gui, Show, NoActivate } else Gui, Hide return ;_________hotkeys: down:: key = down def_t := GetTarget(key) ;pass "key" to the GetTarget function which returns the new def_t WinGetPos, px, py, , , ahk_id%def_t% ;move the GUI to the new de_t Gui, Show, w%w% x%px% y%py% NoActivate return up:: key = up def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate return right:: key = right def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate return left:: key = left def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate return ;_________functions: Update_tables() ;this function returns "table_list" and also operates on the GUI (which is why "size_titlebar" is made global): { global size_titlebar WinGet, pid, PID, Welcome to the PartyPoker.com ;retrieves the process ID (using the window title of the lobby) WinGet, id, list, Table ahk_pid%pid% ahk_class #32770, , Welcome to the PartyPoker.com Lobby, Side Bet ;make a list of windows IDs matching ahk_pid/class, excluding the lobby Loop, %id% { StringTrimRight, this_id, id%a_index%, 0 ;look familiar? [img]/images/graemlins/wink.gif[/img] WinGetPos, x, y, w, h, ahk_id %this_id% w -= 50 ;this allows for slight overlap or slightly different table sizes h -= 50 If (x < a_screenwidth/6 AND y < a_screenheight/6) ;determine the table number based on its position table_1 = %this_id% If (x < a_screenwidth/6 AND y > a_screenheight/6 AND y < 2*h) table_2 = %this_id% If (x < a_screenwidth/6 AND y >= 2*h) table_3 = %this_id% If (x > a_screenwidth/6 AND y < a_screenheight/6 AND x < 2*w AND y < 2*h) table_4 = %this_id% If (x > a_screenwidth/6 AND y > a_screenheight/6 AND x < 2*w AND y < 2*h) table_5 = %this_id% If (x > a_screenwidth/6 AND x < 2*w AND y >= 2*h) table_6 = %this_id% If (y < a_screenheight/6 AND x >= 2*w) table_7 = %this_id% If (y > a_screenheight/6 AND x >= 2*w AND y < 2*h) table_8 = %this_id% If (x > a_screenwidth/6 AND x >= 2*w AND y >= 2*h) table_9 = %this_id% } table_list = %table_1%,%table_2%,%table_3%,%table_4%,%table_5%, %table_6%,%table_7%,%table_8%,%table_9% w += 50 ;reset to the actual width ;modify the GUI according to the height of the titlebar, the width of the table(s) ;(this assumes all tables are roughly the same size) and round the edges because it looks better: WinSet, Region, w%w% h%size_titlebar% 0-0 %w%-0 %w%-%size_titlebar% 0-%size_titlebar% R20-20, table_navigator return, table_list ;return "table_list" } GetTarget(key) ;this function returns the new "def_t" when passed "key" { global def_t ;make these two variables global global table_list If key = down new_order = 123456789 ;since this is the order the tables are in anyways, new_order equals the old order in this case If key = up new_order = 987654321 ;"up" is the opposite of "down" [img]/images/graemlins/smile.gif[/img] so we just reverse the order If key = right new_order = 147258369 ;the table to the right of table_1 is table_4 etc. If key = left new_order = 963852741 ;reverse the order for "right" Loop, Parse, table_list, `, ;parse table_list, assigning each substring (ID) a new table number based on the new order { StringMid, new_number, new_order, %a_index%, 1 table_%new_number% = %a_loopfield% } Loop, 9 { StringTrimRight, table, table_%a_index%, 0 ;acces the (new) array to find out which number the def_t is in the new order If def_t = %table% { table_number = %a_index% break } } Loop, 9 ;this loop finds the number of the next table in the list (target) { table_number++ ;for instance: if the loop above determined that the def_t is table_5, this loop looks for table_6 first; If table_%table_number% <> ;if "table_6" is empty, it looks for table_7 and so on { target = %table_number% break } If table_number >= 9 ;if table_number reaches 9, tables 6 through 9 didn't exist, to continue the example above table_number = 0 ;so we search for tables 1 through 4 (table_number is set to 1 at the beginning of the next loop iteration) } target := table_%target% ;once we've found "target", change it to be the ID of the table (using the array created by the first loop) IfWinExist, ahk_id%target% ;only return a new de_t if it actually still exists; else, return the old def_t { def_t = %target% } Return, def_t ;return "def_t" } ;_______end of code edited to show title. -Sam |
#2
|
|||
|
|||
Re: A script you might like
Awesome. I use the MTH style, so I don't think I'll personally use this, but I'm psyched to see more AHK developement on the forum. I'll check-out your code; see if there're ideas I can steal in future scripts. [img]/images/graemlins/smile.gif[/img]
-Sam |
#3
|
|||
|
|||
Re: A script you might like
[ QUOTE ]
I hope somebody likes it: [/ QUOTE ] I do! Tyvm for posting this, will check it out later tonight [img]/images/graemlins/smile.gif[/img] Can I ask if anybody knows if there is a thread here which lists all of the available AHK scripts (I looked before but couldn't see it, so apologize if my searching not so good... [img]/images/graemlins/smile.gif[/img] ). I would love to adapt this so that it worked on a joy-pad and just need to find the relevant AHK snippets to do it. Juk [img]/images/graemlins/smile.gif[/img] |
#4
|
|||
|
|||
Re: A script you might like
[ QUOTE ]
Can I ask if anybody knows if there is a thread here which lists all of the available AHK scripts [/ QUOTE ] don’t know, but you might find this old thread helpful: link And this is from the AHK tutorial: Remapping I myself have no experience with remapping whatsoever (just ordered a game pad, hopfully it comes tomorrow [img]/images/graemlins/smile.gif[/img]). On a side note, I just tried to get Sams clicking script to use ahk_id instead of the window title, but no luck. I just don’t get the SetTitleMatchMode part. What does it do? [img]/images/graemlins/confused.gif[/img] |
#5
|
|||
|
|||
Re: A script you might like
[ QUOTE ]
On a side note, I just tried to get Sams clicking script to use ahk_id instead of the window title, but no luck. I just don’t get the SetTitleMatchMode part. What does it do? [img]/images/graemlins/confused.gif[/img] [/ QUOTE ]I'm not sure what you mean and the ahk_id vs window title. "SetTitleMatchMode" is a parameter in how it searches. It changes from "Exact match" to "Begins this way" to "Contains this string". -Sam |
#6
|
|||
|
|||
Re: A script you might like
Well, I’m still not sure why you use SetTitleMatchMode (I’m tired - getting late over here in Germany) but here goes anway:
;__________________________Table Navigator_____________________ ; AutoHotkey Version: 1.0.41.02 ; Platform: WinXP ; Author: Roland & SamIAm ;some of Sams functions (these have to be in the auto-execute section as I found out; so apparently they get called [img]/images/graemlins/crazy.gif[/img]. Getting late, like I said). ;FOLD = 1; newButton("fold", 1, "AfxWnd42s14") ;( newButton("checkFoldInTurn", 1, "AfxWnd42s20") newButton("foldInTurn", 1, "AfxWnd42s19") ;CALL = 2; newButton("call", 2, "Call (", 1) newButton("check", 2, "AfxWnd42s15") ;( newButton("cInTurn", 2, "AfxWnd42s21") ;RAISE = 3; newButton("bet", 3, "Bet", 1) newButton("raise", 3, "Raise ", 1) newButton("r1InTurn", 3, "AfxWnd42s23") ;LEAVE = 4; newButton("muckNow", 4, "Muck?", 2) newButton("sitout", 4, "Sit Out") newButton("muckInTurn", 4, "Muck Losing/Uncalled Hands") ;STAY = 5; newButton("back", 5, "I am Back") newButton("waitNow", 5, "AfxWnd42s16") ;( newButton("waitInTurn", 5, "Wait for Big Blind") ;PLAY = 6; newButton("post", 6, "Post", 1) newButton("show", 6, "Show", 2) newButton("autopost", 6, "Auto Post Blind") SysGet, size_caption, 4 SysGet, size_boarder, 32 size_titlebar := size_caption + size_boarder ;I wanted the GUI to be the same height as the titlebar and this seems to do the trick Gui, +alwaysontop +Lastfound +Owner Gui, Color, 00008B ;a dark blue I quite like. Change it to whatever you want WinSet, Transparent, 200 ;make the GUI slightly transparent - looks better that way Gui, -Caption Gosub, get_table_list ;get the table list without waiting for the timer. That way we can... def_t = %table_1% ;... make table_1 the default table to have a starting point SetTimer, get_table_list, 1000 ;update table_list every second WinGetPos, x, y, , , ahk_id%def_t% Gui, Show, w800 h%size_titlebar% x%x% y%y% NoActivate, table_navigator ;show the GUI on table_1 SetTimer, show_hide, 200 return ;_________end of auto-execute section___________ ;_________subroutines: get_table_list: table_list := Update_tables() ; the function returns a comma seperated list of unique window IDs Loop, Parse, table_list, `, ;assign these IDs to the variables "table_1", "table_2" etc. { table_%A_Index% = %A_LoopField% } return show_hide: ;hide the GUI if a) def_t doesn't exist, b) def_t is minimized or c) the active window is maximized IfWinExist, ahk_id%def_t% { WinGet, is_maximised_active, MinMax, A WinGet, is_minimized_def_t, MinMax, ahk_id%def_t% If (is_maximised_active = 1 or is_minimized_def_t = -1) Gui, Hide else Gui, Show, NoActivate } else Gui, Hide return ;_________hotkeys: down:: key = down def_t := GetTarget(key) ;pass "key" to the GetTarget function which returns the new def_t WinGetPos, px, py, , , ahk_id%def_t% ;move the GUI to the new de_t Gui, Show, w%w% x%px% y%py% NoActivate return up:: key = up def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate return right:: key = right def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate return left:: key = left def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate return <font color="red"> ;Sams hotkeys: </font> !1:: clickVis(1) return !2:: clickVis(2) return !3:: clickVis(3) return !4:: clickVis(4) return !5:: clickVis(5) return !6:: clickVis(6) return !7:: debug() return ;_________functions: Update_tables() ;this function returns "table_list" and also operates on the GUI (which is why "size_titlebar" is made global): { global size_titlebar WinGet, pid, PID, Welcome to the PartyPoker.com ;retrieves the process ID (using the window title of the lobby) WinGet, id, list, Table ahk_pid%pid% ahk_class #32770, , Welcome to the PartyPoker.com Lobby, Side Bet ;make a list of windows IDs matching ahk_pid/class, excluding the lobby Loop, %id% { StringTrimRight, this_id, id%a_index%, 0 ;look familiar? [img]/images/graemlins/smile.gif[/img] WinGetPos, x, y, w, h, ahk_id %this_id% w -= 50 ;this allows for slight overlap or slightly different table sizes h -= 50 If (x < a_screenwidth/6 AND y < a_screenheight/6) ;determine the table number based on its position table_1 = %this_id% If (x < a_screenwidth/6 AND y > a_screenheight/6 AND y < 2*h) table_2 = %this_id% If (x < a_screenwidth/6 AND y >= 2*h) table_3 = %this_id% If (x > a_screenwidth/6 AND y < a_screenheight/6 AND x < 2*w AND y < 2*h) table_4 = %this_id% If (x > a_screenwidth/6 AND y > a_screenheight/6 AND x < 2*w AND y < 2*h) table_5 = %this_id% If (x > a_screenwidth/6 AND x < 2*w AND y >= 2*h) table_6 = %this_id% If (y < a_screenheight/6 AND x >= 2*w) table_7 = %this_id% If (y > a_screenheight/6 AND x >= 2*w AND y < 2*h) table_8 = %this_id% If (x > a_screenwidth/6 AND x >= 2*w AND y >= 2*h) table_9 = %this_id% } table_list = %table_1%,%table_2%,%table_3%,%table_4%,%table_5%, %table_6%,%table_7%,%table_8%,%table_9% w += 50 ;reset to the actual width ;modify the GUI according to the height of the titlebar, the width of the table(s) ;(this assumes all tables are roughly the same size) and round the edges because it looks better: WinSet, Region, w%w% h%size_titlebar% 0-0 %w%-0 %w%-%size_titlebar% 0-%size_titlebar% R20-20, table_navigator return, table_list ;return "table_list" } GetTarget(key) ;this function returns the new "def_t" when passed "key" { global def_t ;make these two variables global global table_list If key = down new_order = 123456789 ;since this is the order the tables are in anyways, new_order equals the old order in this case If key = up new_order = 987654321 ;"up" is the opposite of "down" [img]/images/graemlins/smile.gif[/img] so we just reverse the order If key = right new_order = 147258369 ;the table to the right of table_1 is table_4 etc. If key = left new_order = 963852741 ;reverse the order for "right" Loop, Parse, table_list, `, ;parse table_list, assigning each substring (ID) a new table number based on the new order { StringMid, new_number, new_order, %a_index%, 1 table_%new_number% = %a_loopfield% } Loop, 9 { StringTrimRight, table, table_%a_index%, 0 ;acces the (new) array to find out which number the def_t is in the new order If def_t = %table% { table_number = %a_index% break } } Loop, 9 ;this loop finds the number of the next table in the list (target) { table_number++ ;for instance: if the loop above determined that the def_t is table_5, this loop looks for table_6 first; If table_%table_number% <> ;if "table_6" is empty, it looks for table_7 and so on { target = %table_number% break } If table_number >= 9 ;if table_number reaches 9, tables 6 through 9 didn't exist, to continue the example above table_number = 0 ;so we search for tables 1 through 4 (table_number is set to 1 at the beginning of the next loop iteration) } target := table_%target% ;once we've found "target", change it to be the ID of the table (using the array created by the first loop) IfWinExist, ahk_id%target% ;only return a new de_t if it actually still exists; else, return the old def_t { def_t = %target% } Return, def_t ;return "def_t" } <font color="red"> ;the rest of Sams functions: </font> debug() { local but, num, Output but = 1 Loop { if(but > numButtons) break num = 1 Loop { if(num > numButtons%but%) break if(visible(but,num) = 1) Output = % Output . names%but%x%num% . " is visible.`n" num += 1 } but += 1 } MsgBox %Output% } clickVis(button) { local output, i, isVis, currString, currMatch WinGetTitle, winTitle, <font color="red"> ahk_id%def_t%</font> i = 1 Loop { if(i > numButtons%button%) break if (visible(button,i) = 1) { currMatch := matches%button%x%i% SetTitleMatchMode, %currMatch% currString := strings%button%x%i% ControlClick, %currString%, %winTitle% break } i += 1 } } visible(but, num) { local currentMatch, currentString local output currentMatch = % matches%but%x%num% currentString = % strings%but%x%num% SetTitleMatchMode % currentMatch ControlGet, output, Visible, , %currentString%, %winTitle% if output <> 1 { output = 0 } return output } newButton(name, button, string, match=3) { local buttonCount numButtons += 1 numButtons%button% += 1 buttonCount := numButtons%button% names%button%x%buttonCount% := name matches%button%x%buttonCount% := match strings%button%x%buttonCount% := string } ;_______end of code_____ |
#7
|
|||
|
|||
Re: A script you might like
Thanks again for this, late here too (UK), but I will test this out either tonight or tomorrow and see how I get on using it [img]/images/graemlins/smile.gif[/img]
Juk [img]/images/graemlins/smile.gif[/img] |
#8
|
|||
|
|||
Re: A script you might like
New sub-thread needed I think... the old one got so deep getting hard to read [img]/images/graemlins/smile.gif[/img]
All seems to be working fine for me, and the fix-GUI button working fine too (ty! [img]/images/graemlins/smile.gif[/img] ), but just one anomaly left: sometimes (maybe 20% of time) the "Fold" checkbox just won't select, no idea why though? (and for some strange reason AutoResizer's "Auto-Post 1st BB" started failing). Sleepy again, so maybe it will be clearer as to what is going on tomorrow. I also gona see if I can use a 6th button for lobby control tomorrow. If I could get it to act as a modifier (which seems possible from what I just read in AHK help), then I hope/think script could be 100% joypad driven. Juk [img]/images/graemlins/smile.gif[/img] |
#9
|
|||
|
|||
Re: A script you might like
[ QUOTE ]
just one anomaly left: sometimes (maybe 20% of time) the "Fold" checkbox just won't select, no idea why though? (and for some strange reason AutoResizer's "Auto-Post 1st BB" started failing). [/ QUOTE ] Maybe the new code I added? I haven't had any problems (mainly playing Stud now though, Hold'em is a bankroll killer for me [img]/images/graemlins/ooo.gif[/img]). Modifiers are possible I believe (Sam posted something a few days ago I think). Here's a cool hotkey I just wrote; it deals you in/out at every table: Warning: This will check the auto-post blind checkbox´when dealing in. Joy9:: Loop, Parse, table_list, `, { ControlGet, is_checked, checked, , Button5, ahk_id%a_loopfield% Control, Check, , Button5, ahk_id%a_loopfield% If is_checked = 0 { Control, Check, , Button5, ahk_id%a_loopfield% } else { Control, Uncheck, , Button5, ahk_id%a_loopfield% Control, Check, , Button3, ahk_id%a_loopfield% } } return |
#10
|
|||
|
|||
Re: A script you might like
Hi, just a quick update to say the script going well for me and no problems since the RefreshGUI button added [img]/images/graemlins/smile.gif[/img]
Still confused about the "Fold" checkbox being ignored sometimes but it makes no real difference to the usability (not been quick enough to press alt+1 yet to see if its a joypad only thing [img]/images/graemlins/smile.gif[/img] ). I will try to look into including Sam's modifiers soon too and see if I can make it totally mouseless. Not had time yet to try the Deal-in/Deal-out script, but I wish I knew how AHK knows a checkbox is checked (this would help AutoResizer, as this the only thing AutoResizer can't confirm has actually changed when clicked). Hope the stud going well for you [img]/images/graemlins/smile.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
|
|