Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-09-2006, 02:15 PM
Roland Roland is offline
Senior Member
 
Join Date: Mar 2005
Location: Norwich, UK
Posts: 2,703
Default 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
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.