|
|
| Free Software Discussion of Free / Freeware / Donationware / Open Source poker software and Free Graphics mods |
11-15-2010, 08:01 PM
|
#16
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
My stars SN is on the 4th line of the script. 'clay973'
Thanks to those who have donated, I really appreciate it.
|
|
|
11-15-2010, 08:05 PM
|
#17
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
Ok, looks like the close table option will be the next thing to look at. I just want to revise the table activation script first as I think the method posted by Max1mums restricts the script to Pokerstars. I was hoping to keep it so that the script would work with any app, particularly other poker sites.
|
|
|
11-15-2010, 08:16 PM
|
#18
|
|
old hand
Join Date: Aug 2009
Location: From Russia with code
Posts: 1,460
|
Re: AHK Script: Stars Stacked Table Previewer
freo, why do you think so? It worked fine for me with FullTilt tables and explorer windows as well. The only thing is that not all poker tables have controls on them (eg fulltilt, ongame tables) so these lines
Code:
;Need to filter out false windows that have no controls
tblcount:=0
Loop, %list%
{
thisid:=list%A_Index%
WinGet,ctrllist,ControlList,ahk_id %thisid%
;WinGetTitle,thistitle,ahk_id %thisid%
If (ctrllist != "") and (thisid > 0)
{
tblcount+=1
tblcount%tblcount%:=list%A_Index%
}
}
should be replaced with
Code:
tblcount:=0
Loop, %list%
{
if thisid:=list%A_Index%
{
tblcount++
tblcount%tblcount%:=list%A_Index%
}
}
and title pattern should be chosen carefully to avoid popups/lobbies etc, eg for FullTilt
Code:
WinGet, list, list, Logged In ahk_class QWidget,,Full Tilt
It would be better to create own Gui control for every slot of course.
|
|
|
11-15-2010, 08:26 PM
|
#19
|
|
_Pooh_Bah_
Join Date: Feb 2005
Location: UK
Posts: 9,139
|
Re: AHK Script: Stars Stacked Table Previewer
I thought PS and FTP were the only sites where stacking was a viable option, don't others all have issues with tables not popping up / correct ordering? Tho with table activation this script may alleviate that somewhat.
|
|
|
11-15-2010, 08:29 PM
|
#20
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
Max1mus, you may be correct, I havent had a chance to test your changes yet as i am at work.
In relation to the blank controls, unfortunately when you select a table using the icon on the task bar it creates a taskbar thumbnail real quick before activating the table which gets picked up by the list command and then created a blank slot. The only way i could think to filter that out to avoid blank slots was to filter out those windows with no controls.
|
|
|
11-15-2010, 08:39 PM
|
#21
|
|
old hand
Join Date: Aug 2009
Location: From Russia with code
Posts: 1,460
|
Re: AHK Script: Stars Stacked Table Previewer
Those thumbnails have class "TaskListThumbnailWnd" so it should be easy to filter them eg "if class!=TaskListThumbnailWnd", specifying window class in winget,list function should solve this problem too eg for explorer windows "WinGet, list, list, Windows Internet Explorer ahk_class IEFrame" will sort thumbs out.
Good job anyway, gl with the script.
|
|
|
11-15-2010, 08:51 PM
|
#22
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
Thanks for the tips Max1mums, i'll give them a try. I'm not a programmer so some of my code may be a bit clunky. It's been a good learning exercise for me.
|
|
|
11-15-2010, 09:02 PM
|
#23
|
|
_Pooh_Bah_
Join Date: Feb 2005
Location: UK
Posts: 9,139
|
Re: AHK Script: Stars Stacked Table Previewer
Once you start messing with DllCall, VarSetCapacity & NumPut to make structs I think that def. makes you a programmer lol.
|
|
|
11-16-2010, 01:09 AM
|
#24
|
|
centurion
Join Date: Sep 2007
Posts: 157
|
Re: AHK Script: Stars Stacked Table Previewer
This is a very nice script. I do not stack because I seem to feel that I am at the mercy of the table that needs action. This script might just be the thing that converts me so tyvm
It is also great to see Max1mums helping out. He edited bits of the mark current hand script and thanks to him it is the first thing I open when I play a session.
One question I have is that it seems this does not auto update. If I have 20 tables open, close 10 and open 10 new ones I can only see the remaining 10 from the start unless I right click > reload script. Is there an AHK command that can be used to reload/refresh the script every x seconds? (Sorry I have zero point zero knowledge of this stuff and can only see a refresh rate in the AHK for the table itself, not the table preview, unless I misunderstood it.)
Thanks once again to both people who have worked on this and dave for posting it in the SNE thread otherwise I might have missed it
|
|
|
11-16-2010, 01:14 AM
|
#25
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
Furio, it should add tables as they are opened and remove them as they are closed. It does so for me.
Are you using the original script or Max1mus modified one? If so please try the original script to see if it loads new tables correctly. As I said, mine does but I dont yet have Max1mums changes added.
I'm hoping to have the table close feature done soon.
|
|
|
11-16-2010, 01:44 AM
|
#26
|
|
veteran
Join Date: Apr 2009
Location: Dreaming of being an FPP Pro
Posts: 2,420
|
Re: AHK Script: Stars Stacked Table Previewer
Wow this script looks awesome. Once I start playing again and mess around with the script for a little while I'll definitely ship you a small donation.
If this can combine well with TOI then my poker setup will be the nuts
|
|
|
11-16-2010, 02:27 AM
|
#27
|
|
old hand
Join Date: Aug 2009
Location: From Russia with code
Posts: 1,460
|
Re: AHK Script: Stars Stacked Table Previewer
Furio, there are 2 entries of "Winget,list,list" in the script but i didn't notice 2nd entry, they should be the same, my mistake.
|
|
|
11-16-2010, 02:35 AM
|
#28
|
|
_Pooh_Bah_
Join Date: Feb 2005
Location: UK
Posts: 9,139
|
Re: AHK Script: Stars Stacked Table Previewer
Quote:
Originally Posted by Max1mums
Furio, there are 2 entries of "Winget,list,list" in the script but i didn't notice 2nd entry, they should be the same, my mistake.
|
I edited your above post with this fix, I think.
|
|
|
11-16-2010, 02:39 AM
|
#29
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
Heres my latest version with table activation included, which is a modified version of what Max1mus did. Opening and closing tables should work correctly as well.
Code:
; freo's Stacked Table Previewer for PokerStars v1.01
; Shows thumbnails of all stacked tables in a preview window
; Only works in Vista/Windows7 with aero enabled
; 'clay973' on PS for donations
#SingleInstance Force
#NoEnv
DetectHiddenWindows,On
SetTitleMatchMode, 2
OnMessage(0x201,"clickevent")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
hostwindoww=800 ;Host preview window width
hostwindowh=600 ;Host preview window height
hostwindowx=400 ;Host preview window x position on screen
hostwindowy=0 ;Host preview window y position on screen
ptablebasew=483 ;Poker table base resolution (For stars this is the smallest table resolution (483 x 353)
ptablebaseh=353
refreshrate=3000 ;Number of seconds to wait between refreshes (1000 = 1 second)
closeareaperc=0.1 ;The percent of the preview window size to use as the close window area on the top right hand side.
;------------------------------------------------------------------------------------------------------------------
hModule := DllCall("LoadLibrary", "str", "dwmapi.dll") ;Load dwmapi.dll for handling thumbnails
ptablehwratio := ptablebaseh / ptablebasew ;Ratio used for scaling thumbnail window size
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 + borderyb ;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
;Create preview window
Gui, 99: +LastFound +LabelForm1_
target := WinExist()
Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, Table Preview
;Create Empty variables for storing thumbnail links
Loop, 98
{
source%A_Index%_hnd:=0
source%A_Index%_thumb:=0
source%A_Index%_wide:=0
source%A_Index%_zoom:=0
}
;Show existing tables
WinGet, list, list, Logged In as, ,PokerStars Lobby ;Get list of open tables
;WinGet, list, list, Windows Internet Explorer ;For testing. Shows internet explorer windows instead of poker tables
;Need to filter out false windows that have no controls
tblcount:=0
Loop, %list%
{
thisid:=list%A_Index%
;WinGet,ctrllist,ControlList,ahk_id %thisid%
WinGetTitle,thistitle,ahk_id %thisid%
If (ctrllist != "") and (thisid > 0)
{
tblcount+=1
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)
}
;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
source%A_Index%_zoom:=0
}
}
}
;Get new list of tables
WinGet, list, list, Logged In as, ,PokerStars Lobby ;Get list of open tables
;WinGet, list, list, Windows Internet Explorer ;For testing. Shows internet explorer windows instead of poker tables
;Need to filter out false windows that have no controls
tblcount:=0
Loop, %list%
{
thisid:=list%A_Index%
WinGet,ctrllist,ControlList,ahk_id %thisid%
WinGetTitle,thistitle,Title,ahk_id %thisid%
If (ctrllist != "") and (thisid > 0)
{
tblcount+=1
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)
}
}
}
}
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,dskThumbProps,28,"Int") ;width of the thumb in relation to the source
NumPut(wh,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
if (newh/wh > neww/ww)
source%thumbnum%_zoom:=neww/ww
else
source%thumbnum%_zoom:=newh/wh
}
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
}
}
clickevent(wparam)
{
local id,win,mousex,mousey,thumbx,thumby,thisrow,thiscol,thisslot,realw,thisx,thisy,thisw,zoom,closesize,xa,xb,ya,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
thumbx:=borderxb+borderxa
thumby:=captionh
;Calculate slot number
thisrow:=Ceil((mousey - thumby) / childwinh)
thiscol:=Ceil((mousex - thumbx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
win:=source%thisslot%_hnd
;Activate the window
if (win >0)
winactivate,ahk_id%win%
}
}
return
Form1_Close:
ExitApp
return
Still working on the closing of the table from the thumbnail.
|
|
|
11-16-2010, 09:02 AM
|
#30
|
|
enthusiast
Join Date: Nov 2008
Posts: 89
|
Re: AHK Script: Stars Stacked Table Previewer
Here the latest version with "Leave Table" support. Click the "Leave Table" icon on the thumbnail, and table will close (You get the standard "Do you want to leave" popup).
Also tweaked the optimization so there is greater preview window space usage.
Code:
; freo's Stacked Table Previewer for PokerStars v1.0
; Shows thumbnails of all stacked tables in a preview window
; Only works in Vista/Windows7 with aero enabled
; 'clay973' on PS for donations
#SingleInstance Force
#NoEnv
DetectHiddenWindows,On
SetTitleMatchMode, 2
OnMessage(0x201,"clickevent")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
hostwindoww=800 ;Host preview window width
hostwindowh=900 ;Host preview window height
hostwindowx=850 ;Host preview window x position on screen
hostwindowy=0 ;Host preview window y position on screen
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
refreshrate=3000 ;Number of seconds to wait between refreshes (1000 = 1 second)
windowtitle=Logged In as ;Window title to match to find tables - Pokerstars
windowtitleexclude=PokerStars Lobby ;Window title to exclude - Pokerstars
;windowtitle=Windows Internet Explorer ;Window title to match to find tables - Internet Explorer
;windowtitleexclude= ;Window title to exclude - Internet Explorer
;------------------------------------------------------------------------------------------------------------------
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 + borderyb ;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
ptablehwratio := (ptablebaseh-captionha) / ptablebasew ;Ratio used for scaling thumbnail window size
;Create preview window
Gui, 99: +LastFound +LabelForm1_
target := WinExist()
Gui, 99: Show, w%hostwindoww% h%hostwindowh% x%hostwindowx% y%hostwindowy%, Table Preview
;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%
;Need to filter out false windows that have no controls
tblcount:=0
Loop, %list%
{
thisid:=list%A_Index%
WinGet,ctrllist,ControlList,ahk_id %thisid%
If (ctrllist != "") and (thisid > 0)
{
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)
}
;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%
;Need to filter out false windows that have no controls
tblcount:=0
Loop, %list%
{
thisid:=list%A_Index%
WinGet,ctrllist,ControlList,ahk_id %thisid%
If (ctrllist != "") and (thisid > 0)
{
tblcount+=1
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)
}
}
}
}
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
}
}
clickevent(wparam)
{
local id,win,mousex,mousey,thumbx,thumby,thisrow,thiscol,thisslot,realw,thisx,thisy,thisw,zoom,closesize,xl,xr,yt,yb
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
thumbx:=borderxb+borderxa
thumby:=captionh
;Calculate slot number
thisrow:=Ceil((mousey - thumby) / childwinh)
thiscol:=Ceil((mousex - thumbx) / childwinw)
thisslot:=((thisrow-1)*tablesw)+thiscol
win:=source%thisslot%_hnd
;Calculate leave table button area
realw:=source%thisslot%_wide
thisx:= ((thiscol-1) * childwinw)+thumbx ;correct
xl:=floor((childwinw*((closexl-borderxa)/(ptablebasew-borderxa-borderxb)) + thisx))
xr:=floor((childwinw*((closexr-borderxa)/(ptablebasew-borderxa-borderxb)) + thisx))
thisy:= ((thisrow - 1) * childwinh)+captionh+borderyb
yt:=floor((childwinh*((closeyt-captionh)/(ptablebaseh-captionh-borderyb)) + thisy))
yb:=floor((childwinh*((closeyb-captionh)/(ptablebaseh-captionh-borderyb)) + thisy))
if (mousex>=xl and mousex<=xr and mousey>=yt and mousey<=yb) ;Close table
winclose,ahk_id%win%
else
{
;Activate the window
if (win >0)
winactivate,ahk_id%win%
}
}
}
return
Form1_Close:
ExitApp
return
Let me know how it goes
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 02:47 PM.
|