[UTILITY] AHK Script: Stacked Table Previewer
Thx for code TTR.
I have some AHK experience, but total noob in these thumbnail things.
Is there way to scan pixelcolor in those thumbnail pictures?
Example, if I want to sort out thumbnails where have visible hole cards. What sort of code should I use, or is this even possible?
Or is there API in somewhere? Try to google it, no luck :\
I have some AHK experience, but total noob in these thumbnail things.
Is there way to scan pixelcolor in those thumbnail pictures?
Example, if I want to sort out thumbnails where have visible hole cards. What sort of code should I use, or is this even possible?
Or is there API in somewhere? Try to google it, no luck :\
Should be easy enough to do you just need to get the window type using WindowSpy. I dont have a Microgaming account so unfortunately I cant do it.
Code:
; freo's Stacked Table Previewer v1.16 ; Only works in Vista/Windows7 with aero enabled ; 'clay973' on PS for donations ;Features: ;Shows thumbnails of all stacked tables in a preview window ;Adds and removes tables as they are opened and closed ;Click on the thumbnail to activate the table in the stack ;Click the "Leave Table" icon on Pokerstars thumbnails or the Options/Lobby/Stats icons on FTP thumbnails to leave the table ;this will also click the "are you sure you want to leave?" message box ;Displays number of open tables in the preview window title (in the caption) ;Highlights the active table green in the thumbnail (Color and border width can be changed in the user defined settings) ;Highlights the previous active table pink (Color and border width can be changed in the user defined settings) #SingleInstance Force #NoEnv DetectHiddenWindows,On SetTitleMatchMode, 2 OnMessage(0x201,"clickevent") OnMessage(0x46, "WM_WINDOWPOSCHANGING") ;------------------------------------------------------------------------------------------------------------------ ;User defined settings pokersite=cu ;Pokersite ID - ps for Pokerstars : ft for Full Tilt : cu for customised (you'll need to change cu settings further down) hostwindoww=800 ;Host preview window width hostwindowh=900 ;Host preview window height hostwindowx=800 ;Host preview window x position on screen hostwindowy=0 ;Host preview window y position on screen refreshrate=3000 ;Number of seconds to wait between refreshes (1000 = 1 second) activebordersize=4 ;Width of the colored border for showing active and last active tables activebordercolor=00FF00 ;Color of the highlight border for the active window lactivebordercolor=FF00FF ;Color of the highlight boredr for the last active window ;------------------------------------------------------------------------------------------------------------------ if pokersite = ps { ptablebasew=483 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353) ptablebaseh=353 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353) ;Close settings - On Pokerstars this is the area of the Leave Table icon in the top right of the thumbnail closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh windowtitle=ahk_class PokerStarsTableFrameClass ;Window title to match to find tables - Pokerstars (use window class (ahk_class prefixed)) windowtitleexclude= ;Window title to exclude } else if pokersite = ft { ptablebasew=480 ;Poker table base resolution width ptablebaseh=351 ;Poker table base resolution height ;Close settings - On Full Tilt this is the area of the blue Options/Lobby/Stats icons in the top right of the thumbnail closexl=427 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closexr=478 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyt=22 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyb=52 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh windowtitle= Logged In As ahk_class QWidget ;Window title to match to find tables - (use window class (ahk_class prefixed)) windowtitleexclude=Full Tilt ;Window title to exclude } else if pokersite = cu ;Change these settings for a custom site/application { ptablebasew=800 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353) ptablebaseh=624 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353) closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh windowtitle=ahk_class GFX_INT_DLG_WINDOW_GAME ;Window title to match to find tables - Pokerstars (use control type) windowtitleexclude= ;Window title to exclude }
Somethings I didn't understand was where to get the values for:
closexl=418
closexr=481
closeyt=24
closeyb=42
in Window Spy. Also for title class I used what Window Spy said, but I noticed when you posted the code for Boyle poker you used a screen name, so confused which to use for that field. I tried it with my NordicBet screen name and then also with ahk_class GFX_INT_DLG_WINDOW_GAME, and managed to get the preview window to come up with the tables, but when I click on the tables in the preview window nothing happens, could you point me in the right direction in getting this set up properly?.
Thanks
Somethings I didn't understand was where to get the values for:
closexl=418
closexr=481
closeyt=24
closeyb=42
in Window Spy. Also for title class I used what Window Spy said, but I noticed when you posted the code for Boyle poker you used a screen name, so confused which to use for that field. I tried it with my NordicBet screen name and then also with ahk_class GFX_INT_DLG_WINDOW_GAME, and managed to get the preview window to come up with the tables, but when I click on the tables in the preview window nothing happens, could you point me in the right direction in getting this set up properly?.
Thanks
closexl=418
closexr=481
closeyt=24
closeyb=42
in Window Spy. Also for title class I used what Window Spy said, but I noticed when you posted the code for Boyle poker you used a screen name, so confused which to use for that field. I tried it with my NordicBet screen name and then also with ahk_class GFX_INT_DLG_WINDOW_GAME, and managed to get the preview window to come up with the tables, but when I click on the tables in the preview window nothing happens, could you point me in the right direction in getting this set up properly?.
Thanks
Then hover over the right edge and it will give you the right x coord (closexr)
Then hover over the top edge and it will give you the top y coord (closeyt)
Then hover over the bottom edge and it will give you the bottom y coord (closeyb)
You are basically giving the 4 edges of a box.
In regards to clicking the table to activate, see post 172.
For you query as to using a username instead of window name, you just need to find a combo that picks up the tables but excludes the lobby and other unwanted windows. For memory for Boyle, the active table show the username in the window title but the lobby does not, so I used that to show the active tables but not the lobby. Had I used the window name the lobby would have shown as well as the tables. Each site works differently.
Hello guys, i´m new on this, and i getting trouble on setting the AHK script to work on my pacific poker software ( luckyace poker ).
Heard that Freo was really good on this, so i appreciate some help!!
This is what is happening to me :
http://img10.imageshack.us/img10/5317/semttuloobv.jpg
And this is the code i am using:
Heard that Freo was really good on this, so i appreciate some help!!
This is what is happening to me :
http://img10.imageshack.us/img10/5317/semttuloobv.jpg
And this is the code i am using:
Code:
; freo's Stacked Table Previewer v1.16 ; Only works in Vista/Windows7 with aero enabled ; 'clay973' on PS for donations ;Features: ;Shows thumbnails of all stacked tables in a preview window ;Adds and removes tables as they are opened and closed ;Click on the thumbnail to activate the table in the stack ;Click the "Leave Table" icon on Pokerstars thumbnails or the Options/Lobby/Stats icons on FTP thumbnails to leave the table ;this will also click the "are you sure you want to leave?" message box ;Displays number of open tables in the preview window title (in the caption) ;Highlights the active table green in the thumbnail (Color and border width can be changed in the user defined settings) ;Highlights the previous active table pink (Color and border width can be changed in the user defined settings) #SingleInstance Force #NoEnv DetectHiddenWindows,On SetTitleMatchMode, 2 OnMessage(0x201,"clickevent") OnMessage(0x46, "WM_WINDOWPOSCHANGING") ;------------------------------------------------------------------------------------------------------------------ ;User defined settings pokersite=cu ;Pokersite ID - ps for Pokerstars : ft for Full Tilt : cu for customised (you'll need to change cu settings further down) hostwindoww=800 ;Host preview window width hostwindowh=900 ;Host preview window height hostwindowx=800 ;Host preview window x position on screen hostwindowy=0 ;Host preview window y position on screen refreshrate=3000 ;Number of seconds to wait between refreshes (1000 = 1 second) activebordersize=4 ;Width of the colored border for showing active and last active tables activebordercolor=00FF00 ;Color of the highlight border for the active window lactivebordercolor=FF00FF ;Color of the highlight boredr for the last active window ;------------------------------------------------------------------------------------------------------------------ if pokersite = ps { ptablebasew=483 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353) ptablebaseh=353 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353) ;Close settings - On Pokerstars this is the area of the Leave Table icon in the top right of the thumbnail closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh windowtitle=ahk_class PokerStarsTableFrameClass ;Window title to match to find tables - Pokerstars (use window class (ahk_class prefixed)) windowtitleexclude= ;Window title to exclude } else if pokersite = ft { ptablebasew=480 ;Poker table base resolution width ptablebaseh=351 ;Poker table base resolution height ;Close settings - On Full Tilt this is the area of the blue Options/Lobby/Stats icons in the top right of the thumbnail closexl=427 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closexr=478 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyt=22 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyb=52 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh windowtitle= Logged In As ahk_class QWidget ;Window title to match to find tables - (use window class (ahk_class prefixed)) windowtitleexclude=Full Tilt ;Window title to exclude } else if pokersite = cu ;Change these settings for a custom site/application { ptablebasew=810 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353) ptablebaseh=584 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353) closexl=686 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closexr=718 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyt=8 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh closeyb=26 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh windowtitle=ahk_class #32770 ;Window title to match to find tables - Pokerstars (use control type) windowtitleexclude= ;Window title to exclude } hModule := DllCall("LoadLibrary", "str", "dwmapi.dll") ;Load dwmapi.dll for handling thumbnails SysGet, borderxa, 45 ;Size of the x window 3D border Sysget, borderya, 46 ;Size of the y window 3D border Sysget, captionha, 4 ;Size of the caption Sysget, borderxb, 5 ;Size of the x window normal border Sysget, borderyb, 6 ;Size of the y window normal border borderx := borderxa + borderxb ;Total size of the x border bordery := borderya + borderyb ;Total size of the y border captionh := captionha + bordery ;Total size of the caption clientareah := hostwindowh - bordery - captionh ;Height of the area thumbnail windows can be placed in clientareaw := hostwindoww - borderx - borderx ;Width of the area thumbnail windows can be placed in clientareax := hostwindowx + borderx clientareay := hostwindowy + captionh ptablehwratio := (ptablebaseh-captionha) / ptablebasew ;Ratio used for scaling thumbnail window size lastactive:=0 thisactive:=0 borderguix:=clientareax borderguiy:=clientareay ;Create preview window Gui, 99: +LastFound +LabelForm1_ Gui, 99: Color, 000000 ;WinSet, TransColor, 000000 target := WinExist() ;Test calls ;DLL hook for detecting window activations (for colored active table borders) DllCall( "RegisterShellHookWindow", UInt,target) MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" ) OnMessage( MsgNum, "ShellMessage" ) ;Create GUi's for colored border ;Gui 1 for active table Gui, 1:+LastFound +Owner99 Gui, 1:Color, %activebordercolor% Gui, 1:-Caption -Border activegui:=WinExist() ;Gui 2 for last active table Gui, 2:+LastFound +Owner99 Gui, 2:Color, %lactivebordercolor% Gui, 2:-Caption -Border lactivegui:=WinExist() ;Create Empty variables for storing thumbnail links Loop, 98 { source%A_Index%_hnd:=0 source%A_Index%_thumb:=0 source%A_Index%_wide:=0 } ;Show existing tables WinGet, list, list, %windowtitle%, ,%windowtitleexclude% tblcount:=0 Loop, %list% { tblcount++ tblcount%tblcount%:=list%A_Index% } currentcnt:=tblcount ;Calculate child window size and number per row tablesw := numtablesw(currentcnt) childwinw := Floor(calcwinsize(tablesw, currentcnt)) childwinh := Floor(childwinw * ptablehwratio) ;Create child windows for tables already open Loop, %tblcount% { thisid:=tblcount%A_Index% addchild(A_Index, thisid) } Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, %tblcount% Tables Previewed ;Infinite loop to monitor table opens, closes & resizes. Loop, { Sleep, %refreshrate% wasredrawn:=0 ;Find any closed tables Loop, 98 { thishnd:=source%A_Index%_hnd if (thishnd > 0) { IfWinNotExist, ahk_id %thishnd% { source%A_Index%_hnd:=0 source%A_Index%_thumb:=0 source%A_Index%_wide:=0 } } } ;Get new list of tables WinGet, list, list, %windowtitle%, ,%windowtitleexclude% tblcount:=0 Loop, %list% { tblcount++ tblcount%tblcount%:=list%A_Index% } ;Find any new tables Loop, %tblcount% { thishnd:=tblcount%A_Index% found:=0 Loop,98 { if (source%A_Index%_hnd = thishnd) { found:=1 break } } ;New table found if (found = 0) { ;Find first avail slot newslot:=0 Loop,98 { if (source%A_Index%_hnd = 0) { newslot:=A_Index break } } ;Determine whether an existing slot is available or a recalculation is required as its a new slot. if (newslot <= currentcnt) ;Existing slot taken, no recalc required { addchild(newslot, thishnd) } else ;Need to recalculate to determine if new rows or columns are required { currentcnt += 1 oldcols:=tablesw oldw:=childwinw tablesw := numtablesw(currentcnt) childwinw := Floor(calcwinsize(tablesw, currentcnt)) childwinh := Floor(childwinw * ptablehwratio) if (oldcols = tablesw) and (oldw = childwinw) ;Still a slot left at the end of the current config addchild(newslot, thishnd) else ;Need to redraw all thumbnails with diff config { Loop, 98 { unregisterthumbnail(source%A_Index%_thumb) ;Unregister existing thumbs } Loop, %tblcount% { if(A_Index < tblcount) { thisid:=source%A_Index%_hnd addchild(A_Index, thisid) } else { thisid:=tblcount%A_Index% addchild(A_Index, thishnd) } } wasredrawn:=1 } } } } ;Check if any tables have been resized and if so, redraw if (wasredrawn = 0) { Loop, %tblcount% { retable:=source%A_Index%_hnd WinGetPos,wx,wy,ww,wh,ahk_id %retable% if (ww != source%A_Index%_wide) { unregisterthumbnail(source%A_Index%_thumb) addchild(A_Index, retable) } } } WinSetTitle, ahk_id %target%, ,%tblcount% Tables Previewed } Return ;Function to register the thumbnail to the GUI registerthumbnail(target, source, thumbnum) { Global VarSetCapacity(thumbnail,4,0) hr1:=DllCall("dwmapi\DwmRegisterThumbnail",UInt,target,UInt,source,UInt, &thumbnail) thumbnail:=Numget(thumbnail,0,true) source%thumbnum%_hnd:=source source%thumbnum%_thumb:=thumbnail updatethumbnail(source, thumbnum, thumbnail) } ;Function sets thumbnail properties and displays updatethumbnail(source, thumbnum, thumbnail) { /* DWM_TNP_RECTDESTINATION (0x00000001) Indicates a value for rcDestination has been specified. DWM_TNP_RECTSOURCE (0x00000002) Indicates a value for rcSource has been specified. DWM_TNP_OPACITY (0x00000004) Indicates a value for opacity has been specified. DWM_TNP_VISIBLE (0x00000008) Indicates a value for fVisible has been specified. DWM_TNP_SOURCECLIENTAREAONLY (0x00000010) Indicates a value for fSourceClientAreaOnly has been specified. */ Global dwFlags:=0X1 | 0x2 | 0x10 opacity:=150 fVisible:=1 fSourceClientAreaOnly:=1 ;Determine where to position thumbnail based on its number rownum := Ceil(thumbnum / tablesw) colnum := Mod(thumbnum - 1,tablesw) newx := ((colnum) * childwinw) newy := ((rownum - 1) * childwinh) neww := newx + childwinw newh := newy + childwinh WinGetPos,wx,wy,ww,wh,ahk_id %source% VarSetCapacity(dskThumbProps,45,0) ;struct _DWM_THUMBNAIL_PROPERTIES NumPut(dwFlags,dskThumbProps,0,"UInt") NumPut(newx,dskThumbProps,4,"Int") ;x coord in relation to the target NumPut(newy,dskThumbProps,8,"Int") ;y coord in relation to the target NumPut(neww,dskThumbProps,12,"Int") ;x coord of bottom of the thumb in relation to the target NumPut(newh,dskThumbProps,16,"Int") ;y coord of the right edge of the thumb in relation to the target NumPut(0,dskThumbProps,20,"Int") ;x coord of target to start thumb NumPut(0,dskThumbProps,24,"Int") ;y coord of target to start thumb NumPut(ww-borderx,dskThumbProps,28,"Int") ;width of the thumb in relation to the source NumPut(wh-captionh,dskThumbProps,32,"Int") ;height of the thumb in relation to the source NumPut(opacity,dskThumbProps,36,"UChar") NumPut(fVisible,dskThumbProps,37,"Int") NumPut(fSourceClientAreaOnly,dskThumbProps,41,"Int") hr2:=DllCall("dwmapi\DwmUpdateThumbnailProperties","UInt",thumbnail,"UInt",&dskThumbProps) source%thumbnum%_wide:=ww-(borderx*2) } unregisterthumbnail(unthumbnail) { ur1:=DllCall("dwmapi.dll\DwmUnregisterThumbnail", "UInt", unthumbnail) } ;Function to determine the optimal number of tables wide to show in preview window numtablesw(totaltables) { if(totaltables > "1") { global clientareah global clientareaw global ptablehwratio wsize := 0 wnum := 0 ;The loop value will equal the number of tables per row Loop,%totaltables% { thiswsize := floor(calcwinsize(A_Index, totaltables)) if (thiswsize >= wsize) { wsize := thiswsize wnum := A_Index } } return, %wnum% } Else { return, 1 } } ;Calculates child window size based on number of tables per row calcwinsize(tblperrow, totaltables) { global clientareaw global clientareah global ptablehwratio calcwsize := clientareaw / tblperrow calcrownum := ceil(totaltables / tblperrow) if ((clientareah / calcrownum) < (ptablehwratio * calcwsize)) { calcwsize := (1 / ptablehwratio) * (clientareah / calcrownum) } Return, calcwsize } ;Adds child window to the preview pane addchild(usenum, previewid) { Global childwinw Global childwinh Global hostwindoww Global hostwindowh Global target if (usenum > 0) ;If usenum is 0 it is not part of the initial load of existing windows { registerthumbnail(target, previewid, usenum) Return } } ;Function to determine what happens when a thumbnail is clicked clickevent(wparam) { local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,xr,yt,yb coordmode,mouse,relative mousegetpos,mousex,mousey,id if (id=target) { if(tblcount>0) { ;Calculate slot number thisrow:=Ceil((mousey - captionh) / childwinh) thiscol:=Ceil((mousex - borderx) / childwinw) thisslot:=((thisrow-1)*tablesw)+thiscol getcoords(thisslot,thisrow,thiscol,closexl,closexr,closeyt,closeyb,xl,xr,yt,yb) win:=source%thisslot%_hnd ;Action to take if (mousex>=(xl-1) and mousex<=(xr-1) and mousey>=(yt+1) and mousey<=(yb+1)) ;Close table if pokersite = ps { WinGetTitle, closetitle, ahk_id%win% winclose,ahk_id%win% stringleft,endtitle,closetitle,3 Loop { IfWinNotExist, ahk_id%win% break WinGet,closeID,ID,%endtitle% ahk_class #32770 if (closeID > 0) { WinActivate,ahk_id%closeID% SendInput {Enter} } } } else if pokersite = ft { WinGetTitle, closetitle, ahk_id%win% winclose,ahk_id%win% stringleft,endtitle,closetitle,3 Loop { IfWinNotExist, ahk_id%win% break WinGet,closeID,ID,%endtitle% ahk_class QWidget,,Logged if (closeID > 0) { WinActivate,ahk_id%closeID% SendInput {Tab}{Enter} } } } else { winclose,ahk_id%win% } else { if (win >0) ;Activate the window winactivate,ahk_id%win% } } } } ;Calculates the four coordinates of a rectangle in a thumbnail getcoords(calcslot,thisrow,thiscol,rectxl,rectxr,rectyt,rectyb,ByRef thisxl,ByRef thisxr,ByRef thisyt,ByRef thisyb) { Global ;Calculate coords realw:=source%calcslot%_wide thisx:= ((thiscol-1) * childwinw)+borderx thisy:= ((thisrow - 1) * childwinh)+captionh ;+bordery thisxl:=floor((childwinw*((rectxl-borderx)/(ptablebasew-borderx))) + thisx) thisxr:=floor((childwinw*((rectxr-borderx)/(ptablebasew-borderx))) + thisx) thisyt:=floor((childwinh*((rectyt-captionh)/(ptablebaseh-captionh-bordery))) + thisy) thisyb:=floor((childwinh*((rectyb-captionh)/(ptablebaseh-captionh-bordery))) + thisy) return } ;Function for docking the border gui's to the preview window WM_WINDOWPOSCHANGING(wParam, lParam) { Global captionh,borderx,thisactive,lastactive, borderguix, borderguiy if (A_Gui = 99) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2 { ; Since WM_WINDOWPOSCHANGING happens *before* the window moves, ; we must get the new position from the WINDOWPOS pointed to by lParam. borderguix := NumGet(lParam+8,0,"int") + borderx borderguiy := NumGet(lParam+12,0,"int") + captionh ; Move - but don't activate - Border Gui's If(thisactive>0) Gui, 1:Show, X%borderguix% Y%borderguiy% NA if(lastactive>0) Gui, 2:Show, X%borderguix% Y%borderguiy% NA } } ;Function for detecting window activations for setting border colors ShellMessage( wParam,lParam ) { Global If ((wParam = 4 or wParam = 32772) And WinExist( "ahk_id " lParam )) ; HSHELL_WINDOWACTIVATED = 4, HSHELL_RUDEAPPACTIVATED = 32772 { ;If the activated window is in the list set the active and last active window matchcnt:=0 Loop, 98 { matchcnt++ if(source%matchcnt%_hnd = lParam) break } if (matchcnt < 98 and thisactive != lParam) { ;Set and display active table border gui's drawborder(1,matchcnt) lastactive:=thisactive thisactive:=lParam if(lastactive > 0) { matchcnt:=0 Loop, 98 { matchcnt++ if(source%matchcnt%_hnd = lastactive) break } drawborder(2,matchcnt) } } } } drawborder(guinum, slotnumb) { Global ;Get the thumbnail outer edge coords thisrow:=Ceil(slotnumb/tablesw) thiscol:=Mod(slotnumb - 1,tablesw)+1 getcoords(slotnumb,thisrow,thiscol,borderx,ptablebasew-borderx,captionh,ptablebaseh-bordery,xl,xr,yt,yb) if(guinum=1) thisgui:=activegui else thisgui:=lactivegui xl-=borderx xr-=borderx yt-=captionh yb-=captionh xli:=xl+activebordersize xri:=xr-activebordersize yti:=yt+activebordersize ybi:=yb-activebordersize neww:=xr-xl newh:=yb-yt ;Draw the border gui WinSet, Region, %xl%-%yt% %xr%-%yt% %xr%-%yb% %xl%-%yb% %xl%-%yt% %xli%-%yti% %xri%-%yti% %xri%-%ybi% %xli%-%ybi% %xli%-%yti%, ahk_id %thisgui% Gui, %guinum%:Show, x%borderguix% y%borderguiy% W%hostwindoww% H%hostwindowh% NA } Form1_Close: ExitApp return
If you can screendump the window title of an active table and the lobby I might be able to make a suggestion. I dont have any accounts on 888 network so cant do it myself.
Thanks for the help, gonna try it
Hi,
What should I modify to set the background to black?
thanks
What should I modify to set the background to black?
thanks
Is there a way to make the fold/call/raise buttons clickable directly from the preview?
Thanks in adavance.
Thanks in adavance.
Max Cut
Have a look at post 137. Looks like someone made just that, but I don't know how it all worked out and if it's still compatible with any changes since then.
Trying to set this up to work on merge, how do i work out what to put for the windowtitle option?
that is "-", don't forget it or you will get other flash windows from the lobby in there
If you want to exclude the lobby from the preview, just put something from the lobby title in the windowtitleexclude setting. i.e. Carbon Poker, your username, etc.
Just discovered this script. Sooooo much I can do here. Great job OP, I'll post up anything interesting I come up with.
Max Cut
popcorn.gif
Max Cut
For anyone interested in previewing a combination of Merge and Revolution tables, the following changes worked for me.
- change (about line 19)Code:
SetTitleMatchMode, 2
Code:SetTitleMatchMode, RegEx
- change (about line 74, in the "else if pokersite = cu" section)Code:
windowtitle=- ahk_class SWT_Window0
Code:windowtitle=^(`#[0-9]+.* - Table [0-9]+ - .*)|(Tournament: [0-9]+ Buy-In .* : Table.*)
Hi guys,
I'm new here, sorry if I ask something, that was posted 1000 times before...
I use the stacked table previewer on Stars and it works perfect, so I wanted to use it on Winner Poker, too.
Winner Poker belongs to the ipoker network, so I use the "freo's Stacked Table Previewer v1.16 for ipoker" version.
I changed the following line:
windowtitle= nightflier (my nickname)
But the preview windows stays black....
If I leave the line blank....I can see 1000things in the window, so I guess that the problem is to type the correct table name. So I tried different things, but nothing works!
So, I hope that you guys could help me!
What can I do or try?
Thanks!!
I'm new here, sorry if I ask something, that was posted 1000 times before...
I use the stacked table previewer on Stars and it works perfect, so I wanted to use it on Winner Poker, too.
Winner Poker belongs to the ipoker network, so I use the "freo's Stacked Table Previewer v1.16 for ipoker" version.
I changed the following line:
windowtitle= nightflier (my nickname)
But the preview windows stays black....
If I leave the line blank....I can see 1000things in the window, so I guess that the problem is to type the correct table name. So I tried different things, but nothing works!
So, I hope that you guys could help me!
What can I do or try?
Thanks!!
Hi Guys,
Is there a way to implement border coloring the tables themselves. So not in the preview window ?
Is there a way to implement border coloring the tables themselves. So not in the preview window ?
If you want the ordinary poker table window to have a border there is this script I found a while ago.
OP, this is excellent. The only downside imo is that tables do not resize to small when you go from, say, playing 12 tables to only playing 6.
Also the tables seem to be smaller than they need to be in the preview window, for example:
I don't mean the gap at the bottom, just the gaps between tables. How can I change this?
OP, this is excellent. The only downside imo is that tables do not resize to small when you go from, say, playing 12 tables to only playing 6.
Also the tables seem to be smaller than they need to be in the preview window, for example:
I don't mean the gap at the bottom, just the gaps between tables. How can I change this?
Is it possible to move around the tile tables? For example if you are heads up and the table is on the bottom line to drag it in the first line?
Bump, made a custom settings for the HEM note windows but as in my last post itt just above it doesn't show the window borders for the HEM notes which means I can't see the names. Anyone got any ideas? I have fiddled with table ratio but that didn't do anything.
I tried this and it is great. thanks a lot!!!
after using it, I was wondering if it is possible to preview ONLY part of the tables, i.e., the area showing your hole cards, stack size, actions (check/fold, time bank activated or not), instead of the whole table. This is because the preview got really small when I have many tables, and it's hard to see the important things like your hole cards.
after using it, I was wondering if it is possible to preview ONLY part of the tables, i.e., the area showing your hole cards, stack size, actions (check/fold, time bank activated or not), instead of the whole table. This is because the preview got really small when I have many tables, and it's hard to see the important things like your hole cards.
hey there, using that atm for stars. once full tilt is back i wanna play both sites and have preview for both. i post my actual code here. if somebody can edit it that it works for stars and FT simulataneously i would be willing to pay some cash. just drop me a pm if u r my man and we can go into detail, thanks:
Spoiler:
; freo's Stacked Table Previewer v1.11
; Only works in Vista/Windows7 with aero enabled
; 'clay973' on PS for donations
;Features:
;Shows thumbnails of all stacked tables in a preview window
;Adds and removes tables as they are opened and closed
;Click on the thumbnail to activate the table in the stack
;Click the "Leave Table" icon on Pokerstars thumbnails or the Options/Lobby/Stats icons on FTP thumbnails to leave the table
;Displays number of open tables in the preview window title (in the caption)
;Highlights the active table green in the thumbnail (Color and border width can be changed in the user defined settings)
;Highlights the previous active table pink (Color and border width can be changed in the user defined settings)
#SingleInstance Force
#NoEnv
DetectHiddenWindows,On
SetTitleMatchMode, 2
OnMessage(0x201,"clickevent")
OnMessage(0x46, "WM_WINDOWPOSCHANGING")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
pokersite=ps ;Pokersite ID - ps for Pokerstars : ft for Full Tilt : cu for customised (you'll need to change cu settings further down)
hostwindoww=760 ;Host preview window width
hostwindowh=1150 ;Host preview window height
hostwindowx=0 ;Host preview window x position on screen
hostwindowy=0 ;Host preview window y position on screen
refreshrate=3000 ;Number of seconds to wait between refreshes (1000 = 1 second)
activebordersize=4 ;Width of the colored border for showing active and last active tables
activebordercolor=00FF00 ;Color of the highlight border for the active window
lactivebordercolor=FF00FF ;Color of the highlight boredr for the last active window
;------------------------------------------------------------------------------------------------------------------
if pokersite = ps
{
ptablebasew=483 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353)
ptablebaseh=353 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353)
;Close settings - On Pokerstars this is the area of the Leave Table icon in the top right of the thumbnail
closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
windowtitle=ahk_class PokerStarsTableFrameClass ;Window title to match to find tables - Pokerstars (use window class (ahk_class prefixed))
windowtitleexclude= ;Window title to exclude
}
else if pokersite = ft
{
ptablebasew=480 ;Poker table base resolution width
ptablebaseh=351 ;Poker table base resolution height
;Close settings - On Full Tilt this is the area of the blue Options/Lobby/Stats icons in the top right of the thumbnail
closexl=427 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closexr=478 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyt=22 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyb=52 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
windowtitle=Logged In ahk_class QWidget ;Window title to match to find tables - (use window class (ahk_class prefixed))
windowtitleexclude=Full Tilt ;Window title to exclude
}
else if pokersite = cu ;Change these settings for a custom site/application
{
ptablebasew=483 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353)
ptablebaseh=353 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353)
closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
windowtitle=My win ahk_class AutoHotkeyGUI ;Window title to match to find tables - Pokerstars (use control type)
windowtitleexclude= ;Window title to exclude
}
hModule := DllCall("LoadLibrary", "str", "dwmapi.dll") ;Load dwmapi.dll for handling thumbnails
SysGet, borderxa, 45 ;Size of the x window 3D border
Sysget, borderya, 46 ;Size of the y window 3D border
Sysget, captionha, 4 ;Size of the caption
Sysget, borderxb, 5 ;Size of the x window normal border
Sysget, borderyb, 6 ;Size of the y window normal border
borderx := borderxa + borderxb ;Total size of the x border
bordery := borderya + borderyb ;Total size of the y border
captionh := captionha + bordery ;Total size of the caption
clientareah := hostwindowh - bordery - captionh ;Height of the area thumbnail windows can be placed in
clientareaw := hostwindoww - borderx - borderx ;Width of the area thumbnail windows can be placed in
clientareax := hostwindowx + borderx
clientareay := hostwindowy + captionh
ptablehwratio := (ptablebaseh-captionha) / ptablebasew ;Ratio used for scaling thumbnail window size
lastactive:=0
thisactive:=0
borderguix:=clientareax
borderguiy:=clientareay
;Create preview window
Gui, 99: +LastFound +LabelForm1_
target := WinExist()
;Test calls
;DLL hook for detecting window activations (for colored active table borders)
DllCall( "RegisterShellHookWindow", UInt,target)
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
;Create GUi's for colored border
;Gui 1 for active table
Gui, 1:+LastFound +Owner99
Gui, 1:Color, %activebordercolor%
Gui, 1:-Caption -Border
activegui:=WinExist()
;Gui 2 for last active table
Gui, 2:+LastFound +Owner99
Gui, 2:Color, %lactivebordercolor%
Gui, 2:-Caption -Border
lactivegui:=WinExist()
;Create Empty variables for storing thumbnail links
Loop, 98
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
;Show existing tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
currentcnt:=tblcount
;Calculate child window size and number per row
tablesw := numtablesw(currentcnt)
childwinw := Floor(calcwinsize(tablesw, currentcnt))
childwinh := Floor(childwinw * ptablehwratio)
;Create child windows for tables already open
Loop, %tblcount%
{
thisid:=tblcount%A_Index%
addchild(A_Index, thisid)
}
Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, %tblcount% Tables Previewed
;Infinite loop to monitor table opens, closes & resizes.
Loop,
{
Sleep, %refreshrate%
wasredrawn:=0
;Find any closed tables
Loop, 98
{
thishnd:=source%A_Index%_hnd
if (thishnd > 0)
{
IfWinNotExist, ahk_id %thishnd%
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
}
}
;Get new list of tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
;Find any new tables
Loop, %tblcount%
{
thishnd:=tblcount%A_Index%
found:=0
Loop,98
{
if (source%A_Index%_hnd = thishnd)
{
found:=1
break
}
}
;New table found
if (found = 0)
{
;Find first avail slot
newslot:=0
Loop,98
{
if (source%A_Index%_hnd = 0)
{
newslot:=A_Index
break
}
}
;Determine whether an existing slot is available or a recalculation is required as its a new slot.
if (newslot <= currentcnt) ;Existing slot taken, no recalc required
{
addchild(newslot, thishnd)
}
else ;Need to recalculate to determine if new rows or columns are required
{
currentcnt += 1
oldcols:=tablesw
oldw:=childwinw
tablesw := numtablesw(currentcnt)
childwinw := Floor(calcwinsize(tablesw, currentcnt))
childwinh := Floor(childwinw * ptablehwratio)
if (oldcols = tablesw) and (oldw = childwinw) ;Still a slot left at the end of the current config
addchild(newslot, thishnd)
else ;Need to redraw all thumbnails with diff config
{
Loop, 98
{
unregisterthumbnail(source%A_Index%_thumb) ;Unregister existing thumbs
}
Loop, %tblcount%
{
if(A_Index < tblcount)
{
thisid:=source%A_Index%_hnd
addchild(A_Index, thisid)
}
else
{
thisid:=tblcount%A_Index%
addchild(A_Index, thishnd)
}
}
wasredrawn:=1
}
}
}
}
;Check if any tables have been resized and if so, redraw
if (wasredrawn = 0)
{
Loop, %tblcount%
{
retable:=source%A_Index%_hnd
WinGetPos,wx,wy,ww,wh,ahk_id %retable%
if (ww != source%A_Index%_wide)
{
unregisterthumbnail(source%A_Index%_thumb)
addchild(A_Index, retable)
}
}
}
WinSetTitle, ahk_id %target%, ,%tblcount% Tables Previewed
}
Return
;Function to register the thumbnail to the GUI
registerthumbnail(target, source, thumbnum)
{
Global
VarSetCapacity(thumbnail,4,0)
hr1:=DllCall("dwmapi\DwmRegisterThumbnail",UInt,ta rget,UInt,source,UInt, &thumbnail)
thumbnail:=Numget(thumbnail,0,true)
source%thumbnum%_hnd:=source
source%thumbnum%_thumb:=thumbnail
updatethumbnail(source, thumbnum, thumbnail)
}
;Function sets thumbnail properties and displays
updatethumbnail(source, thumbnum, thumbnail)
{
/*
DWM_TNP_RECTDESTINATION (0x00000001)
Indicates a value for rcDestination has been specified.
DWM_TNP_RECTSOURCE (0x00000002)
Indicates a value for rcSource has been specified.
DWM_TNP_OPACITY (0x00000004)
Indicates a value for opacity has been specified.
DWM_TNP_VISIBLE (0x00000008)
Indicates a value for fVisible has been specified.
DWM_TNP_SOURCECLIENTAREAONLY (0x00000010)
Indicates a value for fSourceClientAreaOnly has been specified.
*/
Global
dwFlags:=0X1 | 0x2 | 0x10
opacity:=150
fVisible:=1
fSourceClientAreaOnly:=1
;Determine where to position thumbnail based on its number
rownum := Ceil(thumbnum / tablesw)
colnum := Mod(thumbnum - 1,tablesw)
newx := ((colnum) * childwinw)
newy := ((rownum - 1) * childwinh)
neww := newx + childwinw
newh := newy + childwinh
WinGetPos,wx,wy,ww,wh,ahk_id %source%
VarSetCapacity(dskThumbProps,45,0)
;struct _DWM_THUMBNAIL_PROPERTIES
NumPut(dwFlags,dskThumbProps,0,"UInt")
NumPut(newx,dskThumbProps,4,"Int") ;x coord in relation to the target
NumPut(newy,dskThumbProps,8,"Int") ;y coord in relation to the target
NumPut(neww,dskThumbProps,12,"Int") ;x coord of bottom of the thumb in relation to the target
NumPut(newh,dskThumbProps,16,"Int") ;y coord of the right edge of the thumb in relation to the target
NumPut(0,dskThumbProps,20,"Int") ;x coord of target to start thumb
NumPut(0,dskThumbProps,24,"Int") ;y coord of target to start thumb
NumPut(ww-borderx,dskThumbProps,28,"Int") ;width of the thumb in relation to the source
NumPut(wh-captionh,dskThumbProps,32,"Int") ;height of the thumb in relation to the source
NumPut(opacity,dskThumbProps,36,"UChar")
NumPut(fVisible,dskThumbProps,37,"Int")
NumPut(fSourceClientAreaOnly,dskThumbProps,41,"Int ")
hr2:=DllCall("dwmapi\DwmUpdateThumbnailProperties" ,"UInt",thumbnail,"UInt",&dskThumbProps)
source%thumbnum%_wide:=ww-(borderx*2)
}
unregisterthumbnail(unthumbnail)
{
ur1:=DllCall("dwmapi.dll\DwmUnregisterThumbnail", "UInt", unthumbnail)
}
;Function to determine the optimal number of tables wide to show in preview window
numtablesw(totaltables)
{
if(totaltables > "1")
{
global clientareah
global clientareaw
global ptablehwratio
wsize := 0
wnum := 0
;The loop value will equal the number of tables per row
Loop,%totaltables%
{
thiswsize := floor(calcwinsize(A_Index, totaltables))
if (thiswsize >= wsize)
{
wsize := thiswsize
wnum := A_Index
}
}
return, %wnum%
}
Else
{
return, 1
}
}
;Calculates child window size based on number of tables per row
calcwinsize(tblperrow, totaltables)
{
global clientareaw
global clientareah
global ptablehwratio
calcwsize := clientareaw / tblperrow
calcrownum := ceil(totaltables / tblperrow)
if ((clientareah / calcrownum) < (ptablehwratio * calcwsize))
{
calcwsize := (1 / ptablehwratio) * (clientareah / calcrownum)
}
Return, calcwsize
}
;Adds child window to the preview pane
addchild(usenum, previewid)
{
Global childwinw
Global childwinh
Global hostwindoww
Global hostwindowh
Global target
if (usenum > 0) ;If usenum is 0 it is not part of the initial load of existing windows
{
registerthumbnail(target, previewid, usenum)
Return
}
}
;Function to determine what happens when a thumbnail is clicked
clickevent(wparam)
{
local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,x r,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
;Calculate slot number
thisrow:=Ceil((mousey - captionh) / childwinh)
thiscol:=Ceil((mousex - borderx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
getcoords(thisslot,thisrow,thiscol,closexl,closexr ,closeyt,closeyb,xl,xr,yt,yb)
win:=source%thisslot%_hnd
;Action to take
if (mousex>=(xl-1) and mousex<=(xr-1) and mousey>=(yt+1) and mousey<=(yb+1)) ;Close table
winclose,ahk_id%win%
else
{
if (win >0) ;Activate the window
winactivate,ahk_id%win%
}
}
}
;Calculates the four coordinates of a rectangle in a thumbnail
getcoords(calcslot,thisrow,thiscol,rectxl,rectxr,r ectyt,rectyb,ByRef thisxl,ByRef thisxr,ByRef thisyt,ByRef thisyb)
{
Global
;Calculate coords
realw:=source%calcslot%_wide
thisx:= ((thiscol-1) * childwinw)+borderx
thisy:= ((thisrow - 1) * childwinh)+captionh ;+bordery
thisxl:=floor((childwinw*((rectxl-borderx)/(ptablebasew-borderx))) + thisx)
thisxr:=floor((childwinw*((rectxr-borderx)/(ptablebasew-borderx))) + thisx)
thisyt:=floor((childwinh*((rectyt-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
thisyb:=floor((childwinh*((rectyb-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
return
}
;Function for docking the border gui's to the preview window
WM_WINDOWPOSCHANGING(wParam, lParam)
{
Global captionh,borderx,thisactive,lastactive, borderguix, borderguiy
if (A_Gui = 99) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
; Since WM_WINDOWPOSCHANGING happens *before* the window moves,
; we must get the new position from the WINDOWPOS pointed to by lParam.
borderguix := NumGet(lParam+8,0,"int") + borderx
borderguiy := NumGet(lParam+12,0,"int") + captionh
; Move - but don't activate - Border Gui's
If(thisactive>0)
Gui, 1:Show, X%borderguix% Y%borderguiy% NA
if(lastactive>0)
Gui, 2:Show, X%borderguix% Y%borderguiy% NA
}
}
;Function for detecting window activations for setting border colors
ShellMessage( wParam,lParam )
{
Global
If ((wParam = 4 or wParam = 32772) And WinExist( "ahk_id " lParam )) ; HSHELL_WINDOWACTIVATED = 4, HSHELL_RUDEAPPACTIVATED = 32772
{
;If the activated window is in the list set the active and last active window
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lParam)
break
}
if (matchcnt < 98 and thisactive != lParam)
{
;Set and display active table border gui's
drawborder(1,matchcnt)
lastactive:=thisactive
thisactive:=lParam
if(lastactive > 0)
{
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lastactive)
break
}
drawborder(2,matchcnt)
}
}
}
}
drawborder(guinum, slotnumb)
{
Global
;Get the thumbnail outer edge coords
thisrow:=Ceil(slotnumb/tablesw)
thiscol:=Mod(slotnumb - 1,tablesw)+1
getcoords(slotnumb,thisrow,thiscol,borderx,ptableb asew-borderx,captionh,ptablebaseh-bordery,xl,xr,yt,yb)
if(guinum=1)
thisgui:=activegui
else
thisgui:=lactivegui
xl-=borderx
xr-=borderx
yt-=captionh
yb-=captionh
xli:=xl+activebordersize
xri:=xr-activebordersize
yti:=yt+activebordersize
ybi:=yb-activebordersize
neww:=xr-xl
newh:=yb-yt
;Draw the border gui
WinSet, Region, %xl%-%yt% %xr%-%yt% %xr%-%yb% %xl%-%yb% %xl%-%yt% %xli%-%yti% %xri%-%yti% %xri%-%ybi% %xli%-%ybi% %xli%-%yti%, ahk_id %thisgui%
Gui, %guinum%:Show, x%borderguix% y%borderguiy% W%hostwindoww% H%hostwindowh% NA
}
Form1_Close:
ExitApp
return
; Only works in Vista/Windows7 with aero enabled
; 'clay973' on PS for donations
;Features:
;Shows thumbnails of all stacked tables in a preview window
;Adds and removes tables as they are opened and closed
;Click on the thumbnail to activate the table in the stack
;Click the "Leave Table" icon on Pokerstars thumbnails or the Options/Lobby/Stats icons on FTP thumbnails to leave the table
;Displays number of open tables in the preview window title (in the caption)
;Highlights the active table green in the thumbnail (Color and border width can be changed in the user defined settings)
;Highlights the previous active table pink (Color and border width can be changed in the user defined settings)
#SingleInstance Force
#NoEnv
DetectHiddenWindows,On
SetTitleMatchMode, 2
OnMessage(0x201,"clickevent")
OnMessage(0x46, "WM_WINDOWPOSCHANGING")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
pokersite=ps ;Pokersite ID - ps for Pokerstars : ft for Full Tilt : cu for customised (you'll need to change cu settings further down)
hostwindoww=760 ;Host preview window width
hostwindowh=1150 ;Host preview window height
hostwindowx=0 ;Host preview window x position on screen
hostwindowy=0 ;Host preview window y position on screen
refreshrate=3000 ;Number of seconds to wait between refreshes (1000 = 1 second)
activebordersize=4 ;Width of the colored border for showing active and last active tables
activebordercolor=00FF00 ;Color of the highlight border for the active window
lactivebordercolor=FF00FF ;Color of the highlight boredr for the last active window
;------------------------------------------------------------------------------------------------------------------
if pokersite = ps
{
ptablebasew=483 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353)
ptablebaseh=353 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353)
;Close settings - On Pokerstars this is the area of the Leave Table icon in the top right of the thumbnail
closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
windowtitle=ahk_class PokerStarsTableFrameClass ;Window title to match to find tables - Pokerstars (use window class (ahk_class prefixed))
windowtitleexclude= ;Window title to exclude
}
else if pokersite = ft
{
ptablebasew=480 ;Poker table base resolution width
ptablebaseh=351 ;Poker table base resolution height
;Close settings - On Full Tilt this is the area of the blue Options/Lobby/Stats icons in the top right of the thumbnail
closexl=427 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closexr=478 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyt=22 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyb=52 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
windowtitle=Logged In ahk_class QWidget ;Window title to match to find tables - (use window class (ahk_class prefixed))
windowtitleexclude=Full Tilt ;Window title to exclude
}
else if pokersite = cu ;Change these settings for a custom site/application
{
ptablebasew=483 ;Poker table base resolution width(For stars this is the smallest table resolution (483 x 353)
ptablebaseh=353 ;Poker table base resolution height(For stars this is the smallest table resolution (483 x 353)
closexl=418 ;Left x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closexr=481 ;Right x position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyt=24 ;Top y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
closeyb=42 ;Bottom y position of leave table button in relation to the resolution set against ptablebasew & ptablebaseh
windowtitle=My win ahk_class AutoHotkeyGUI ;Window title to match to find tables - Pokerstars (use control type)
windowtitleexclude= ;Window title to exclude
}
hModule := DllCall("LoadLibrary", "str", "dwmapi.dll") ;Load dwmapi.dll for handling thumbnails
SysGet, borderxa, 45 ;Size of the x window 3D border
Sysget, borderya, 46 ;Size of the y window 3D border
Sysget, captionha, 4 ;Size of the caption
Sysget, borderxb, 5 ;Size of the x window normal border
Sysget, borderyb, 6 ;Size of the y window normal border
borderx := borderxa + borderxb ;Total size of the x border
bordery := borderya + borderyb ;Total size of the y border
captionh := captionha + bordery ;Total size of the caption
clientareah := hostwindowh - bordery - captionh ;Height of the area thumbnail windows can be placed in
clientareaw := hostwindoww - borderx - borderx ;Width of the area thumbnail windows can be placed in
clientareax := hostwindowx + borderx
clientareay := hostwindowy + captionh
ptablehwratio := (ptablebaseh-captionha) / ptablebasew ;Ratio used for scaling thumbnail window size
lastactive:=0
thisactive:=0
borderguix:=clientareax
borderguiy:=clientareay
;Create preview window
Gui, 99: +LastFound +LabelForm1_
target := WinExist()
;Test calls
;DLL hook for detecting window activations (for colored active table borders)
DllCall( "RegisterShellHookWindow", UInt,target)
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
;Create GUi's for colored border
;Gui 1 for active table
Gui, 1:+LastFound +Owner99
Gui, 1:Color, %activebordercolor%
Gui, 1:-Caption -Border
activegui:=WinExist()
;Gui 2 for last active table
Gui, 2:+LastFound +Owner99
Gui, 2:Color, %lactivebordercolor%
Gui, 2:-Caption -Border
lactivegui:=WinExist()
;Create Empty variables for storing thumbnail links
Loop, 98
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
;Show existing tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
currentcnt:=tblcount
;Calculate child window size and number per row
tablesw := numtablesw(currentcnt)
childwinw := Floor(calcwinsize(tablesw, currentcnt))
childwinh := Floor(childwinw * ptablehwratio)
;Create child windows for tables already open
Loop, %tblcount%
{
thisid:=tblcount%A_Index%
addchild(A_Index, thisid)
}
Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, %tblcount% Tables Previewed
;Infinite loop to monitor table opens, closes & resizes.
Loop,
{
Sleep, %refreshrate%
wasredrawn:=0
;Find any closed tables
Loop, 98
{
thishnd:=source%A_Index%_hnd
if (thishnd > 0)
{
IfWinNotExist, ahk_id %thishnd%
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
}
}
;Get new list of tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
;Find any new tables
Loop, %tblcount%
{
thishnd:=tblcount%A_Index%
found:=0
Loop,98
{
if (source%A_Index%_hnd = thishnd)
{
found:=1
break
}
}
;New table found
if (found = 0)
{
;Find first avail slot
newslot:=0
Loop,98
{
if (source%A_Index%_hnd = 0)
{
newslot:=A_Index
break
}
}
;Determine whether an existing slot is available or a recalculation is required as its a new slot.
if (newslot <= currentcnt) ;Existing slot taken, no recalc required
{
addchild(newslot, thishnd)
}
else ;Need to recalculate to determine if new rows or columns are required
{
currentcnt += 1
oldcols:=tablesw
oldw:=childwinw
tablesw := numtablesw(currentcnt)
childwinw := Floor(calcwinsize(tablesw, currentcnt))
childwinh := Floor(childwinw * ptablehwratio)
if (oldcols = tablesw) and (oldw = childwinw) ;Still a slot left at the end of the current config
addchild(newslot, thishnd)
else ;Need to redraw all thumbnails with diff config
{
Loop, 98
{
unregisterthumbnail(source%A_Index%_thumb) ;Unregister existing thumbs
}
Loop, %tblcount%
{
if(A_Index < tblcount)
{
thisid:=source%A_Index%_hnd
addchild(A_Index, thisid)
}
else
{
thisid:=tblcount%A_Index%
addchild(A_Index, thishnd)
}
}
wasredrawn:=1
}
}
}
}
;Check if any tables have been resized and if so, redraw
if (wasredrawn = 0)
{
Loop, %tblcount%
{
retable:=source%A_Index%_hnd
WinGetPos,wx,wy,ww,wh,ahk_id %retable%
if (ww != source%A_Index%_wide)
{
unregisterthumbnail(source%A_Index%_thumb)
addchild(A_Index, retable)
}
}
}
WinSetTitle, ahk_id %target%, ,%tblcount% Tables Previewed
}
Return
;Function to register the thumbnail to the GUI
registerthumbnail(target, source, thumbnum)
{
Global
VarSetCapacity(thumbnail,4,0)
hr1:=DllCall("dwmapi\DwmRegisterThumbnail",UInt,ta rget,UInt,source,UInt, &thumbnail)
thumbnail:=Numget(thumbnail,0,true)
source%thumbnum%_hnd:=source
source%thumbnum%_thumb:=thumbnail
updatethumbnail(source, thumbnum, thumbnail)
}
;Function sets thumbnail properties and displays
updatethumbnail(source, thumbnum, thumbnail)
{
/*
DWM_TNP_RECTDESTINATION (0x00000001)
Indicates a value for rcDestination has been specified.
DWM_TNP_RECTSOURCE (0x00000002)
Indicates a value for rcSource has been specified.
DWM_TNP_OPACITY (0x00000004)
Indicates a value for opacity has been specified.
DWM_TNP_VISIBLE (0x00000008)
Indicates a value for fVisible has been specified.
DWM_TNP_SOURCECLIENTAREAONLY (0x00000010)
Indicates a value for fSourceClientAreaOnly has been specified.
*/
Global
dwFlags:=0X1 | 0x2 | 0x10
opacity:=150
fVisible:=1
fSourceClientAreaOnly:=1
;Determine where to position thumbnail based on its number
rownum := Ceil(thumbnum / tablesw)
colnum := Mod(thumbnum - 1,tablesw)
newx := ((colnum) * childwinw)
newy := ((rownum - 1) * childwinh)
neww := newx + childwinw
newh := newy + childwinh
WinGetPos,wx,wy,ww,wh,ahk_id %source%
VarSetCapacity(dskThumbProps,45,0)
;struct _DWM_THUMBNAIL_PROPERTIES
NumPut(dwFlags,dskThumbProps,0,"UInt")
NumPut(newx,dskThumbProps,4,"Int") ;x coord in relation to the target
NumPut(newy,dskThumbProps,8,"Int") ;y coord in relation to the target
NumPut(neww,dskThumbProps,12,"Int") ;x coord of bottom of the thumb in relation to the target
NumPut(newh,dskThumbProps,16,"Int") ;y coord of the right edge of the thumb in relation to the target
NumPut(0,dskThumbProps,20,"Int") ;x coord of target to start thumb
NumPut(0,dskThumbProps,24,"Int") ;y coord of target to start thumb
NumPut(ww-borderx,dskThumbProps,28,"Int") ;width of the thumb in relation to the source
NumPut(wh-captionh,dskThumbProps,32,"Int") ;height of the thumb in relation to the source
NumPut(opacity,dskThumbProps,36,"UChar")
NumPut(fVisible,dskThumbProps,37,"Int")
NumPut(fSourceClientAreaOnly,dskThumbProps,41,"Int ")
hr2:=DllCall("dwmapi\DwmUpdateThumbnailProperties" ,"UInt",thumbnail,"UInt",&dskThumbProps)
source%thumbnum%_wide:=ww-(borderx*2)
}
unregisterthumbnail(unthumbnail)
{
ur1:=DllCall("dwmapi.dll\DwmUnregisterThumbnail", "UInt", unthumbnail)
}
;Function to determine the optimal number of tables wide to show in preview window
numtablesw(totaltables)
{
if(totaltables > "1")
{
global clientareah
global clientareaw
global ptablehwratio
wsize := 0
wnum := 0
;The loop value will equal the number of tables per row
Loop,%totaltables%
{
thiswsize := floor(calcwinsize(A_Index, totaltables))
if (thiswsize >= wsize)
{
wsize := thiswsize
wnum := A_Index
}
}
return, %wnum%
}
Else
{
return, 1
}
}
;Calculates child window size based on number of tables per row
calcwinsize(tblperrow, totaltables)
{
global clientareaw
global clientareah
global ptablehwratio
calcwsize := clientareaw / tblperrow
calcrownum := ceil(totaltables / tblperrow)
if ((clientareah / calcrownum) < (ptablehwratio * calcwsize))
{
calcwsize := (1 / ptablehwratio) * (clientareah / calcrownum)
}
Return, calcwsize
}
;Adds child window to the preview pane
addchild(usenum, previewid)
{
Global childwinw
Global childwinh
Global hostwindoww
Global hostwindowh
Global target
if (usenum > 0) ;If usenum is 0 it is not part of the initial load of existing windows
{
registerthumbnail(target, previewid, usenum)
Return
}
}
;Function to determine what happens when a thumbnail is clicked
clickevent(wparam)
{
local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,x r,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
;Calculate slot number
thisrow:=Ceil((mousey - captionh) / childwinh)
thiscol:=Ceil((mousex - borderx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
getcoords(thisslot,thisrow,thiscol,closexl,closexr ,closeyt,closeyb,xl,xr,yt,yb)
win:=source%thisslot%_hnd
;Action to take
if (mousex>=(xl-1) and mousex<=(xr-1) and mousey>=(yt+1) and mousey<=(yb+1)) ;Close table
winclose,ahk_id%win%
else
{
if (win >0) ;Activate the window
winactivate,ahk_id%win%
}
}
}
;Calculates the four coordinates of a rectangle in a thumbnail
getcoords(calcslot,thisrow,thiscol,rectxl,rectxr,r ectyt,rectyb,ByRef thisxl,ByRef thisxr,ByRef thisyt,ByRef thisyb)
{
Global
;Calculate coords
realw:=source%calcslot%_wide
thisx:= ((thiscol-1) * childwinw)+borderx
thisy:= ((thisrow - 1) * childwinh)+captionh ;+bordery
thisxl:=floor((childwinw*((rectxl-borderx)/(ptablebasew-borderx))) + thisx)
thisxr:=floor((childwinw*((rectxr-borderx)/(ptablebasew-borderx))) + thisx)
thisyt:=floor((childwinh*((rectyt-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
thisyb:=floor((childwinh*((rectyb-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
return
}
;Function for docking the border gui's to the preview window
WM_WINDOWPOSCHANGING(wParam, lParam)
{
Global captionh,borderx,thisactive,lastactive, borderguix, borderguiy
if (A_Gui = 99) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
; Since WM_WINDOWPOSCHANGING happens *before* the window moves,
; we must get the new position from the WINDOWPOS pointed to by lParam.
borderguix := NumGet(lParam+8,0,"int") + borderx
borderguiy := NumGet(lParam+12,0,"int") + captionh
; Move - but don't activate - Border Gui's
If(thisactive>0)
Gui, 1:Show, X%borderguix% Y%borderguiy% NA
if(lastactive>0)
Gui, 2:Show, X%borderguix% Y%borderguiy% NA
}
}
;Function for detecting window activations for setting border colors
ShellMessage( wParam,lParam )
{
Global
If ((wParam = 4 or wParam = 32772) And WinExist( "ahk_id " lParam )) ; HSHELL_WINDOWACTIVATED = 4, HSHELL_RUDEAPPACTIVATED = 32772
{
;If the activated window is in the list set the active and last active window
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lParam)
break
}
if (matchcnt < 98 and thisactive != lParam)
{
;Set and display active table border gui's
drawborder(1,matchcnt)
lastactive:=thisactive
thisactive:=lParam
if(lastactive > 0)
{
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lastactive)
break
}
drawborder(2,matchcnt)
}
}
}
}
drawborder(guinum, slotnumb)
{
Global
;Get the thumbnail outer edge coords
thisrow:=Ceil(slotnumb/tablesw)
thiscol:=Mod(slotnumb - 1,tablesw)+1
getcoords(slotnumb,thisrow,thiscol,borderx,ptableb asew-borderx,captionh,ptablebaseh-bordery,xl,xr,yt,yb)
if(guinum=1)
thisgui:=activegui
else
thisgui:=lactivegui
xl-=borderx
xr-=borderx
yt-=captionh
yb-=captionh
xli:=xl+activebordersize
xri:=xr-activebordersize
yti:=yt+activebordersize
ybi:=yb-activebordersize
neww:=xr-xl
newh:=yb-yt
;Draw the border gui
WinSet, Region, %xl%-%yt% %xr%-%yt% %xr%-%yb% %xl%-%yb% %xl%-%yt% %xli%-%yti% %xri%-%yti% %xri%-%ybi% %xli%-%ybi% %xli%-%yti%, ahk_id %thisgui%
Gui, %guinum%:Show, x%borderguix% y%borderguiy% W%hostwindoww% H%hostwindowh% NA
}
Form1_Close:
ExitApp
return
Can't believe I haven't started to use this before sooo good! Thank you!
I think I've read that it was possible to config the script so it's possible to click fold in the preview window. Is that right? For the version I got I can click the top right red x to close tables. Also; is there a "refresh" button available? For when I go from eg. 8 tables to 4.
i tried to edit this script for ipoker and it seems to work..
you can change Rearrangetablesafterclosedwindow to 1 if you want update the previewer constantly.
right click to prew window sends fold.
if the active table is waiting for action, as soon as you make your action it will bring up next table waiting for action. this will need to set up correct ActionColor:=0x... to work for pixelsearch. do anyone have ideas how to do autositback and autoregister? tried couple of ways but nothing seems to work. sorry about ugly code.
#SingleInstance Force
#NoEnv
DetectHiddenWindows,On
SetTitleMatchMode, 2
OnMessage(0x201,"Lclickevent")
OnMessage(0x207,"Mclickevent")
OnMessage(0x204,"Rclickevent")
OnMessage(0x46, "WM_WINDOWPOSCHANGING")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
hostwindoww=450 ;Host preview window width
hostwindowh=800 ;Host preview window height
hostwindowx=800 ;Host preview window x position on screen
hostwindowy=0 ;Host preview window y position on screen
refreshrateStack=1000 ;Number of seconds to wait between refreshes (1000 = 1 second)
refreshrateTablesearch= 1000
activebordersize=1 ;Width of the colored border for showing active and last active tables
activebordercolor=aaaaff ;Color of the highlight border for the active window
lactivebordercolor=3333ff ;Color of the highlight boredr for the last active window
Rearrangetablesafterclosedwindow := 0
;------------------------------------------------------------------------------------------------------------------
ptablebasew=814 ;Poker table base resolution width
ptablebaseh=614 ;Poker table base resolution height
windowtitle= yournickname ;Window title to match to find tables
windowtitleexclude= Poker ;Window title to exclude
ActionColor:=0x628200
ActionX:=444/814
ActionY:=544/614
FoldX:=460/814
FoldY:=593/614
hModule := DllCall("LoadLibrary", "str", "dwmapi.dll") ;Load dwmapi.dll for handling thumbnails
SysGet, borderxa, 45 ;Size of the x window 3D border
Sysget, borderya, 46 ;Size of the y window 3D border
Sysget, captionha, 4 ;Size of the caption
Sysget, borderxb, 5 ;Size of the x window normal border
Sysget, borderyb, 6 ;Size of the y window normal border
borderx := borderxa + borderxb ;Total size of the x border
bordery := borderya + borderyb ;Total size of the y border
captionh := captionha + bordery ;Total size of the caption
clientareah := hostwindowh - bordery - captionh ;Height of the area thumbnail windows can be placed in
clientareaw := hostwindoww - borderx - borderx ;Width of the area thumbnail windows can be placed in
clientareax := hostwindowx + borderx
clientareay := hostwindowy + captionh
ptablehwratio := (ptablebaseh-captionha) / ptablebasew ;Ratio used for scaling thumbnail window size
lastactive:=0
thisactive:=0
borderguix:=clientareax
borderguiy:=clientareay
;Create preview window
Gui, 99: +LastFound +LabelForm1_
Gui, 99: Color, 000000
;WinSet, TransColor, 000000
target := WinExist()
;Test calls
;DLL hook for detecting window activations (for colored active table borders)
DllCall( "RegisterShellHookWindow", UInt,target)
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
;Create GUi's for colored border
;Gui 1 for active table
Gui, 1:+LastFound +Owner99
Gui, 1:Color, %activebordercolor%
Gui, 1:-Caption -Border
activegui:=WinExist()
;Gui 2 for last active table
Gui, 2:+LastFound +Owner99
Gui, 2:Color, %lactivebordercolor%
Gui, 2:-Caption -Border
lactivegui:=WinExist()
;Create Empty variables for storing thumbnail links
Loop, 98
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
;Show existing tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
currentcnt:=tblcount
;Calculate child window size and number per row
tablesw := numtablesw(tblcount)
childwinw := Floor(calcwinsize(tablesw, tblcount))
childwinh := Floor(childwinw * ptablehwratio)
;Create child windows for tables already open
Loop, %tblcount%
{
thisid:=tblcount%A_Index%
addchild(A_Index, thisid)
}
Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, %tblcount% Tables Previewed
settimer StackPreviewer, %RefreshrateStack%
settimer TableSearch, %RefreshrateTableSearch%
return
esc::
exitapp
StackPreviewer:
closedfound:=0
wasredrawn:=0
;Find any closed tables
Loop, 98
{
thishnd:=source%A_Index%_hnd
if (thishnd > 0)
{
IfWinNotExist, ahk_id %thishnd%
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
closedfound = 1
}
}
}
if closedfound
{
if Rearrangetablesafterclosedwindow
{
Loop, 98 ;Unregister existing thumbs
{
unregisterthumbnail(source%A_Index%_thumb)
}
Loop, 98 ;Create Empty variables for storing thumbnail links
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
;Show existing tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
;Calculate child window size and number per row
tablesw := numtablesw(tblcount)
childwinw := Floor(calcwinsize(tablesw, tblcount))
childwinh := Floor(childwinw * ptablehwratio)
;Create child windows for tables already open
Loop, %tblcount%
{
thisid:=tblcount%A_Index%
addchild(A_Index, thisid)
}
currentcnt:=tblcount
return
}
wasredrawn = 1
}
;Get new list of tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
;Find any new tables
Loop, %tblcount%
{
thishnd:=tblcount%A_Index%
found:=0
Loop,98
{
if (source%A_Index%_hnd = thishnd)
{
found:=1
break
}
}
if (found = 0)
{
;Find first avail slot
newslot:=0
Loop,98
{
if (source%A_Index%_hnd = 0)
{
newslot:=A_Index
break
}
}
;Determine whether an existing slot is available or a recalculation is required as its a new slot.
if (newslot <= currentcnt) ;Existing slot taken, no recalc required
{
addchild(newslot, thishnd)
}
else ;Need to recalculate to determine if new rows or columns are required
{
currentcnt += 1
oldcols:=tablesw
oldw:=childwinw
tablesw := numtablesw(currentcnt)
childwinw := Floor(calcwinsize(tablesw, currentcnt))
childwinh := Floor(childwinw * ptablehwratio)
if (oldcols = tablesw) and (oldw = childwinw) ;Still a slot left at the end of the current config
addchild(newslot, thishnd)
else
{
Loop, 98
{
unregisterthumbnail(source%A_Index%_thumb) ;Unregister existing thumbs
}
Loop, %tblcount%
{
if(A_Index < tblcount)
{
thisid:=source%A_Index%_hnd
addchild(A_Index, thisid)
}
else
{
thisid:=tblcount%A_Index%
addchild(A_Index, thishnd)
}
wasredrawn:=1
}
}
}
}
}
if wasredrawn = 0 ;Check if any tables have been resized and if so, redraw
{
Loop, %tblcount%
{
retable:=source%A_Index%_hnd
WinGetPos,wx,wy,ww,wh,ahk_id %retable%
if (ww != source%A_Index%_wide)
{
unregisterthumbnail(source%A_Index%_thumb)
addchild(A_Index, retable)
}
}
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = thisactive)
break
}
drawborder(1,matchcnt)
if(lastactive > 0)
{
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lastactive)
break
}
drawborder(2,matchcnt)
}
}
WinSetTitle, ahk_id %target%, ,%tblcount% Tables Previewed
Return
;Function to register the thumbnail to the GUI
registerthumbnail(target, source, thumbnum)
{
Global
VarSetCapacity(thumbnail,4,0)
hr1:=DllCall("dwmapi\DwmRegisterThumbnail",UInt,ta rget,UInt,source,UInt, &thumbnail)
thumbnail:=Numget(thumbnail,0,true)
source%thumbnum%_hnd:=source
source%thumbnum%_thumb:=thumbnail
updatethumbnail(source, thumbnum, thumbnail)
}
;Function sets thumbnail properties and displays
updatethumbnail(source, thumbnum, thumbnail)
{
/*
DWM_TNP_RECTDESTINATION (0x00000001)
Indicates a value for rcDestination has been specified.
DWM_TNP_RECTSOURCE (0x00000002)
Indicates a value for rcSource has been specified.
DWM_TNP_OPACITY (0x00000004)
Indicates a value for opacity has been specified.
DWM_TNP_VISIBLE (0x00000008)
Indicates a value for fVisible has been specified.
DWM_TNP_SOURCECLIENTAREAONLY (0x00000010)
Indicates a value for fSourceClientAreaOnly has been specified.
*/
Global
dwFlags:=0X1 | 0x2 | 0x10
opacity:=150
fVisible:=1
fSourceClientAreaOnly:=1
;Determine where to position thumbnail based on its number
rownum := Ceil(thumbnum / tablesw)
colnum := Mod(thumbnum - 1,tablesw)
newx := ((colnum) * childwinw)
newy := ((rownum - 1) * childwinh)
neww := newx + childwinw
newh := newy + childwinh
WinGetPos,wx,wy,ww,wh,ahk_id %source%
VarSetCapacity(dskThumbProps,45,0)
;struct _DWM_THUMBNAIL_PROPERTIES
NumPut(dwFlags,dskThumbProps,0,"UInt")
NumPut(newx,dskThumbProps,4,"Int") ;x coord in relation to the target
NumPut(newy,dskThumbProps,8,"Int") ;y coord in relation to the target
NumPut(neww,dskThumbProps,12,"Int") ;x coord of bottom of the thumb in relation to the target
NumPut(newh,dskThumbProps,16,"Int") ;y coord of the right edge of the thumb in relation to the target
NumPut(0,dskThumbProps,20,"Int") ;x coord of target to start thumb
NumPut(0,dskThumbProps,24,"Int") ;y coord of target to start thumb
NumPut(ww-borderx,dskThumbProps,28,"Int") ;width of the thumb in relation to the source
NumPut(wh-captionh,dskThumbProps,32,"Int") ;height of the thumb in relation to the source
NumPut(opacity,dskThumbProps,36,"UChar")
NumPut(fVisible,dskThumbProps,37,"Int")
NumPut(fSourceClientAreaOnly,dskThumbProps,41,"Int ")
hr2:=DllCall("dwmapi\DwmUpdateThumbnailProperties" ,"UInt",thumbnail,"UInt",&dskThumbProps)
source%thumbnum%_wide:=ww-(borderx*2)
}
unregisterthumbnail(unthumbnail)
{
ur1:=DllCall("dwmapi.dll\DwmUnregisterThumbnail", "UInt", unthumbnail)
}
;Function to determine the optimal number of tables wide to show in preview window
numtablesw(totaltables)
{
if(totaltables > "1")
{
global clientareah
global clientareaw
global ptablehwratio
wsize := 0
wnum := 0
;The loop value will equal the number of tables per row
Loop,%totaltables%
{
thiswsize := floor(calcwinsize(A_Index, totaltables))
if (thiswsize >= wsize)
{
wsize := thiswsize
wnum := A_Index
}
}
return, %wnum%
}
Else
{
return, 1
}
}
;Calculates child window size based on number of tables per row
calcwinsize(tblperrow, totaltables)
{
global clientareaw
global clientareah
global ptablehwratio
calcwsize := clientareaw / tblperrow
calcrownum := ceil(totaltables / tblperrow)
if ((clientareah / calcrownum) < (ptablehwratio * calcwsize))
{
calcwsize := (1 / ptablehwratio) * (clientareah / calcrownum)
}
Return, calcwsize
}
;Adds child window to the preview pane
addchild(usenum, previewid)
{
Global childwinw
Global childwinh
Global hostwindoww
Global hostwindowh
Global target
if (usenum > 0) ;If usenum is 0 it is not part of the initial load of existing windows
{
registerthumbnail(target, previewid, usenum)
Return
}
}
;Function to determine what happens when a thumbnail is clicked
Lclickevent(wparam)
{
local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,x r,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
if(tblcount>0)
{
;Calculate slot number
thisrow:=Ceil((mousey - captionh) / childwinh)
thiscol:=Ceil((mousex - borderx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
;getcoords(thisslot,thisrow,thiscol,closexl,closex r,closeyt,closeyb,xl,xr,yt,yb)
win:=source%thisslot%_hnd
winactivate,ahk_id%win%
}
}
}
Mclickevent(wparam)
{
msgbox middle
}
Rclickevent(wparam)
{
local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,x r,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
if(tblcount>0)
{
;Calculate slot number
thisrow:=Ceil((mousey - captionh) / childwinh)
thiscol:=Ceil((mousex - borderx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
win:=source%thisslot%_hnd
pix:=PixelColorA(ActionX,ActionY,win)
if (comparecolors(ActionColor,pix,16)=1)
{ ;send fold
getcoordinates(ActionX, ActionY, win)
controlclick, x%pixel_x% y%pixel_y%, ahk_id%win%,,,,NA
}
else
{
getcoordinates(FoldX, FoldY, win)
controlclick, x%pixel_x% y%pixel_y%, ahk_id%win%,,,,NA
}
}
}
}
;Calculates the four coordinates of a rectangle in a thumbnail
getcoords(calcslot,thisrow,thiscol,rectxl,rectxr,r ectyt,rectyb,ByRef thisxl,ByRef thisxr,ByRef thisyt,ByRef thisyb)
{
Global
;Calculate coords
realw:=source%calcslot%_wide
thisx:= ((thiscol-1) * childwinw)+borderx
thisy:= ((thisrow - 1) * childwinh)+captionh ;+bordery
thisxl:=floor((childwinw*((rectxl-borderx)/(ptablebasew-borderx))) + thisx)
thisxr:=floor((childwinw*((rectxr-borderx)/(ptablebasew-borderx))) + thisx)
thisyt:=floor((childwinh*((rectyt-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
thisyb:=floor((childwinh*((rectyb-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
return
}
; Patch fab12 Begin
getcoordsinv(calcslot,thisrow,thiscol,tablew,table h,rectx,recty,ByRef thisx,ByRef thisy)
{
Global
;Calculate coords
realw:=source%calcslot%_wide
thisx:= ((thiscol-1) * childwinw)+borderx
thisy:= ((thisrow - 1) * childwinh)+captionh
thisx:=(rectx-thisx)*tablew/childwinw
thisy:=(recty-thisy)*tableh/childwinh
return
}
; Patch fab12 End
;Function for docking the border gui's to the preview window
WM_WINDOWPOSCHANGING(wParam, lParam)
{
Global captionh,borderx,thisactive,lastactive, borderguix, borderguiy
if (A_Gui = 99) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
; Since WM_WINDOWPOSCHANGING happens *before* the window moves,
; we must get the new position from the WINDOWPOS pointed to by lParam.
borderguix := NumGet(lParam+8,0,"int") + borderx
borderguiy := NumGet(lParam+12,0,"int") + captionh
; Move - but don't activate - Border Gui's
If(thisactive>0)
Gui, 1:Show, X%borderguix% Y%borderguiy% NA
if(lastactive>0)
Gui, 2:Show, X%borderguix% Y%borderguiy% NA
}
}
;Function for detecting window activations for setting border colors
ShellMessage( wParam,lParam )
{
Global
If ((wParam = 4 or wParam = 32772) And WinExist( "ahk_id " lParam )) ; HSHELL_WINDOWACTIVATED = 4, HSHELL_RUDEAPPACTIVATED = 32772
{
;If the activated window is in the list set the active and last active window
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lParam)
break
}
if (matchcnt < 98 and thisactive != lParam)
{
;Set and display active table border gui's
drawborder(1,matchcnt)
lastactive:=thisactive
thisactive:=lParam
lastactive2:=thisactive
if(lastactive > 0)
{
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lastactive)
break
}
drawborder(2,matchcnt)
}
}
}
}
drawborder(guinum, slotnumb)
{
Global
;Get the thumbnail outer edge coords
thisrow:=Ceil(slotnumb/tablesw)
thiscol:=Mod(slotnumb - 1,tablesw)+1
getcoords(slotnumb,thisrow,thiscol,borderx,ptableb asew-borderx,captionh,ptablebaseh-bordery,xl,xr,yt,yb)
if(guinum=1)
thisgui:=activegui
else
thisgui:=lactivegui
xl-=borderx
xr-=borderx
yt-=captionh
yb-=captionh
xli:=xl+activebordersize
xri:=xr-activebordersize
yti:=yt+activebordersize
ybi:=yb-activebordersize
neww:=xr-xl
newh:=yb-yt
;Draw the border gui
WinSet, Region, %xl%-%yt% %xr%-%yt% %xr%-%yb% %xl%-%yb% %xl%-%yt% %xli%-%yti% %xri%-%yti% %xri%-%ybi% %xli%-%ybi% %xli%-%yti%, ahk_id %thisgui%
Gui, %guinum%:Show, x%borderguix% y%borderguiy% W%hostwindoww% H%hostwindowh% NA
}
Form1_Close:
ExitApp
return
TableSearch:
;StartTime:=A_TickCount
WinGet, listst, List, %windowtitle%,, Poker
Loop, %listst%
{
win:=listst%A_index%
pix:=PixelColorA(ActionX,ActionY,win)
if (comparecolors(ActionColor,pix,16)=1)
{
MouseGetPos, , currentwindow
WinGetClass, class, ahk_id %currentwindow%
if class <> PTIODEVICE
return
pix:=PixelColorA(ActionX,ActionY,currentwindow)
if (comparecolors(ActionColor,pix,16)=1)
return
WinActivate, ahk_id %win%
}
}
;ElapsedTime:=A_TickCount - StartTime
return
PixelColorA(colxa,colya,id)
{
critical ;speed up
global borderx,bordery,captionh
DllCall("dwmapi\DwmIsCompositionEnabled","int*",Dw mIsEnabled)
if DwmIsEnabled
{
hdc_buffer := DllCall("GetDCEx", "UInt", id,"UInt",0,"UInt",1)
}
else
{
hdc_frame := DllCall( "GetDC", "UInt", id)
hdc_buffer := DllCall("gdi32.dll\CreateCompatibleDC", "UInt", hdc_frame)
WinGetPos, X, Y, W, H, ahk_id %id%
hbm_buffer := CreateDIBSection(hdc_frame, w, h)
DllCall( "gdi32.dll\SelectObject", UInt,hdc_buffer, UInt,hbm_buffer)
DllCall( "PrintWindow", "UInt" , id , "UInt" , hdc_buffer , "UInt" , 0 )
DllCall("RedrawWindow",uint,id,uint,0,uint,0,uint, 1|16|32|128|256|1024) ; with all children windows
}
WinGetPos, X, Y, W, H, ahk_id %id%
w := w - (2*borderx)
h := h - (2*bordery) - captionh
;msgbox %x% %y% %w% %h%
Transform, X, Floor, W*colxa
Transform, Y, Floor, H*colya
pixel_x := x + borderx
pixel_y := y + bordery + captionh
pix := DllCall("GetPixel", "UInt", hdc_buffer, "Int", pixel_x , "Int", pixel_y)
SetFormat, IntegerFast, hex
pix += 0 ; Sets Var (which previously contained 11) to be 0xb.
pix .= "" ; Necessary due to the "fast" mode.
SetFormat, IntegerFast, d
DllCall( "gdi32.dll\DeleteObject", "uint", hbm_buffer )
DllCall( "gdi32.dll\ReleaseDC" , "uint", hdc_frame )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_frame )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_buffer )
return pix
}
CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "") {
NumPut(VarSetCapacity(bi, 40, 0), bi)
NumPut(nW, bi, 4)
NumPut(nH, bi, 8)
NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
NumPut(0, bi,16)
Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}
CompareColors(ByRef bgr1, ByRef bgr2, ByRef variation) {
c1 := bgr1 & 0xff
c2 := bgr2 & 0xff
if (abs(c1 - c2) > variation)
return false
c1 := (bgr1 >> 8) & 0xff
c2 := (bgr2 >> 8) & 0xff
if (abs(c1 - c2) > variation)
return false
c1 := (bgr1 >> 16) & 0xff
c2 := (bgr2 >> 16) & 0xff
if (abs(c1 - c2) > variation)
return false
return true
}
getcoordinates(pixelx,pixely,id)
{
global
WinGetPos, X, Y, W, H, ahk_id %id%
w := w - (2*borderx)
h := h - (2*bordery) - captionh
;msgbox %x% %y% %w% %h%
Transform, X, Floor, W*pixelx
Transform, Y, Floor, H*pixely
pixel_x := x + borderx
pixel_y := y + bordery + captionh
}
you can change Rearrangetablesafterclosedwindow to 1 if you want update the previewer constantly.
right click to prew window sends fold.
if the active table is waiting for action, as soon as you make your action it will bring up next table waiting for action. this will need to set up correct ActionColor:=0x... to work for pixelsearch. do anyone have ideas how to do autositback and autoregister? tried couple of ways but nothing seems to work. sorry about ugly code.
Spoiler:
#SingleInstance Force
#NoEnv
DetectHiddenWindows,On
SetTitleMatchMode, 2
OnMessage(0x201,"Lclickevent")
OnMessage(0x207,"Mclickevent")
OnMessage(0x204,"Rclickevent")
OnMessage(0x46, "WM_WINDOWPOSCHANGING")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
hostwindoww=450 ;Host preview window width
hostwindowh=800 ;Host preview window height
hostwindowx=800 ;Host preview window x position on screen
hostwindowy=0 ;Host preview window y position on screen
refreshrateStack=1000 ;Number of seconds to wait between refreshes (1000 = 1 second)
refreshrateTablesearch= 1000
activebordersize=1 ;Width of the colored border for showing active and last active tables
activebordercolor=aaaaff ;Color of the highlight border for the active window
lactivebordercolor=3333ff ;Color of the highlight boredr for the last active window
Rearrangetablesafterclosedwindow := 0
;------------------------------------------------------------------------------------------------------------------
ptablebasew=814 ;Poker table base resolution width
ptablebaseh=614 ;Poker table base resolution height
windowtitle= yournickname ;Window title to match to find tables
windowtitleexclude= Poker ;Window title to exclude
ActionColor:=0x628200
ActionX:=444/814
ActionY:=544/614
FoldX:=460/814
FoldY:=593/614
hModule := DllCall("LoadLibrary", "str", "dwmapi.dll") ;Load dwmapi.dll for handling thumbnails
SysGet, borderxa, 45 ;Size of the x window 3D border
Sysget, borderya, 46 ;Size of the y window 3D border
Sysget, captionha, 4 ;Size of the caption
Sysget, borderxb, 5 ;Size of the x window normal border
Sysget, borderyb, 6 ;Size of the y window normal border
borderx := borderxa + borderxb ;Total size of the x border
bordery := borderya + borderyb ;Total size of the y border
captionh := captionha + bordery ;Total size of the caption
clientareah := hostwindowh - bordery - captionh ;Height of the area thumbnail windows can be placed in
clientareaw := hostwindoww - borderx - borderx ;Width of the area thumbnail windows can be placed in
clientareax := hostwindowx + borderx
clientareay := hostwindowy + captionh
ptablehwratio := (ptablebaseh-captionha) / ptablebasew ;Ratio used for scaling thumbnail window size
lastactive:=0
thisactive:=0
borderguix:=clientareax
borderguiy:=clientareay
;Create preview window
Gui, 99: +LastFound +LabelForm1_
Gui, 99: Color, 000000
;WinSet, TransColor, 000000
target := WinExist()
;Test calls
;DLL hook for detecting window activations (for colored active table borders)
DllCall( "RegisterShellHookWindow", UInt,target)
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
;Create GUi's for colored border
;Gui 1 for active table
Gui, 1:+LastFound +Owner99
Gui, 1:Color, %activebordercolor%
Gui, 1:-Caption -Border
activegui:=WinExist()
;Gui 2 for last active table
Gui, 2:+LastFound +Owner99
Gui, 2:Color, %lactivebordercolor%
Gui, 2:-Caption -Border
lactivegui:=WinExist()
;Create Empty variables for storing thumbnail links
Loop, 98
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
;Show existing tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
currentcnt:=tblcount
;Calculate child window size and number per row
tablesw := numtablesw(tblcount)
childwinw := Floor(calcwinsize(tablesw, tblcount))
childwinh := Floor(childwinw * ptablehwratio)
;Create child windows for tables already open
Loop, %tblcount%
{
thisid:=tblcount%A_Index%
addchild(A_Index, thisid)
}
Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, %tblcount% Tables Previewed
settimer StackPreviewer, %RefreshrateStack%
settimer TableSearch, %RefreshrateTableSearch%
return
esc::
exitapp
StackPreviewer:
closedfound:=0
wasredrawn:=0
;Find any closed tables
Loop, 98
{
thishnd:=source%A_Index%_hnd
if (thishnd > 0)
{
IfWinNotExist, ahk_id %thishnd%
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
closedfound = 1
}
}
}
if closedfound
{
if Rearrangetablesafterclosedwindow
{
Loop, 98 ;Unregister existing thumbs
{
unregisterthumbnail(source%A_Index%_thumb)
}
Loop, 98 ;Create Empty variables for storing thumbnail links
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
}
;Show existing tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
;Calculate child window size and number per row
tablesw := numtablesw(tblcount)
childwinw := Floor(calcwinsize(tablesw, tblcount))
childwinh := Floor(childwinw * ptablehwratio)
;Create child windows for tables already open
Loop, %tblcount%
{
thisid:=tblcount%A_Index%
addchild(A_Index, thisid)
}
currentcnt:=tblcount
return
}
wasredrawn = 1
}
;Get new list of tables
WinGet, list, list, %windowtitle%, ,%windowtitleexclude%
tblcount:=0
Loop, %list%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
;Find any new tables
Loop, %tblcount%
{
thishnd:=tblcount%A_Index%
found:=0
Loop,98
{
if (source%A_Index%_hnd = thishnd)
{
found:=1
break
}
}
if (found = 0)
{
;Find first avail slot
newslot:=0
Loop,98
{
if (source%A_Index%_hnd = 0)
{
newslot:=A_Index
break
}
}
;Determine whether an existing slot is available or a recalculation is required as its a new slot.
if (newslot <= currentcnt) ;Existing slot taken, no recalc required
{
addchild(newslot, thishnd)
}
else ;Need to recalculate to determine if new rows or columns are required
{
currentcnt += 1
oldcols:=tablesw
oldw:=childwinw
tablesw := numtablesw(currentcnt)
childwinw := Floor(calcwinsize(tablesw, currentcnt))
childwinh := Floor(childwinw * ptablehwratio)
if (oldcols = tablesw) and (oldw = childwinw) ;Still a slot left at the end of the current config
addchild(newslot, thishnd)
else
{
Loop, 98
{
unregisterthumbnail(source%A_Index%_thumb) ;Unregister existing thumbs
}
Loop, %tblcount%
{
if(A_Index < tblcount)
{
thisid:=source%A_Index%_hnd
addchild(A_Index, thisid)
}
else
{
thisid:=tblcount%A_Index%
addchild(A_Index, thishnd)
}
wasredrawn:=1
}
}
}
}
}
if wasredrawn = 0 ;Check if any tables have been resized and if so, redraw
{
Loop, %tblcount%
{
retable:=source%A_Index%_hnd
WinGetPos,wx,wy,ww,wh,ahk_id %retable%
if (ww != source%A_Index%_wide)
{
unregisterthumbnail(source%A_Index%_thumb)
addchild(A_Index, retable)
}
}
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = thisactive)
break
}
drawborder(1,matchcnt)
if(lastactive > 0)
{
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lastactive)
break
}
drawborder(2,matchcnt)
}
}
WinSetTitle, ahk_id %target%, ,%tblcount% Tables Previewed
Return
;Function to register the thumbnail to the GUI
registerthumbnail(target, source, thumbnum)
{
Global
VarSetCapacity(thumbnail,4,0)
hr1:=DllCall("dwmapi\DwmRegisterThumbnail",UInt,ta rget,UInt,source,UInt, &thumbnail)
thumbnail:=Numget(thumbnail,0,true)
source%thumbnum%_hnd:=source
source%thumbnum%_thumb:=thumbnail
updatethumbnail(source, thumbnum, thumbnail)
}
;Function sets thumbnail properties and displays
updatethumbnail(source, thumbnum, thumbnail)
{
/*
DWM_TNP_RECTDESTINATION (0x00000001)
Indicates a value for rcDestination has been specified.
DWM_TNP_RECTSOURCE (0x00000002)
Indicates a value for rcSource has been specified.
DWM_TNP_OPACITY (0x00000004)
Indicates a value for opacity has been specified.
DWM_TNP_VISIBLE (0x00000008)
Indicates a value for fVisible has been specified.
DWM_TNP_SOURCECLIENTAREAONLY (0x00000010)
Indicates a value for fSourceClientAreaOnly has been specified.
*/
Global
dwFlags:=0X1 | 0x2 | 0x10
opacity:=150
fVisible:=1
fSourceClientAreaOnly:=1
;Determine where to position thumbnail based on its number
rownum := Ceil(thumbnum / tablesw)
colnum := Mod(thumbnum - 1,tablesw)
newx := ((colnum) * childwinw)
newy := ((rownum - 1) * childwinh)
neww := newx + childwinw
newh := newy + childwinh
WinGetPos,wx,wy,ww,wh,ahk_id %source%
VarSetCapacity(dskThumbProps,45,0)
;struct _DWM_THUMBNAIL_PROPERTIES
NumPut(dwFlags,dskThumbProps,0,"UInt")
NumPut(newx,dskThumbProps,4,"Int") ;x coord in relation to the target
NumPut(newy,dskThumbProps,8,"Int") ;y coord in relation to the target
NumPut(neww,dskThumbProps,12,"Int") ;x coord of bottom of the thumb in relation to the target
NumPut(newh,dskThumbProps,16,"Int") ;y coord of the right edge of the thumb in relation to the target
NumPut(0,dskThumbProps,20,"Int") ;x coord of target to start thumb
NumPut(0,dskThumbProps,24,"Int") ;y coord of target to start thumb
NumPut(ww-borderx,dskThumbProps,28,"Int") ;width of the thumb in relation to the source
NumPut(wh-captionh,dskThumbProps,32,"Int") ;height of the thumb in relation to the source
NumPut(opacity,dskThumbProps,36,"UChar")
NumPut(fVisible,dskThumbProps,37,"Int")
NumPut(fSourceClientAreaOnly,dskThumbProps,41,"Int ")
hr2:=DllCall("dwmapi\DwmUpdateThumbnailProperties" ,"UInt",thumbnail,"UInt",&dskThumbProps)
source%thumbnum%_wide:=ww-(borderx*2)
}
unregisterthumbnail(unthumbnail)
{
ur1:=DllCall("dwmapi.dll\DwmUnregisterThumbnail", "UInt", unthumbnail)
}
;Function to determine the optimal number of tables wide to show in preview window
numtablesw(totaltables)
{
if(totaltables > "1")
{
global clientareah
global clientareaw
global ptablehwratio
wsize := 0
wnum := 0
;The loop value will equal the number of tables per row
Loop,%totaltables%
{
thiswsize := floor(calcwinsize(A_Index, totaltables))
if (thiswsize >= wsize)
{
wsize := thiswsize
wnum := A_Index
}
}
return, %wnum%
}
Else
{
return, 1
}
}
;Calculates child window size based on number of tables per row
calcwinsize(tblperrow, totaltables)
{
global clientareaw
global clientareah
global ptablehwratio
calcwsize := clientareaw / tblperrow
calcrownum := ceil(totaltables / tblperrow)
if ((clientareah / calcrownum) < (ptablehwratio * calcwsize))
{
calcwsize := (1 / ptablehwratio) * (clientareah / calcrownum)
}
Return, calcwsize
}
;Adds child window to the preview pane
addchild(usenum, previewid)
{
Global childwinw
Global childwinh
Global hostwindoww
Global hostwindowh
Global target
if (usenum > 0) ;If usenum is 0 it is not part of the initial load of existing windows
{
registerthumbnail(target, previewid, usenum)
Return
}
}
;Function to determine what happens when a thumbnail is clicked
Lclickevent(wparam)
{
local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,x r,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
if(tblcount>0)
{
;Calculate slot number
thisrow:=Ceil((mousey - captionh) / childwinh)
thiscol:=Ceil((mousex - borderx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
;getcoords(thisslot,thisrow,thiscol,closexl,closex r,closeyt,closeyb,xl,xr,yt,yb)
win:=source%thisslot%_hnd
winactivate,ahk_id%win%
}
}
}
Mclickevent(wparam)
{
msgbox middle
}
Rclickevent(wparam)
{
local id,win,mousex,mousey,thisslot,thisrow,thiscol,xl,x r,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
if(tblcount>0)
{
;Calculate slot number
thisrow:=Ceil((mousey - captionh) / childwinh)
thiscol:=Ceil((mousex - borderx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
win:=source%thisslot%_hnd
pix:=PixelColorA(ActionX,ActionY,win)
if (comparecolors(ActionColor,pix,16)=1)
{ ;send fold
getcoordinates(ActionX, ActionY, win)
controlclick, x%pixel_x% y%pixel_y%, ahk_id%win%,,,,NA
}
else
{
getcoordinates(FoldX, FoldY, win)
controlclick, x%pixel_x% y%pixel_y%, ahk_id%win%,,,,NA
}
}
}
}
;Calculates the four coordinates of a rectangle in a thumbnail
getcoords(calcslot,thisrow,thiscol,rectxl,rectxr,r ectyt,rectyb,ByRef thisxl,ByRef thisxr,ByRef thisyt,ByRef thisyb)
{
Global
;Calculate coords
realw:=source%calcslot%_wide
thisx:= ((thiscol-1) * childwinw)+borderx
thisy:= ((thisrow - 1) * childwinh)+captionh ;+bordery
thisxl:=floor((childwinw*((rectxl-borderx)/(ptablebasew-borderx))) + thisx)
thisxr:=floor((childwinw*((rectxr-borderx)/(ptablebasew-borderx))) + thisx)
thisyt:=floor((childwinh*((rectyt-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
thisyb:=floor((childwinh*((rectyb-captionh)/(ptablebaseh-captionh-bordery))) + thisy)
return
}
; Patch fab12 Begin
getcoordsinv(calcslot,thisrow,thiscol,tablew,table h,rectx,recty,ByRef thisx,ByRef thisy)
{
Global
;Calculate coords
realw:=source%calcslot%_wide
thisx:= ((thiscol-1) * childwinw)+borderx
thisy:= ((thisrow - 1) * childwinh)+captionh
thisx:=(rectx-thisx)*tablew/childwinw
thisy:=(recty-thisy)*tableh/childwinh
return
}
; Patch fab12 End
;Function for docking the border gui's to the preview window
WM_WINDOWPOSCHANGING(wParam, lParam)
{
Global captionh,borderx,thisactive,lastactive, borderguix, borderguiy
if (A_Gui = 99) && !(NumGet(lParam+24) & 0x2) ; SWP_NOMOVE=0x2
{
; Since WM_WINDOWPOSCHANGING happens *before* the window moves,
; we must get the new position from the WINDOWPOS pointed to by lParam.
borderguix := NumGet(lParam+8,0,"int") + borderx
borderguiy := NumGet(lParam+12,0,"int") + captionh
; Move - but don't activate - Border Gui's
If(thisactive>0)
Gui, 1:Show, X%borderguix% Y%borderguiy% NA
if(lastactive>0)
Gui, 2:Show, X%borderguix% Y%borderguiy% NA
}
}
;Function for detecting window activations for setting border colors
ShellMessage( wParam,lParam )
{
Global
If ((wParam = 4 or wParam = 32772) And WinExist( "ahk_id " lParam )) ; HSHELL_WINDOWACTIVATED = 4, HSHELL_RUDEAPPACTIVATED = 32772
{
;If the activated window is in the list set the active and last active window
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lParam)
break
}
if (matchcnt < 98 and thisactive != lParam)
{
;Set and display active table border gui's
drawborder(1,matchcnt)
lastactive:=thisactive
thisactive:=lParam
lastactive2:=thisactive
if(lastactive > 0)
{
matchcnt:=0
Loop, 98
{
matchcnt++
if(source%matchcnt%_hnd = lastactive)
break
}
drawborder(2,matchcnt)
}
}
}
}
drawborder(guinum, slotnumb)
{
Global
;Get the thumbnail outer edge coords
thisrow:=Ceil(slotnumb/tablesw)
thiscol:=Mod(slotnumb - 1,tablesw)+1
getcoords(slotnumb,thisrow,thiscol,borderx,ptableb asew-borderx,captionh,ptablebaseh-bordery,xl,xr,yt,yb)
if(guinum=1)
thisgui:=activegui
else
thisgui:=lactivegui
xl-=borderx
xr-=borderx
yt-=captionh
yb-=captionh
xli:=xl+activebordersize
xri:=xr-activebordersize
yti:=yt+activebordersize
ybi:=yb-activebordersize
neww:=xr-xl
newh:=yb-yt
;Draw the border gui
WinSet, Region, %xl%-%yt% %xr%-%yt% %xr%-%yb% %xl%-%yb% %xl%-%yt% %xli%-%yti% %xri%-%yti% %xri%-%ybi% %xli%-%ybi% %xli%-%yti%, ahk_id %thisgui%
Gui, %guinum%:Show, x%borderguix% y%borderguiy% W%hostwindoww% H%hostwindowh% NA
}
Form1_Close:
ExitApp
return
TableSearch:
;StartTime:=A_TickCount
WinGet, listst, List, %windowtitle%,, Poker
Loop, %listst%
{
win:=listst%A_index%
pix:=PixelColorA(ActionX,ActionY,win)
if (comparecolors(ActionColor,pix,16)=1)
{
MouseGetPos, , currentwindow
WinGetClass, class, ahk_id %currentwindow%
if class <> PTIODEVICE
return
pix:=PixelColorA(ActionX,ActionY,currentwindow)
if (comparecolors(ActionColor,pix,16)=1)
return
WinActivate, ahk_id %win%
}
}
;ElapsedTime:=A_TickCount - StartTime
return
PixelColorA(colxa,colya,id)
{
critical ;speed up
global borderx,bordery,captionh
DllCall("dwmapi\DwmIsCompositionEnabled","int*",Dw mIsEnabled)
if DwmIsEnabled
{
hdc_buffer := DllCall("GetDCEx", "UInt", id,"UInt",0,"UInt",1)
}
else
{
hdc_frame := DllCall( "GetDC", "UInt", id)
hdc_buffer := DllCall("gdi32.dll\CreateCompatibleDC", "UInt", hdc_frame)
WinGetPos, X, Y, W, H, ahk_id %id%
hbm_buffer := CreateDIBSection(hdc_frame, w, h)
DllCall( "gdi32.dll\SelectObject", UInt,hdc_buffer, UInt,hbm_buffer)
DllCall( "PrintWindow", "UInt" , id , "UInt" , hdc_buffer , "UInt" , 0 )
DllCall("RedrawWindow",uint,id,uint,0,uint,0,uint, 1|16|32|128|256|1024) ; with all children windows
}
WinGetPos, X, Y, W, H, ahk_id %id%
w := w - (2*borderx)
h := h - (2*bordery) - captionh
;msgbox %x% %y% %w% %h%
Transform, X, Floor, W*colxa
Transform, Y, Floor, H*colya
pixel_x := x + borderx
pixel_y := y + bordery + captionh
pix := DllCall("GetPixel", "UInt", hdc_buffer, "Int", pixel_x , "Int", pixel_y)
SetFormat, IntegerFast, hex
pix += 0 ; Sets Var (which previously contained 11) to be 0xb.
pix .= "" ; Necessary due to the "fast" mode.
SetFormat, IntegerFast, d
DllCall( "gdi32.dll\DeleteObject", "uint", hbm_buffer )
DllCall( "gdi32.dll\ReleaseDC" , "uint", hdc_frame )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_frame )
DllCall( "gdi32.dll\DeleteDC" , "uint", hdc_buffer )
return pix
}
CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "") {
NumPut(VarSetCapacity(bi, 40, 0), bi)
NumPut(nW, bi, 4)
NumPut(nH, bi, 8)
NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
NumPut(0, bi,16)
Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}
CompareColors(ByRef bgr1, ByRef bgr2, ByRef variation) {
c1 := bgr1 & 0xff
c2 := bgr2 & 0xff
if (abs(c1 - c2) > variation)
return false
c1 := (bgr1 >> 8) & 0xff
c2 := (bgr2 >> 8) & 0xff
if (abs(c1 - c2) > variation)
return false
c1 := (bgr1 >> 16) & 0xff
c2 := (bgr2 >> 16) & 0xff
if (abs(c1 - c2) > variation)
return false
return true
}
getcoordinates(pixelx,pixely,id)
{
global
WinGetPos, X, Y, W, H, ahk_id %id%
w := w - (2*borderx)
h := h - (2*bordery) - captionh
;msgbox %x% %y% %w% %h%
Transform, X, Floor, W*pixelx
Transform, Y, Floor, H*pixely
pixel_x := x + borderx
pixel_y := y + bordery + captionh
}
Feedback is used for internal purposes. LEARN MORE