Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > Internet Poker > Software > Free Software

Notices

Free Software Discussion of Free / Freeware / Donationware / Open Source poker software and Free Graphics mods

Reply
 
Thread Tools Display Modes
Old 11-15-2010, 08:15 AM   #1
enthusiast
 
Join Date: Nov 2008
Posts: 89
AHK Script: Stacked Table Previewer

AHK script which shows thumbnail previews of all open stars tables. Like those that show when you hover over the task bar except all tables are shown rather than just the one hovered over.

Image below shows 14 tables stacked on the left. On the right is the thumbnail previews of all 14 tables in a preview window. Requires Vista/Windows7 with aero turned on.
Uploaded with ImageShack.us[/IMG]

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

;------------------------------------------------------------------------------------------------------------------
;User defined settings
hostwindoww=800         ;Host preview window width             
hostwindowh=990        ;Host preview window height
hostwindowx=870         ;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)
;------------------------------------------------------------------------------------------------------------------

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
}

;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
            }
        }
    }
        
    ;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")                    ;x coord of bottom of the thumb in relation to the source
    NumPut(wh,dskThumbProps,32,"Int")                    ;y coord of the right edge 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
}


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
    }
}

Form1_Close:
	ExitApp
return
freo is offline   Reply With Quote
Old 11-15-2010, 11:10 AM   #2
Carpal \'Tunnel
 
Join Date: Aug 2004
Posts: 7,215
Re: AHK Script: Stars Stacked Table Previewer

very cool, nice work.
greg nice is offline   Reply With Quote
Old 11-15-2010, 02:34 PM   #3
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK
Posts: 9,190
Re: AHK Script: Stars Stacked Table Previewer

Yes, very cool indeed!
_dave_ is offline   Reply With Quote
Old 11-15-2010, 04:29 PM   #4
journeyman
 
Join Date: Sep 2003
Posts: 385
Re: AHK Script: Stars Stacked Table Previewer

How could I change the script to make the preview window bigger???
imcastleman is offline   Reply With Quote
Old 11-15-2010, 04:47 PM   #5
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK
Posts: 9,190
Re: AHK Script: Stars Stacked Table Previewer

I guess those "hostwindow" lines at the start of the script - there's a short section
Code:
;User defined settings
_dave_ is offline   Reply With Quote
Old 11-15-2010, 04:57 PM   #6
journeyman
 
Join Date: Sep 2003
Posts: 385
Re: AHK Script: Stars Stacked Table Previewer

ty, that worked nicely.
imcastleman is offline   Reply With Quote
Old 11-15-2010, 05:05 PM   #7
Carpal \'Tunnel
 
Michael Davis's Avatar
 
Join Date: Sep 2002
Posts: 9,809
Re: AHK Script: Stars Stacked Table Previewer

Great script. So awesome to finally have this, will send a donation.

Of course, in keeping with the tradition of those who have received something good but want something more, how difficult is it to make it so that clicking on a table in the preview calls up that table? I'm guessing this is a major project, unfortunately...
Michael Davis is offline   Reply With Quote
Old 11-15-2010, 05:15 PM   #8
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK
Posts: 9,190
Re: AHK Script: Stars Stacked Table Previewer

That was my first thought also - Ideally I'd want the previews almost "active",but an option to just bring to front would be similar in difficulty. It would be great for clicking "I'm Back", or leaving tables, or even advance-folding EP-Trash hands etc.

I *think* any of the above isn't too hard - but I can't do anything as I don't have a Vista / Win7 box. Which has always not bothered me... but similarly this is something I have always wanted since I started stacking.

Hopefully Freo starts posting more
_dave_ is offline   Reply With Quote
Old 11-15-2010, 07:05 PM   #9
old hand
 
Join Date: Aug 2009
Location: From Russia with code
Posts: 1,490
Re: AHK Script: Stars Stacked Table Previewer

Here you go, changes i've made are shown in red
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,"activatethumbsource")
;------------------------------------------------------------------------------------------------------------------
;User defined settings
hostwindoww=800         ;Host preview window width             
hostwindowh=990        ;Host preview window height
hostwindowx=870         ;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)
;------------------------------------------------------------------------------------------------------------------


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
}

;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
 WinGet, list, list, ahk_class PokerStarsTableFrameClass
 
;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
            }
        }
    }
        
    ;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
    WinGet, list, list, ahk_class PokerStarsTableFrameClass

    ;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")                    ;x coord of bottom of the thumb in relation to the source
    NumPut(wh,dskThumbProps,32,"Int")                    ;y coord of the right edge 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
}


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
    }
}

Form1_Close:
	ExitApp
return

activatethumbsource(wparam)
{
local id,win,mousex,mousey,thumbx,thumby,thumbleftxpos,thumbrightxpos,thumbtopypos,thumbbottomypos
coordmode,mouse,relative
mousegetpos,mousex,mousey,id
if (id=target)
{
thumbx:=borderxb+borderxa
thumby:=captionh
loop 98
{
 thumbleftxpos:=thumbx
 thumbrightxpos:=thumbx+childwinw
 thumbtopypos:=thumby
 thumbbottomypos:=thumby+childwinh
 if (mousex>thumbleftxpos) & (mousex<thumbrightxpos) & (mousey>thumbtopypos) & (mousey<thumbbottomypos)
 {
  win:=source%A_Index%_hnd
  winactivate,ahk_id%win%
  break
 }
 thumbx+=childwinw
 if (thumbx+childwinw>hostwindoww)
 {
  thumby+=childwinh
  thumbx:=borderxb+borderxa
 }
}
}
}
return

Last edited by _dave_; 11-16-2010 at 02:34 AM.
Max1mums is offline   Reply With Quote
Old 11-15-2010, 07:09 PM   #10
Carpal \'Tunnel
 
DaycareInferno's Avatar
 
Join Date: Jun 2007
Posts: 16,309
Re: AHK Script: Stars Stacked Table Previewer

wow, this is really awesome. thank you.
DaycareInferno is offline   Reply With Quote
Old 11-15-2010, 07:24 PM   #11
enthusiast
 
Join Date: Nov 2008
Posts: 89
Re: AHK Script: Stars Stacked Table Previewer

Hey guys, glad you like it. Thanks Max1mums for the table activation change, I havent had a chance a test that yet as i've been asleep (I live in Australia).

My thoughts for the next steps for this would be to make the preview window resizable, and also possibly be able to close the table by clicking to top right corner of the preview. Would this be useful or a waste of time?
freo is offline   Reply With Quote
Old 11-15-2010, 07:33 PM   #12
Carpal \'Tunnel
 
DaycareInferno's Avatar
 
Join Date: Jun 2007
Posts: 16,309
Re: AHK Script: Stars Stacked Table Previewer

being able to close would be very useful imo
DaycareInferno is offline   Reply With Quote
Old 11-15-2010, 07:33 PM   #13
Carpal \'Tunnel
 
Michael Davis's Avatar
 
Join Date: Sep 2002
Posts: 9,809
Re: AHK Script: Stars Stacked Table Previewer

Dude, the close table option would be the absolute nuts. At this rate I'm going to be donating to you once a day, stop pulling this holding features back crap. (Joking.)

Thanks for an awesome script.
Michael Davis is offline   Reply With Quote
Old 11-15-2010, 07:38 PM   #14
enthusiast
 
Join Date: Nov 2008
Posts: 89
Re: AHK Script: Stars Stacked Table Previewer

Just a note on the settings you can change:

;User defined settings
hostwindoww=800 ;Host preview window width
hostwindowh=990 ;Host preview window height
hostwindowx=870 ;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)


As indicated by _dave_ you can change the height and width of the preview window by changing hostwindoww and hostwindowh.

You can also change where it appears on the screen using hostwindowx and hostwindowy.

Note also that this should work with any type of app, including other poker sites. If you want to use it for another site you just need to change the ptablebasew and ptablebaseh to the size of that site's tables. This is used to optimize the number of tables wide and high that fit into the preview pane. You then need to change wherever you see this line to suit the title of your windows:
WinGet, list, list, Logged In as, ,PokerStars Lobby

As an example, for testing I used Internet Explorer windows
WinGet, list, list, Windows Internet Explorer
freo is offline   Reply With Quote
Old 11-15-2010, 07:59 PM   #15
veteran
 
Join Date: Jan 2009
Location: teh Valuetown
Posts: 2,921
Re: AHK Script: Stars Stacked Table Previewer

Quote:
Originally Posted by Michael Davis View Post
Dude, the close table option would be the absolute nuts. At this rate I'm going to be donating to you once a day, stop pulling this holding features back crap. (Joking.)

Thanks for an awesome script.
tis!

would be nice if you could pm me ur sn... i will donate something end of the month as well... pretty awesome work...
TimStone is online now   Reply With Quote

Reply
      

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 03:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.
Copyright © 2008-2010, Two Plus Two Interactive