![]() |
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. |
All times are GMT -4. The time now is 01:18 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.