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 |
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 |
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] |
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] |
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 |
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_____ |
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] |
Re: A script you might like
Love this, TYVM! [img]/images/graemlins/smile.gif[/img]
Just tried it out on my setup and so far so good! I do have a slight overlap on my setup (using PartyPlanner for the layout) and all was ok too! [img]/images/graemlins/smile.gif[/img] I just made a couple of changes, but only cosmetic: A) Using !down::, !up::, etc rather than just down:: and up::, etc. (Just did this to keep in line with Sam's functions which use ALT key as the modifier, so I can keep running the script and still use the cursor keys elsewhere in windows). B) I altered this line to allow it to be tested on Demo Money: WinGet, id, list, Play 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% Also, I only 4-table 6max atm, and just wondered if it would be possible to stop the wrap-around effect (EG: So if I am in the top left window and press up or left, the GUI just stays at the top left). I owe you one for this!!! I tried quite a few scripts and MTH, and IMHO this is by far the best hybrid yet! [img]/images/graemlins/laugh.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Glad you like it.
[ QUOTE ] I do have a slight overlap on my setup [/ QUOTE ] In this case you might want to try this: up:: key = up def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate <font color="red"> WinActivate, ahk_id%def_t% </font> Return etc.... That way you’ll be able to see the entire table. Good ideas with the demo money and the alt-modifier, thx for sharing. [ QUOTE ] Also, I only 4-table 6max atm, and just wondered if it would be possible to stop the wrap-around effect (EG: So if I am in the top left window and press up or left, the GUI just stays at the top left). [/ QUOTE ] No problem. Getting it to work was the hard part [img]/images/graemlins/laugh.gif[/img]. Do you still want it to skip from the last table in the first row to the first table in the last row etc., or should I turn that off too? [ QUOTE ] I owe you one for this!!! [/ QUOTE ] Nope. [img]/images/graemlins/smile.gif[/img] I use Auto Resizer and love it (especially the auto-rebuy) so tyvm for that mate. |
Re: A script you might like
[ QUOTE ]
Nope. I use Auto Resizer and love it (especially the auto-rebuy) so tyvm for that mate. [/ QUOTE ] Ty for the compliment (alot more peeps use this than I realized! [img]/images/graemlins/smile.gif[/img] ). I just sorry the interface is a bit iffy for the testing version (interfaces not my strong point...), but eventually it will be improved when I get more time (along with the code), and hopefully most of the ideas can go into another project like PartyPlanner for the long term [img]/images/graemlins/smile.gif[/img] Overall this forum has improved my mouse strain problems ten fold or more... Only a few months ago I used to 8/10-table 800x600 tables using built-in windows cascade mode as my only aid, so huge improvement now! [ QUOTE ] Do you still want it to skip from the last table in the first row to the first table in the last row etc., or should I turn that off too? [/ QUOTE ] I think for me just 4-tabling 6max atm, then perhaps easiest for me if this is off also. BUT I can see this being useful for others so I wouldn't totally disable it [img]/images/graemlins/smile.gif[/img] Possibly could there just be an option at the top of the script to turn it on/off? Thanks again for sharing the script - Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Need help, very confused now... (and got AHK tilt now!!! hehe) [img]/images/graemlins/smile.gif[/img]
I just tried to get this working with a joypad, but I seem to be doing something wrong [img]/images/graemlins/confused.gif[/img] I can use the joypad buttons just fine and have adapted your script to do this, but I can't seem to get the D-Pad to control the active window. I run of out ideas now, the script bellow seems to be capable of sending cursor keys fine (ie: it will move around icons on my desktop, or move the cursor in notepad, etc), BUT it just wont send these keys to the other script (they work in parallel somehow, so I can use the keyboard cursors keys to move the active window, and STILL use the D-pad to send up/down/left/right etc) : ;_________________________________________________ ; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoHotkey script. ; #Persistent ; Keep this script running until the user explicitly exits it. SetTimer, WatchAxis, 5 return WatchAxis: GetKeyState, JoyX, JoyX ; Get position of X axis. GetKeyState, JoyY, JoyY ; Get position of Y axis. KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any). if JoyX > 70 KeyToHoldDown = right else if JoyX < 30 KeyToHoldDown = left else if JoyY > 70 KeyToHoldDown = down else if JoyY < 30 KeyToHoldDown = up else KeyToHoldDown = if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down. return ; Do nothing. ; Otherwise, release the previous key and press down the new key: SetKeyDelay -1 ; Avoid delays between keystrokes. if KeyToHoldDownPrev ; There is a previous key to release. Send, {%KeyToHoldDownPrev% up} ; Release it. if KeyToHoldDown ; There is a key to press down. Send, {%KeyToHoldDown% down} ; Press it down. return ;_________________________________________________ I did originally try to merge this script with yours and write it all using functions, but had no luck getting it to work either... [img]/images/graemlins/frown.gif[/img] I not used AHK much (tend to code stuff up using win32 calls) or use another macro-er called MacroSceduler (which is nothing like as good, but lets u write VB functions to get round its limitations). It must be something I am doing which is really silly, but I just can't seem to work out what the heck I am doing wrong. Any help would be very much appreciated [img]/images/graemlins/smile.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
I am having the saming problem with the U-V axis on my script. I use X-Y (the analog stick) as a mouse so I can move around the screen and act in turn but want to use U-V (the gamepad) to send keystrokes but have had no luck. I am still working on it, I'll let you know if I discover something.
|
Re: A script you might like
Fixed my problem now [img]/images/graemlins/laugh.gif[/img] but still no idea why it wouldn't work for me 1st time I tried? Very confusing... [img]/images/graemlins/smile.gif[/img]
While trying to fix this found this interesting freeware app: JoyToKey (It didn't fix the problem, but it might be of use in the future to others...). Here is my modified version of the script: ; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoHotkey script. ; ;__________________________Table Navigator V3____________________ ; - This version works with demo $ tables (see ### Juk: Change 'list, Play' to 'list, Table' for real $.) ; - It now allows the joypad OR alt+cursor keys for navigation, along with joypadbuttons to press F/C/R. ; AutoHotkey Version: 1.0.41.02 ; Platform: WinXP ; Author: Roland & SamIAm ; ### JUK: Added this to make it easier to change between "Play Money" and "Real Money" tables. TableType := Play ;Table ;some of Sams functions (these have to be in the auto-execute section as I found out; so apparently they get called . 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 SetTimer, WatchAxis, 5 ; ### Juk: Added this for Joyapd control (5ms?). 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 ; ### Juk added this to try to get Joypad working. WatchAxis: GetKeyState, JoyX, JoyX ; Get position of X axis. GetKeyState, JoyY, JoyY ; Get position of Y axis. KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any). if JoyX > 70 KeyToHoldDown = right else if JoyX < 30 KeyToHoldDown = left else if JoyY > 70 KeyToHoldDown = down else if JoyY < 30 KeyToHoldDown = up else KeyToHoldDown = if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down. return ; Do nothing. ; Otherwise, release the previous key and press down the new key: SetKeyDelay -1 ; Avoid delays between keystrokes. if KeyToHoldDown ; There is a key to press down. { def_t := GetTarget(KeyToHoldDown) ;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 WinActivate, ahk_id%def_t% } 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 WinActivate, ahk_id%def_t% return !up:: key = up def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate WinActivate, ahk_id%def_t% return !right:: key = right def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate WinActivate, ahk_id%def_t% return !left:: key = left def_t := GetTarget(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate WinActivate, ahk_id%def_t% return ;Sams hotkeys: !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 ; ### JUK: Added these to make joypad buttons map to Sam's functions (for my joypad only). Joy3::ClickVis(1) Joy1::ClickVis(2) Joy2::ClickVis(3) ;_________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, %TableType% 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% ; ### Juk: Change 'list, Play' to 'list, Table' for real $. { StringTrimRight, this_id, id%a_index%, 0 ;look familiar? 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" 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" } ;the rest of Sams functions: 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, ahk_id%def_t% 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_____ Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Thanks for adding joypad support Juk. That’ll save me some work when my joypad arrives. I was hoping I’d get it today, but it’s been snowing on end here so the postman probably took one look at our drive, shook his head and put his car in reverse. Damn him. [img]/images/graemlins/mad.gif[/img]
Anways, I added a little GUI that lets you select a few things. It uses an .ini file to save your settings, so you’ll probably want to put the script in some folder somewhere and create a desktop shortcut; else you’ll have that file floating around all the time. I hope I put all the stuff you added in the right places - no way to test it, since no joypad. Also, it’s getting late again over here. I always underestimate how long this stuff takes. [img]/images/graemlins/crazy.gif[/img] There are still some bugs (especially interesting is the one where WinGetPos returns -3200 for both the x and y position of table_1 [img]/images/graemlins/shocked.gif[/img]), but they’ll have to wait till tomorrow. Here we go: [img]/images/graemlins/smile.gif[/img] ;__________________________Table Navigator V4_____________________ ; AutoHotkey Version: 1.0.41.02 ; Platform: WinXP & Win9x/NT (for joypad) ; Author: Roland, SamIAm & jukofyork ; this script now allows the joypad OR alt+cursor keys for navigation, along with joypadbuttons to press F/C/R. IniRead, 3pos_x, TableNavigator.ini, Position, 3pos_x, 0 IniRead, 3pos_y, TableNavigator.ini, Position, 3pos_y, 0 IniRead, wrapping_on, TableNavigator.ini, Wrapping, wrapping_on, 1 IniRead, wrapping_off, TableNavigator.ini, Wrapping, wrapping_off, 0 IniRead, activate_on, TableNavigator.ini, ActivateTarget, activate_on, 1 IniRead, activate_off, TableNavigator.ini, ActivateTarget, activate_off, 0 IniRead, auto_launch, TableNavigator.ini, AutoLaunch, auto_launch, off TableType = Table 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 If auto_launch = yes { 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, 1: Show, w800 h%size_titlebar% x%x% y%y% NoActivate, table_navigator ;show the GUI on table_1 SetTimer, show_hide, 200 SetTimer, WatchAxis, 5 ; ### Juk: Added this for Joyapd control (5ms?). } Gui, 2: +owner +lastfound +alwaysontop Gui, 2: Color, 4F94CD Gui, 2: Font, s30, Comic Sans MS Gui, 2: Add, Text, vText1 cE0FFFF, Table Gui, 2: Add, Text, vText2 cWhite, Navigator WinSet, Transparent, 0 Gui, 2: -Caption Gui, 2: Show, w259 h200 Center GuiControlGet, Text1, 2: Pos, Text1 GuiControlGet, Text2, 2: Pos, Text2 GuiControl, 2: Move, Text1, % "x" (250 - Text1W)/2 GuiControl, 2: Move, Text2, % "x" (250 - Text2W)/2 Loop, 20 { trans += 10 WinSet, Transparent, %trans% Sleep, 50 } Sleep, 500 Loop, 20 { trans -= 10 WinSet, Transparent, %trans% Sleep, 50 } Gui, 2: Destroy Menu, FileMenu, Add, Launch Navigator, LaunchNavigator Menu, FileMenu, Add, Auto-Launch Navigator, AutoLaunchNavigator Menu, FileMenu, Add Menu, FileMenu, Add, Test on Play Money, PlayMoney Menu, FileMenu, Add Menu, FileMenu, Add, Exit, Exit Menu, HelpMenu, Add, Help, Help Menu, MenuBar, Add, File, :FileMenu Menu, MenuBar, Add, Help, :HelpMenu Menu, MenuBar, Color, FFFACD Gui, 3: Menu, MenuBar If auto_launch = yes Menu, FileMenu, Check, Auto-Launch Navigator Menu, Tray, Add, Show, Show Menu, Tray, Default, Show Gui, 3: +owner +lastfound Gui, 3: Color, CDC9A5 Gui, 3: Font, s10, Arial Gui, 3: Add, Text, Section w70 x20 y20, Wrapping: Gui, 3: Add, Radio, ys checked%wrapping_on% gWrapping_on, On Gui, 3: Add, Radio, checked%wrapping_off% gWrapping_off, Off Gui, 3: Add, Text, x20 w70 Section, Activate target: Gui, 3: Add, Radio, ys checked%activate_on% gActivate_on, On Gui, 3: Add, Radio, checked%activate_off% gActivate_off, Off Gui, 3: Show, x%3pos_x% y%3pos_y% w200 h130, Table Navigator ;call Sams functions: ;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") 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 LaunchNavigator: ;do what the original script did in the auto-execute-section (and still does, if auto-launch was selected) Gosub, get_table_list def_t = %table_1% SetTimer, get_table_list, 1000 WinGetPos, x, y, , , ahk_id%def_t% Gui, 1: Show, w800 h%size_titlebar% x%x% y%y% NoActivate, table_navigator SetTimer, show_hide, 200 SetTimer, WatchAxis, 5 ; ### Juk: Added this for Joyapd control (5ms?). return Exit: 3GuiClose: WinGetPos, 3pos_x, 3pos_y, , , Table Navigator Gui, 3: Destroy IniWrite, %3pos_x%, TableNavigator.ini, Position, 3pos_x IniWrite, %3pos_y%, TableNavigator.ini, Position, 3pos_y IniWrite, %wrapping_on%, TableNavigator.ini, Wrapping, wrapping_on IniWrite, %wrapping_off%, TableNavigator.ini, Wrapping, wrapping_off IniWrite, %activate_on%, TableNavigator.ini, ActivateTarget, activate_on IniWrite, %activate_off%, TableNavigator.ini, ActivateTarget, activate_off IniWrite, %auto_launch%, TableNavigator.ini, AutoLaunch, auto_launch ExitApp return 3GuiSize: If ErrorLevel = 1 Gui, 3: Hide return Show: Gui, 3: Restore Gui, 3: Show return Wrapping_on: wrapping_on = 1 wrapping_off = 0 return Wrapping_off: wrapping_off = 1 wrapping_on = 0 return Activate_on: activate_on = 1 activate_off = 0 return Activate_off: activate_off = 1 activate_on = 0 return AutoLaunchNavigator: If auto_launch = no auto_launch = yes else auto_launch = no Menu, FileMenu, ToggleCheck, Auto-Launch Navigator return PlayMoney: If TableType = Play TableType = Table else TableType = Play Menu, FileMenu, ToggleCheck, Test on Play Money return Help: Gui, 4: Color, F5F5DC Gui, 4: Font, s10, Arial Gui, 4: Add, Text, , ( 1. Turning Wrapping off will prevent TN from moving to the next row or column when it has reached the last table in that row or column. 2. Turning "Activate Target" on will cause the table under TN to be activated. This might be especially useful when over-lapping. 3. Selecting "Auto-Launch Navigator" from the File Menu will cause the Navigator to be launched automatically the next time you start TN. 4. If you wish to test TN on play money first, select "Test on Play Money" from the File Menu. ) Gui, 4: Add, Button, vbutton_close_help Center gCloseHelp, Close Gui, 4: Show, autosize Hide, Help GuiControlGet, button_close_help, 4: pos GuiControl, 4: Move, button_close_help, % "x" (334 - button_close_helpW)/2 Gui, 4: Show return CloseHelp: Gui, 4: Destroy return ; ### Juk added this to try to get Joypad working. WatchAxis: GetKeyState, JoyX, JoyX ; Get position of X axis. GetKeyState, JoyY, JoyY ; Get position of Y axis. KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any). if JoyX > 70 KeyToHoldDown = right else if JoyX < 30 KeyToHoldDown = left else if JoyY > 70 KeyToHoldDown = down else if JoyY < 30 KeyToHoldDown = up else KeyToHoldDown = if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down. return ; Do nothing. ; Otherwise, release the previous key and press down the new key: SetKeyDelay -1 ; Avoid delays between keystrokes. if KeyToHoldDown ; There is a key to press down. { If wrapping_on = 1 def_t := GetTargetWrap(KeyToHoldDown) else def_t := GetTargetNoWrap(KeyToHoldDown) WinGetPos, px, py, , , ahk_id%def_t% ;move the GUI to the new de_t Gui, Show, w%w% x%px% y%py% NoActivate WinActivate, ahk_id%def_t% } return ;_________hotkeys: !down:: key = down If wrapping_on = 1 def_t := GetTargetWrap(key) ;pass "key" to the GetTarget function which returns the new def_t else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% ;move the GUI to the new de_t Gui, Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return !up:: key = up If wrapping_on = 1 def_t := GetTargetWrap(key) else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return !right:: key = right If wrapping_on = 1 def_t := GetTargetWrap(key) else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return !left:: key = left If wrapping_on = 1 def_t := GetTargetWrap(key) else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return ;Sams hotkeys: 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 ; ### JUK: Added these to make joypad buttons map to Sam's functions (for my joypad only). Joy3::ClickVis(1) Joy1::ClickVis(2) Joy2::ClickVis(3) ;_________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 global TableType WinGet, pid, PID, Welcome to the PartyPoker.com ;retrieves the process ID (using the window title of the lobby) WinGet, id, list, %TableType% 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" } GetTargetWrap(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" } GetTargetNoWrap(key) ;this function returns the new "def_t" when passed "key" { global def_t ;make these two variables global global table_list 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 } } If key = down { If table_number = 1 target = 2 If table_number = 2 target = 3 If table_number = 4 target = 5 If table_number = 5 target = 6 If table_number = 7 target = 8 If table_number = 8 target = 9 } If key = up { If table_number = 9 target = 8 If table_number = 8 target = 7 If table_number = 6 target = 5 If table_number = 5 target = 4 If table_number = 3 target = 2 If table_number = 2 target = 1 } If key = right { If table_number = 1 target = 4 If table_number = 4 target = 7 If table_number = 2 target = 5 If table_number = 5 target = 8 If table_number = 3 target = 6 If table_number = 6 target = 9 } If key = left { If table_number = 9 target = 6 If table_number = 6 target = 3 If table_number = 8 target = 5 If table_number = 5 target = 2 If table_number = 7 target = 4 If table_number = 4 target = 1 } 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" } ;the rest of Sams functions: 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, ahk_id%def_t% 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_____ |
Re: A script you might like
Good stuff. We don't have many posts, but the AHK threads are certainly the longest. [img]/images/graemlins/smile.gif[/img]
I stole some of your table-list stuff for another script I'm working on. Hope you don't mind. Another thing: in posting stuff on the forum, your code will look prettier if you use the [ code ] [ /code ] brackets. It won't rip-out your indents and stuff. -Sam P.S. In Atlanta, the weather channel forecasts "chilly" for some time next week. I'll let you know if it ever happens. |
Re: A script you might like
[ QUOTE ]
Another thing: in posting stuff on the forum, your code will look prettier if you use the [ code ] [ /code ] brackets. It won't rip-out your indents and stuff. [/ QUOTE ] Ty, didn't know about this - will use this in future [img]/images/graemlins/smile.gif[/img] Script seems to be working fine still, but I not having much luck with the .ini (seems to ignore/forget my settings, but I prolly doing something wrong... [img]/images/graemlins/smile.gif[/img] ). I just added a couple of lines: 1. Post/Auto-post can be helpful if using AutoResizer at same time, so I used my last button for it: Joy3::ClickVis(1) ; Fold Joy1::ClickVis(2) ; Call Joy2::ClickVis(3) ; Raise <font color="red">Joy4::ClickVis(6) ; ### JUK: V5: Post</font> 2. I get trouble sometimes if I have any HH windows open (sometimes it select HH window, but not sure why). This line fixes it bc on my PP client I killed off the casino/side-bets by deleting the sub-folder, so this prolly only work for people who also deleted the side-bet stuff: WinGet, id, list, %TableType% ahk_pid%pid% ahk_class #32770, , Welcome to the PartyPoker.com Lobby, <font color="red">Click on a hand number to check hand history</font> ;make a list of windows IDs matching ahk_pid/class, excluding the lobby (Not 100% sure if there any way to test for both types of window and ignore them both.) 3. I also changed back the 1::, 2::, 3::, to !1::, !2::, !3::, etc keys after having a bit of a disaster talking in IM at same time as playing [img]/images/graemlins/smirk.gif[/img] Late here too now, but two other cool functions would be these: 1. If press the fold hotkey, then if the check button is visible press this instead (I use this in AutoResizer app, so the key is basically 'check or fold'), but tried the obvious hack and I can't seem to get this to work. [img]/images/graemlins/frown.gif[/img] 2. Sometimes if I open new tables, I lose the GUI bar, just wondered if there could be a quick reload hotkey (was gona try adding, but wasn't sure where to add and worried it would start recursive loading of script... [img]/images/graemlins/smile.gif[/img] ). Also, my theory that the beta crashes only when clicking the mouse is wrong... Mine still crashes when just using the script (but seems to crash less than b4). Overall this script is def the best setup I had yet (very few mis-clicks so far compared to other setups I tried... [img]/images/graemlins/laugh.gif[/img]). Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
[ QUOTE ]
Good stuff. We don't have many posts, but the AHK threads are certainly the longest. [img]/images/graemlins/smile.gif[/img] [/ QUOTE ] That’s for damn sure. [img]/images/graemlins/grin.gif[/img] [ QUOTE ] I stole some of your table-list stuff for another script I'm working on. Hope you don't mind. [/ QUOTE ] Hell no, you’re welcome. Your code has my name on it now too, after all. [img]/images/graemlins/wink.gif[/img] [ QUOTE ] Another thing: in posting stuff on the forum, your code will look prettier if you use the [ code ] [ /code ] brackets. It won't rip-out your indents and stuff. [/ QUOTE ] Maybe it’s just me, but when I copy & paste [ code ] I loose the linefeeds, resulting in one terribly long line. [ QUOTE ] P.S. In Atlanta, the weather channel forecasts "chilly" for some time next week. I'll let you know if it ever happens. [/ QUOTE ] Lol. Apparently the postman had a change of heart - my pad arrived today. |
Re: A script you might like
Hmm… the script assumes the .ini is in A_WorkingDir, the working directory of the script. So both the script and the .ini have to be in the same directory, which is why I said to put the script in a folder somewhere and create a desktop shortcut. Maybe I’m missing something though.
I don’t know how to exclude two windows either , although it can’t be that hard. I use Tigerites script to remove the sidebet crap though, so I’m not gonna try and find a solution unless someone asks me to. Sorry about losing the Alt-key there - I hope you play limit. [img]/images/graemlins/shocked.gif[/img] I think I know what you mean with that Fold/Check thing - that’s when that little window pops up asking if you really want to fold etc…, right? I’ll see what I can do. A quick reload hotkey is a good idea - I’ve had weird stuff happen in other scripts (GUIs loosing their AlwaysOnTop attribute for no apparent reason, or completey disappering) and most times I just can’t tell what’s causing it (I.e. I can’t fix it). So a work-around will be it. |
Re: A script you might like
[ QUOTE ]
Hmm… the script assumes the .ini is in A_WorkingDir, the working directory of the script. So both the script and the .ini have to be in the same directory, which is why I said to put the script in a folder somewhere and create a desktop shortcut. Maybe I’m missing something though. [/ QUOTE ] It was me being sleepy... [img]/images/graemlins/blush.gif[/img] I was just quitting the script by right clicking the system tray, but when I looked at the script in more detail I saw I needed to use the exit function on the menu for the ini to be saved. All ok now [img]/images/graemlins/smile.gif[/img] [ QUOTE ] I don’t know how to exclude two windows either , although it can’t be that hard. I use Tigerites script to remove the sidebet crap though, so I’m not gonna try and find a solution unless someone asks me to. [/ QUOTE ] Same here, so long as party don't force the horrible sidebet thing on us, then it wont effect me either. [img]/images/graemlins/smile.gif[/img] [ QUOTE ] A quick reload hotkey is a good idea - I’ve had weird stuff happen in other scripts (GUIs loosing their AlwaysOnTop attribute for no apparent reason, or completey disappering) and most times I just can’t tell what’s causing it (I.e. I can’t fix it). So a work-around will be it. [/ QUOTE ] It could be something to do with my setup (or me being sleepy last night - like the ini file problem [img]/images/graemlins/smile.gif[/img] ), but after using this quite alot last night it seems that I needed to reload the script each time I closed/re-opened a new table (the GUI bar disappears [a bit like you mention for the quick reload key], but the set to foreground code still works and I can still navigate). Glad you got the joypad at last - it feels a very 'natural' control system for me and found it MUCH easier to adapt to than MTH or my quick fold keys in AutoResizer. Ty again for this! [img]/images/graemlins/smile.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
[ QUOTE ]
I was just quitting the script by right clicking the system tray [/ QUOTE ] Oh, that. That was me being sleepy [img]/images/graemlins/smile.gif[/img] - I had the same problem with another script and never fixed it, my bad. Should have known. [ QUOTE ] It could be something to do with my setup (or me being sleepy last night - like the ini file problem [img]/images/graemlins/smile.gif[/img] ), but after using this quite alot last night it seems that I needed to reload the script each time I closed/re-opened a new table (the GUI bar disappears [a bit like you mention for the quick reload key], but the set to foreground code still works and I can still navigate). [/ QUOTE ] I haven’t had any problems when closing/opening tables, but I’ll look into it. |
Re: A script you might like
Okay, the GUI disappearing was partly due to the NoWrap function not behaving itsself - I think I fixed that.
One other strange thing I don't get is this: When I launch the navigator prior to having any tables open and then open some tables, the GUI won't show when using the joypad; but it will show when using the keyboard. Any ideas? I'd rather post the new version once that's fixed, too. |
Re: A script you might like
I think (but not sure yet), it is something to do with the pseudo-thread 'WatchAxis'.
Not 100% sure how to fix yet, but I think just need some semaphore type flag in the other pseudo-threads. Easier than this might be just try to merge 'WatchAxis' pseudo-thread into one of the other threads (but the timings are very different bc WatchAxis is polling the joypad, so has to be pretty quick. I think 5ms is prolly overkill though [I just used the example from AHK help, and they used 5ms too]). Will post back in a few mins when find which solution works best. Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Hmmm... I seem to be getting the original disappearing GUI type problem, so not sure if this fix might work for you:
It seems possible to have blocking threads if a priority is set [from the 'Threads' help page in AHK: "A hotkey, timed subroutine, or custom menu item with a priority lower than that of the current thread cannot interrupt it."] (in theory the line below should mean WatchAxis can't be called while in another thread as it has lower priority than the default 0): SetTimer, WatchAxis, 5, , -1 ; Again, I not sure if this works or not (it might be worth trying to set the thread priorities for each timer sepeartely - I just permuted all combinations, but no luck [img]/images/graemlins/frown.gif[/img]). Also I tried just moving the WatchAxis code into show_hide thread, but this didn't work either. I think I having a different problem which looks similar (maybe even more severe version of same problem?). [img]/images/graemlins/smile.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Lol. This is the weirdest GUI ever.
First of all, mouseclicks shouldn't be falling through it, right?? I have a working script where I use buttons set to a transparency of 1, nevermind 200. One other thing - the GUI will pop up if you right-click on the tray icon, always. WTF? I can also, make it pop up by using a hotkey that says, "Gui, Show". Using that same command in the hotkeys for up, down, etc. has no effect whatsover though. Talk about AHK tilt [img]/images/graemlins/crazy.gif[/img] This might be the WatchAxis thread, but I don't really see how it can be interfering. The hotkey thread should resume every time the WatchAxis thread finishes. So the Gui, Show command should be executed at some point. I've tried various WinSet commands, but no luck. |
Re: A script you might like
Ah well, work around in order. Just map the !8:: hotkey to a free button on your joypad and you should be fine.
I also found a way to get it to click "Check" instead of fold when needed. The GetTargetNoWrap() function has been updated to sort of simulate the behavior of the original function when needed (kinda like turning wrap on again just for the purpose of finding a target). I hope that works. ;__________________________Table Navigator V4_____________________ ; AutoHotkey Version: 1.0.41.02 ; Platform: WinXP & Win9x/NT (for joypad) ; Author: Roland, SamIAm & jukofyork ; this script now allows the joypad OR alt+cursor keys for navigation, along with joypadbuttons to press F/C/R. IniRead, 3pos_x, TableNavigator.ini, Position, 3pos_x, 0 IniRead, 3pos_y, TableNavigator.ini, Position, 3pos_y, 0 IniRead, wrapping_on, TableNavigator.ini, Wrapping, wrapping_on, 1 IniRead, wrapping_off, TableNavigator.ini, Wrapping, wrapping_off, 0 IniRead, activate_on, TableNavigator.ini, ActivateTarget, activate_on, 1 IniRead, activate_off, TableNavigator.ini, ActivateTarget, activate_off, 0 IniRead, auto_launch, TableNavigator.ini, AutoLaunch, auto_launch, off TableType = Table 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 If auto_launch = yes { 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, 1: Show, w800 h%size_titlebar% x%x% y%y% NoActivate, table_navigator ;show the GUI on table_1 SetTimer, show_hide, 200 SetTimer, WatchAxis, 5 ; ### Juk: Added this for Joyapd control (5ms?). } Gui, 2: +owner +lastfound +alwaysontop Gui, 2: Color, 4F94CD Gui, 2: Font, s30, Comic Sans MS Gui, 2: Add, Text, vText1 cE0FFFF, Table Gui, 2: Add, Text, vText2 cWhite, Navigator WinSet, Transparent, 0 Gui, 2: -Caption Gui, 2: Show, w259 h200 Center GuiControlGet, Text1, 2: Pos, Text1 GuiControlGet, Text2, 2: Pos, Text2 GuiControl, 2: Move, Text1, % "x" (250 - Text1W)/2 GuiControl, 2: Move, Text2, % "x" (250 - Text2W)/2 Loop, 20 { trans += 10 WinSet, Transparent, %trans% Sleep, 50 } Sleep, 500 Loop, 20 { trans -= 10 WinSet, Transparent, %trans% Sleep, 50 } Gui, 2: Destroy Menu, FileMenu, Add, Launch Navigator, LaunchNavigator Menu, FileMenu, Add, Auto-Launch Navigator, AutoLaunchNavigator Menu, FileMenu, Add Menu, FileMenu, Add, Test on Play Money, PlayMoney Menu, FileMenu, Add Menu, FileMenu, Add, Exit, Exit Menu, HelpMenu, Add, Help, Help Menu, MenuBar, Add, File, :FileMenu Menu, MenuBar, Add, Help, :HelpMenu Menu, MenuBar, Color, FFFACD Gui, 3: Menu, MenuBar If auto_launch = yes Menu, FileMenu, Check, Auto-Launch Navigator Menu, Tray, Add, Show, Show Menu, Tray, Default, Show Gui, 3: +owner +lastfound Gui, 3: Color, CDC9A5 Gui, 3: Font, s10, Arial Gui, 3: Add, Text, Section w70 x20 y20, Wrapping: Gui, 3: Add, Radio, ys checked%wrapping_on% gWrapping_on, On Gui, 3: Add, Radio, checked%wrapping_off% gWrapping_off, Off Gui, 3: Add, Text, x20 w70 Section, Activate target: Gui, 3: Add, Radio, ys checked%activate_on% gActivate_on, On Gui, 3: Add, Radio, checked%activate_off% gActivate_off, Off Gui, 3: Show, x%3pos_x% y%3pos_y% w200 h130, Table Navigator ;call Sams functions: ;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") 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 LaunchNavigator: ;do what the original script did in the auto-execute-section (and still does, if auto-launch was selected) Gosub, get_table_list def_t = %table_1% SetTimer, get_table_list, 1000 WinGetPos, x, y, , , ahk_id%def_t% Gui, 1: Show, w800 h%size_titlebar% x%x% y%y% NoActivate, table_navigator SetTimer, show_hide, 200 SetTimer, WatchAxis, 5 ; ### Juk: Added this for Joyapd control (5ms?). return Exit: 3GuiClose: WinGetPos, 3pos_x, 3pos_y, , , Table Navigator Gui, 3: Destroy IniWrite, %3pos_x%, TableNavigator.ini, Position, 3pos_x IniWrite, %3pos_y%, TableNavigator.ini, Position, 3pos_y IniWrite, %wrapping_on%, TableNavigator.ini, Wrapping, wrapping_on IniWrite, %wrapping_off%, TableNavigator.ini, Wrapping, wrapping_off IniWrite, %activate_on%, TableNavigator.ini, ActivateTarget, activate_on IniWrite, %activate_off%, TableNavigator.ini, ActivateTarget, activate_off IniWrite, %auto_launch%, TableNavigator.ini, AutoLaunch, auto_launch ExitApp return 3GuiSize: If ErrorLevel = 1 Gui, 3: Hide return Show: Gui, 3: Restore Gui, 3: Show return Wrapping_on: wrapping_on = 1 wrapping_off = 0 return Wrapping_off: wrapping_off = 1 wrapping_on = 0 return Activate_on: activate_on = 1 activate_off = 0 return Activate_off: activate_off = 1 activate_on = 0 return AutoLaunchNavigator: If auto_launch = no auto_launch = yes else auto_launch = no Menu, FileMenu, ToggleCheck, Auto-Launch Navigator return PlayMoney: If TableType = Play TableType = Table else TableType = Play Menu, FileMenu, ToggleCheck, Test on Play Money return Help: Gui, 4: Color, F5F5DC Gui, 4: Font, s10, Arial Gui, 4: Add, Text, , ( 1. Turning Wrapping off will prevent TN from moving to the next row or column when it has reached the last table in that row or column. 2. Turning "Activate Target" on will cause the table under TN to be activated. This might be especially useful when over-lapping. 3. Selecting "Auto-Launch Navigator" from the File Menu will cause the Navigator to be launched automatically the next time you start TN. 4. If you wish to test TN on play money first, select "Test on Play Money" from the File Menu. ) Gui, 4: Add, Button, vbutton_close_help Center gCloseHelp, Close Gui, 4: Show, autosize Hide, Help GuiControlGet, button_close_help, 4: pos GuiControl, 4: Move, button_close_help, % "x" (334 - button_close_helpW)/2 Gui, 4: Show return CloseHelp: Gui, 4: Destroy return ; ### Juk added this to try to get Joypad working. WatchAxis: GetKeyState, JoyX, JoyX ; Get position of X axis. GetKeyState, JoyY, JoyY ; Get position of Y axis. KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any). if JoyX > 70 KeyToHoldDown = right else if JoyX < 30 KeyToHoldDown = left else if JoyY > 70 KeyToHoldDown = down else if JoyY < 30 KeyToHoldDown = up else KeyToHoldDown = if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down. return ; Do nothing. ; Otherwise, release the previous key and press down the new key: SetKeyDelay -1 ; Avoid delays between keystrokes. if KeyToHoldDown ; There is a key to press down. { If wrapping_on = 1 def_t := GetTargetWrap(KeyToHoldDown) else def_t := GetTargetNoWrap(KeyToHoldDown) WinGetPos, px, py, , , ahk_id%def_t% ;move the GUI to the new de_t Gui, Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% } return ;_________hotkeys: !down:: key = down If wrapping_on = 1 def_t := GetTargetWrap(key) ;pass "key" to the GetTarget function which returns the new def_t else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% ;move the GUI to the new de_t Gui, 1: Show, x0 y0 w800 h30 Gui, 1: Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% WinActivate, table_navigator return !up:: key = up If wrapping_on = 1 def_t := GetTargetWrap(key) else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, 1: Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return !right:: key = right If wrapping_on = 1 def_t := GetTargetWrap(key) else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, 1: Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return !left:: key = left If wrapping_on = 1 def_t := GetTargetWrap(key) else def_t := GetTargetNoWrap(key) WinGetPos, px, py, , , ahk_id%def_t% Gui, 1: Show, w%w% x%px% y%py% NoActivate If activate_on = 1 WinActivate, ahk_id%def_t% return ;Sams hotkeys: <font color="red"> !1:: ControlGetText, check, AfxWnd42s15, ahk_id%def_t% IfInString, check, Check ;this button has the same name as the call button, so we have to check if it actually is a Check-Button { ControlClick, AfxWnd42s15, ahk_id%def_t% check = } else ClickVis(1) return </font> !2:: clickVis(2) return !3:: clickVis(3) return !4:: clickVis(4) return !5:: clickVis(5) return !6:: clickVis(6) return !7:: debug() return <font color="red"> !8:: Gui, 1: Show ;This will restore the GUI if it gets lost return </font> ; ### JUK: Added these to make joypad buttons map to Sam's functions (for my joypad only). Joy3:: ControlGetText, check, AfxWnd42s15, ahk_id%def_t% IfInString, check, Check <font color="red"> ;same as above</font> { ControlClick, AfxWnd42s15, ahk_id%def_t% check = } else ClickVis(1) return Joy1::ClickVis(2) Joy2::ClickVis(3) ;_________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 global TableType WinGet, pid, PID, Welcome to the PartyPoker.com ;retrieves the process ID (using the window title of the lobby) WinGet, id, list, %TableType% 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" } GetTargetWrap(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" } GetTargetNoWrap(key) ;this function returns the new "def_t" when passed "key" { global def_t ;make these two variables global global table_list Loop, 9 { StringTrimRight, table, table_%a_index%, 0 ;acces the array to find out which number the def_t is in the new order If def_t = %table% { table_number = %a_index% break } } <font color="red"> If table_number = ;we need to find a table_number; this isn't perfect, but it does the trick { Loop, Parse, table_list, `, { If a_loopfield <> def_t = %a_loopfield% } } </font> If key = down { If table_number = 1 target = 2 If table_number = 2 target = 3 If table_number = 4 target = 5 If table_number = 5 target = 6 If table_number = 7 target = 8 If table_number = 8 target = 9 } If key = up { If table_number = 9 target = 8 If table_number = 8 target = 7 If table_number = 6 target = 5 If table_number = 5 target = 4 If table_number = 3 target = 2 If table_number = 2 target = 1 } If key = right { If table_number = 1 target = 4 If table_number = 4 target = 7 If table_number = 2 target = 5 If table_number = 5 target = 8 If table_number = 3 target = 6 If table_number = 6 target = 9 } If key = left { If table_number = 9 target = 6 If table_number = 6 target = 3 If table_number = 8 target = 5 If table_number = 5 target = 2 If table_number = 7 target = 4 If table_number = 4 target = 1 } 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" } ;the rest of Sams functions: 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, ahk_id%def_t% 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_____ |
Re: A script you might like
Lol, AHK tilt setting in for me too [img]/images/graemlins/confused.gif[/img]
I have a gut feeling some of this strangeness has to be the psudo-threads (they seem like thread like probs to me...) [img]/images/graemlins/smile.gif[/img] I gona try to get everything in 1 timer and use counters to fix the sepearte delays if needed. Mouseclicks fall through it for me too, but wont fall through for the scripts setting dialog - very strange, but was using this as a feature to be able to click 'X' on the tables. I found making the GUI a bit less wide and offseting it a bit helped avoid this (and using PartyPlanner, so offset avoids overlap with PartyPlanner's tab in the top left): w -= 50 WinSet, Region, w%w% h%size_titlebar% 25-0 %w%-0 %w%-%size_titlebar% 0-%size_titlebar% R20-20, table_navigator Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Im a terrible newbie, but I did tried my best to search, and didn't come to a solution.
- Doest this work with party only? - Do I have to sit at the tables to navigate, or can it be used with observing tables to? - Why do I have to chance play to real $? Neither one seems to work for me. Thanks in advance, .carriermonkey |
Re: A script you might like
[ QUOTE ]
- Doest this work with party only? [/ QUOTE ] Currently, yes. Getting this to work with other sites is can't be a big deal though; the more tedious part is finding the controls to be clicked, since they'll have different names on other sites of course. I believe there are some scripts for other sites around though. If someone could post a link I'd be happy to modify the navigating part (once I've played all those hands I have to play to get the new Party bonus, lol.) [ QUOTE ] - Do I have to sit at the tables to navigate, or can it be used with observing tables to? [/ QUOTE ] You don't have to sit at the table, no. [ QUOTE ] - Why do I have to chance play to real $? Neither one seems to work for me. [/ QUOTE ] Try the latest version; that should work. If it still doesn't, let me know. |
Re: A script you might like
Well to cut a long story short: Tested the new script, added the !8:: options to back button of joypad, everything looked fine, was like "oh yes, can finally play some poker with new setup!", stood up to get a drink ready, tripped over USB wire and broke the [censored] joypad [img]/images/graemlins/mad.gif[/img]
So now I have 1 100% broken USB joypad, and 2 old midi-style ones where the buttons stick and I don't trust em enough for poker [img]/images/graemlins/frown.gif[/img] Oh well, lets just hope I have more luck at the tables [img]/images/graemlins/laugh.gif[/img] On Monday I get a new (hopefully indestructible!) joypad, but until then I will try to put the keyboard command to work. Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Man, you have terrible luck.
I’ve been thinking about what to do with all the free buttons on my joypad; tried this, but no luck: Joy7:: Critical GetBeer, MyFavorite, Cold return [img]/images/graemlins/frown.gif[/img] [img]/images/graemlins/laugh.gif[/img] |
Re: A script you might like
Hehe, just one slight adaption needed for me:
Joy7:: Critical <font color="red">Unplug, USB</font> GetBeer, MyFavorite, Cold return [img]/images/graemlins/smirk.gif[/img] I just opened up the joypad, then put back together and all working again (not a clue why though, but not complaining lol), so maybe my luck changed! [img]/images/graemlins/smile.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
I swear it’s that malicious GUI. First it made you trip over your pad, the it made it work again.
I’m going crazy… I was testing the script and all I did was change a line in one of the hotkeys and now when I try to run it, it tells me the GetTargetWrap() function contains another function, which it absolutely doesn’t. That GUI has supernatural powers. It’s playing with us. [img]/images/graemlins/mad.gif[/img]Gives me the creeps. *shudder* |
Re: A script you might like
My housemate managed to get this to work for a keyboard hotkey:
KBzone3:: Wall, Opposite, MakeHole return You have to hit the keyboard very hard, but it worked. Kayboard still works, too, after he found all the keys. |
Re: A script you might like
[ QUOTE ]
KBzone3:: Wall, Opposite, MakeHole return [/ QUOTE ] This works real good for old ball-mice too! [img]/images/graemlins/grin.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
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] |
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 |
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] |
Re: A script you might like
[ QUOTE ]
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] [/ QUOTE ] Great. Ain't working for me now [img]/images/graemlins/shocked.gif[/img], but I don't get that error unless I reproduce it, so it's cool. [img]/images/graemlins/smile.gif[/img] [ QUOTE ] 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] ). [/ QUOTE ] Strange thing that. I'll play some holdem tomorrow, see if I can find the bug. [ QUOTE ] I will try to look into including Sam's modifiers soon too and see if I can make it totally mouseless. [/ QUOTE ] I have like 10 buttons. How many combinations is that when I use all 10 fingers? [img]/images/graemlins/grin.gif[/img] [ QUOTE ] Not had time yet to try the Deal-in/Deal-out script, [/ QUOTE ] Probably not so good for holdem since you lose $$$ when you have to post the blind again after sitting out. It great for stud though - when I see things are going to get real complicated in a hand I just hit that button and then I can focus and hopefully make some good decision [img]/images/graemlins/laugh.gif[/img]. [ QUOTE ] 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). [/ QUOTE ] ControlGet, OutputVar, Checked (OutputVar is set to 1 if checked, 0 if not), , Control, WinTitle [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
Still working fine and still in love with this script! [img]/images/graemlins/laugh.gif[/img]
I stopped the unpressable fold checkbox thing by just disabling the 'check or fold' stuff (no idea why, but this was the cause of my probs - maybe its just my PC playing up lol). Found I don't use this anyway and still end up pressing check/call rather than check/fold - very few misclicks so far (less than mouse I think!) [img]/images/graemlins/smile.gif[/img] BTW: I adapted the deal-in/deal-out script to make it so that it unchecks "Auto-Post blind" on all windows, which is helpful for me (when I had enough and need a rest from the bad beats etc, but want to finish my rounds off...) [img]/images/graemlins/smile.gif[/img] Not had time to hybridize Sam's mouse-less lobby control yet, but will try and hopefully I can use 'mini-lobby' script too (endless list of projects building up and not enough time... lol) [img]/images/graemlins/smile.gif[/img] Juk [img]/images/graemlins/smile.gif[/img] |
Re: A script you might like
[ QUOTE ]
I stopped the unpressable fold checkbox thing by just disabling the 'check or fold' stuff (no idea why, but this was the cause of my probs - maybe its just my PC playing up lol). Found I don't use this anyway and still end up pressing check/call rather than check/fold - very few misclicks so far (less than mouse I think!) [img]/images/graemlins/smile.gif[/img] [/ QUOTE ] Okay. Haven't had time to really look into it (difficult to fix this stuff when it only comes up every once in a while) and won't if you don't really need it. I don't need it for stud because that check/fold thing almost never comes up (no free flops from the BB). [ QUOTE ] Not had time to hybridize Sam's mouse-less lobby control yet, but will try and hopefully I can use 'mini-lobby' script too (endless list of projects building up and not enough time... lol) [img]/images/graemlins/smile.gif[/img] [/ QUOTE ] I'll can do the lobby control - you better get on with your other projects! [img]/images/graemlins/smile.gif[/img] I was working on it yesterday - the problem is to find a smooth and user-friendly way to handle all the different situations that can come up (no good if you can never remember which button does what [img]/images/graemlins/confused.gif[/img]). I have also pretty much given up on writing something that lets you select a specific open seat via joypad - I have some nice code that highlights a seat but I can't find an easy way to ignore all kinds of other controls with the same name (which are reported as visible even if I can't see them...). I just use brute force now - just have it click every friggin button it can find with that name and then close all the "this seat has already been reserved etc." pop-ups. [img]/images/graemlins/grin.gif[/img] Of course this just takes the first free seat it can find - to select a specific seat you'll have to use the keyboard I guess. Anyway, I hope I can finish this today. |
All times are GMT -4. The time now is 05:46 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.