This is the coco script and he seems to be using ThumbPosGrid() to achive the thumbnail always correlate with toolwindow effect, but I cant get that to work when trying it though.
Code: Select all
; Many thanks to maul.esel for his Thumbnail.ahk library
; Thumbnail.ahk required(http://www.autohotkey.com/community/viewtopic.php?t=70839)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetBatchLines, -1
#SingleInstance force
#NoTrayIcon
;#Include Thumbnail.ahk
DetectHiddenWindows, Off
;~ Config
min_h = 110
min_w = 110
wWorkArea := (A_ScreenWidth + 16)
hWorkArea := (A_ScreenHeight + 16)
s_In = 4
s_Out = 2
bg_Trans = 210
bg_Color = 0
Prev_State = 0
;~ Get Active Window
WinGetTitle, active_Title, A
WinGet, active_Task, ID, A
WinGetPos, x_Active, y_Active,,, A
if active_Title = Program Manager
ExitApp
;~ GUI
;~ ; Background Window
Gui, Gui:-Caption +ToolWindow +Hwndu_hWin
Gui, Gui:Color, %bg_Color%
Gui, Gui:Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% Hide, uWin
;~ Destination Window
Gui, 2Gui:+OwnerGui -Caption +ToolWindow +HwndhWin
Gui, 2Gui:Color, 383838
Gui, 2Gui:Show, x-8 y-8 w%wWorkArea% h%hWorkArea% Hide, Win
GroupAdd, ExposeWin, uWin
GroupAdd, ExposeWin, Win
; Key Mapping
Hotkey, LButton, Pre_Activation,, IfWinActive, ahk_group ExposeWin
Hotkey, Enter, Pre_Activation,, IfWinActive, ahk_group ExposeWin
Hotkey, RButton, Preview_Window,, IfWinActive, ahk_group ExposeWin
;~ Get list of processes
WinGet, ids, List,,, Program Manager
task_List := Object() ; Create array/object to store ID of tasks/processes
num_Win =
ExposeMode :=
;~ Store hwnd of tasks in array
Loop, %ids%
{
task_ID := ids%A_Index%
WinGetTitle, title, ahk_id %task_ID%
WinGetPos,,, w, h, ahk_id %task_ID%
if Window_Hidden()
continue
num_Win++ ; Counter to keep track of the number of windows as well as thumbnails
i++ ; Will use this counter in the thumbnail creation process
task_List.Insert(task_ID)
}
cols := Ceil(Sqrt(num_Win)), rows := Ceil(Sqrt(num_Win))
If (cols*(rows-1) >= num_Win)
rows--
; Create Desktop thumbnail
WinGet, desk_ID, ID, ahk_class Program Manager
thumb_Desk := Thumbnail_Create(hWin, desk_ID)
xSource := 0, ySource := 0
Thumbnail_GetSourceSize(thumb_Desk, wSource, hSource)
ThumbPosGrid(thumb_Desk, "1", "1", xDest, yDest, wDest, hDest, "300")
Thumbnail_SetRegion(thumb_Desk, xDest, yDest, wDest, hDest, xSource, ySource, wSource, hSource)
Thumbnail_Show(thumb_Desk)
;~ Thumbnail_Hide(thumb_Desk)
;~ Create Thumbnails | Creation is done in reverse/descending order so that the active window's thumbnail is set on top of the stack. Thumbnail order is the same with z-order of the windows
thumb_List := Object() ; Create array/object to store ID of thumbnails
for k, v in task_List
{
Source := task_List[i] ; Retrieve window(s) hwnd. Also in reverse order.
thumb := Thumbnail_Create(hWin, Source)
thumb_List.Insert(1, thumb) ; Store thumbnail handle in array
i-- ; Counter starts at n number of tasks/windows going down every iteration
}
;~ Set initial and actual grid position of thumbnails -> for animation purposes
Loop, % num_Win ; Loop through the tasks and the thumbnail(s), then set thumbnail(s) region
{
task := task_List[A_Index]
thumb_%A_Index% := thumb_List[A_Index]
WinGetPos, X%A_Index%, Y%A_Index%,,, ahk_id %task%
xSource%A_Index% := 0, ySource%A_Index% := 0
Thumbnail_GetSourceSize(thumb_%A_Index%, wSource%A_Index%, hSource%A_Index%)
ThumbPosGrid(thumb_%A_Index%, A_Index, num_Win, xDest%A_Index%, yDest%A_Index%, wDest%A_Index%, hDest%A_Index%)
new_xDest%A_Index% := xDest%A_Index%, new_yDest%A_Index% := yDest%A_Index%, new_wDest%A_Index% := wDest%A_Index%, new_hDest%A_Index% := hDest%A_Index% ; Actual position in Grid
old_xDest%A_Index% := X%A_Index%, old_yDest%A_Index% := Y%A_Index%, old_wDest%A_Index% := wSource%A_Index%, old_hDest%A_Index% := hSource%A_Index% ; Position prior animation
old_xDest%A_Index% := old_xDest%A_Index% + 8, old_yDest%A_Index% := old_yDest%A_Index% + 8 ; adjust offset
Opacity := 255
includeNC := True
Thumbnail_SetRegion(thumb_%A_Index%, old_xDest%A_Index%, old_yDest%A_Index%, old_wDest%A_Index%, old_hDest%A_Index%, xSource%A_Index%, ySource%A_Index%, wSource%A_Index%, hSource%A_Index%) ; Set initial position
Thumbnail_SetOpacity(thumb_%A_Index%, Opacity)
Thumbnail_SetIncludeNC(thumb_%A_Index%, includeNC)
Thumbnail_Show(thumb_%A_Index%)
}
;~ Show GUI
Gui, Gui:Show
WinSet, Transparent, 210, uWin
Gui, 2Gui:Show
WinSet, AlwaysOnTop, On, Win
WinSet, TransColor, 383838, Win
Sleep, 100 ; short delay before animation
;~ Animate
i := ; Counter
Steps := 2
Loop, % num_Win * 11 ; Still need to experiment to come up with a constant number
{
i++
action := "-" ; Animation direction: "+" -> Animate out | "-" -> Animate in
xsteps%i% := round(abs(new_xDest%i% - old_xDest%i%) / Steps), ysteps%i% := round(abs(new_yDest%i% - old_yDest%i%) / Steps)
wsteps%i% := round(abs(new_wDest%i% - old_wDest%i%) / Steps), hsteps%i% := round(abs(new_hDest%i% - old_hDest%i%) / Steps)
xDest%i% := (new_xDest%i% > old_xDest%i%) ? (old_xDest%i% += xsteps%i%) : (old_xDest%i% -= xsteps%i%)
yDest%i% := (new_yDest%i% > old_yDest%i%) ? (old_yDest%i% += ysteps%i%) : (old_yDest%i% -= ysteps%i%)
if (action = "-")
wDest%i% := old_wDest%i% -= wsteps%i%, hDest%i% := old_hDest%i% -= hsteps%i%
else if (action = "+")
wDest%i% := old_wDest%i% += wsteps%i%, hDest%i% := old_hDest%i% += hsteps%i%
Thumbnail_SetRegion(thumb_%i%, xDest%i%, yDest%i%, wDest%i%, hDest%i%, xSource%i%, ySource%i%, wSource%i%, hSource%i%) ; Set thumbnail(s) region until actual grid position is reached
if i = %num_Win% ; Reset counter
{
i = 0
Sleep, 1
}
}
ExposeMode := "On"
Loop, % num_Win ; Create "number" and "Numpad" hotkeys for window activation
{
String2Hotkey(A_Index, "Pre_Activation")
String2Hotkey(A_Index, "Pre_Activation", "Numpad")
}
hCurs:=DllCall("LoadCursor", "UInt", NULL,"Int", 32649, "UInt") ; IDC_HAND := 32649, IDC_CROSS := 32515
OnMessage(0x200,"WM_MOUSEMOVE")
;PID := DllCall("GetCurrentProcessId")
;EmptyMem(PID)
return
Pre_Activation:
gosub, % (Prev_State = "0") ? "Activate_Window" : "End_Preview"
return
Activate_Window:
if A_ThisHotkey in LButton,Enter ; Activation via mouse
{
MouseGetPos, X, Y
Pos := 1 + X*cols//wWorkArea + Y*rows//hWorkArea * cols
chosen_Task := task_List[Pos]
thumb := thumb_List[Pos]
ThumbPosGrid(thumb, Pos, num_Win, left, top, right, bottom)
right := (left + right), bottom := (top + bottom)
if (Pos <= num_Win and X >= left and X <= right and Y >= top and Y <= bottom)
{
gosub, Animate_Out
ID := task_List[Pos]
WinActivate(ID)
gosub, Exit
}
}
else ; activation via hotkey
{
Pos := A_ThisHotkey
if Pos contains &,Numpad
Pos := Digitize(Pos)
chosen_Task := task_List[Pos]
gosub, Animate_Out
ID := task_List[Pos]
WinActivate(ID)
ExposeMode := "Off"
gosub, Exit
}
return
Animate_Out: ; Exit expose mode
chosen_Thumb := Thumbnail_Create(hWin, chosen_Task) ; Create thumbnail copy - this to set the chosen thumbnail on top of the other thumbnails
old_Thumb := thumb_List.Remove(Pos) ; Store handle of copied thumbnail - for destruction purposes
thumb_List.Insert(Pos, chosen_Thumb) ; insert new thumbnail in array
xSource := 0, ySource := 0
Thumbnail_GetSourceSize(chosen_Thumb, wSource, hSource)
ThumbPosGrid(chosen_Thumb, Pos, num_Win, xDest, yDest, wDest, hDest)
Opacity := 255, includeNC := True
Thumbnail_SetRegion(chosen_Thumb, xDest, yDest, wDest, hDest, xSource, ySource, wSource, hSource)
Thumbnail_SetOpacity(chosen_Thumb, Opacity)
Thumbnail_SetIncludeNC(chosen_Thumb, includeNC)
Thumbnail_Show(chosen_Thumb) ; Show the thumbnail copy
Thumbnail_Hide(old_Thumb) ; Hide the original thumbnail
Loop, % num_Win
{
task := task_List[A_Index]
thumb_%A_Index% := thumb_List[A_Index]
WinGetPos, X%A_Index%, Y%A_Index%,,, ahk_id %task%
xSource%A_Index% := 0, ySource%A_Index% := 0
Thumbnail_GetSourceSize(thumb_%A_Index%, wSource%A_Index%, hSource%A_Index%)
ThumbPosGrid(thumb_%A_Index%, A_Index, num_Win, xDest%A_Index%, yDest%A_Index%, wDest%A_Index%, hDest%A_Index%)
old_xDest%A_Index% := xDest%A_Index%, old_yDest%A_Index% := yDest%A_Index%, old_wDest%A_Index% := wDest%A_Index%, old_hDest%A_Index% := hDest%A_Index% ; Position in Grid, position prior animation
new_xDest%A_Index% := X%A_Index%, new_yDest%A_Index% := Y%A_Index%, new_wDest%A_Index% := wSource%A_Index%, new_hDest%A_Index% := hSource%A_Index% ;
new_xDest%A_Index% := new_xDest%A_Index% + 8, new_yDest%A_Index% := new_yDest%A_Index% + 8 ; adjust offset
Opacity := 255
includeNC := True
}
;~ Animate thumbnails
i := ; Counter
Steps := 2
Loop, % num_Win * 8
{
i++
action := "+" ; Animation direction: "+" -> Animate out | "-" -> Animate in
xsteps%i% := round(abs(new_xDest%i% - old_xDest%i%) / Steps), ysteps%i% := round(abs(new_yDest%i% - old_yDest%i%) / Steps)
wsteps%i% := round(abs(new_wDest%i% - old_wDest%i%) / Steps), hsteps%i% := round(abs(new_hDest%i% - old_hDest%i%) / Steps)
xDest%i% := (new_xDest%i% > old_xDest%i%) ? (old_xDest%i% += xsteps%i%) : (old_xDest%i% -= xsteps%i%)
yDest%i% := (new_yDest%i% > old_yDest%i%) ? (old_yDest%i% += ysteps%i%) : (old_yDest%i% -= ysteps%i%)
if (action = "-")
wDest%i% := old_wDest%i% -= wsteps%i%, hDest%i% := old_hDest%i% -= hsteps%i%
else if (action = "+")
wDest%i% := old_wDest%i% += wsteps%i%, hDest%i% := old_hDest%i% += hsteps%i%
Thumbnail_SetRegion(thumb_%i%, xDest%i%, yDest%i%, wDest%i%, hDest%i%, xSource%i%, ySource%i%, wSource%i%, hSource%i%) ; Set thumbnail(s) region until actual grid position is reached
if i = %num_Win% ; Reset counter
{
i = 0
Sleep, 1 ; Animation delay
}
}
FadeOut("uWin", "0", "250", "0")
return
Preview_Window:
gosub, % (Prev_State = "0") ? "Start_Preview" : "End_Preview"
return
Start_Preview:
MouseGetPos, X, Y
msgbox
prev_Pos := 1 + X*cols//wWorkArea + Y*rows//hWorkArea * cols
task_Prev := task_List[prev_Pos]
thumb_Hide := thumb_List[prev_Pos] ; Handle of the thumbnail being copied
thumb_Prev := Thumbnail_Create(hWin, task_Prev) ; Create thumbnail copy - this to set the chosen thumbnail on top of the other thumbnails
ThumbPosGrid(thumb_Prev, prev_Pos, num_Win, left, top, right, bottom)
right := (left + right), bottom := (top + bottom)
if (Pos <= num_Win and X >= left and X <= right and Y >= top and Y <= bottom)
{
xSource := 0, ySource := 0
Thumbnail_GetSourceSize(thumb_Prev, wSource, hSource)
ThumbPosGrid(thumb_Prev, "1", "1", xPrev, yPrev, wPrev, hPrev, "0", "Win")
ThumbPosGrid(thumb_Prev, prev_Pos, num_Win, xDest, yDest, wDest, hDest)
Opacity := 255, includeNC := True
Thumbnail_SetRegion(thumb_Prev, xDest, yDest, wDest, hDest, xSource, ySource, wSource, hSource)
Thumbnail_SetOpacity(thumb_Prev, Opacity)
Thumbnail_SetIncludeNC(thumb_Prev, includeNC)
Thumbnail_Show(thumb_Prev) ; Show the thumbnail copy
Thumbnail_Hide(thumb_%prev_Pos%) ; Hide the original thumbnail
ThumbAnimate(thumb_Prev, xDest, yDest, wDest, hDest, xPrev, yPrev, wPrev, hPrev, s_Out) ; Function to animate a thumbnail -> single thuumbnail animation only
Prev_State = 1
}
return
End_Preview:
ThumbPosGrid(thumb_Prev, prev_Pos, num_Win, xDest, yDest, wDest, hDest)
ThumbAnimate(thumb_Prev, xPrev, yPrev, wPrev, hPrev, xDest, yDest, wDest, hDest, s_Out)
Thumbnail_Show(thumb_Hide)
Thumbnail_Destroy(thumb_Prev)
Prev_State = 0
return
Esc::
Loop, % num_Win
{
String2Hotkey(A_Index, "Pre_Activation",, "Off")
String2Hotkey(A_Index, "Pre_Activation", "Numpad", "Off")
}
Thumbnail_Destroy(thumb_Desk)
Thumbnail_Destroy(old_Thumb)
Loop, %num_Win%
{
thumb_%A_Index% := thumb_List[A_Index]
Thumbnail_Destroy(thumb_%A_Index%)
}
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCurs)
Gui Gui:Destroy
ExitApp
Exit:
Loop, % num_Win
{
String2Hotkey(A_Index, "Pre_Activation",, "Off")
String2Hotkey(A_Index, "Pre_Activation", "Numpad", "Off")
}
Thumbnail_Destroy(thumb_Desk)
Thumbnail_Destroy(old_Thumb)
Loop, %num_Win%
{
thumb_%A_Index% := thumb_List[A_Index]
Thumbnail_Destroy(thumb_%A_Index%)
}
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCurs)
Gui Gui:Destroy
ExitApp
; ====================================================================================
; FUNCTIONS
; ====================================================================================
ThumbPosGrid(hThumb, ItemIndex, ItemCount, ByRef xDest, ByRef yDest, ByRef wDest, ByRef hDest, Spacing="20", Coord="Screen") ; This function sets the position of the thumbnail(s) in a grid
{ ; It can also retrieve a thumbnail's region/dimension/property.
cols := Ceil(Sqrt(ItemCount)), rows := Ceil(Sqrt(ItemCount)) ; Specify "Screen" in the "Coord" parameter to postion the
if (cols*(rows-1) >= ItemCount) ; thumbnail relative to the screen otherwise "Win" to postion it
rows-- ; relative to the destination window
if (Coord = "Screen")
wGrid := A_ScreenWidth / cols, hGrid := A_ScreenHeight / rows
if (Coord = "Win")
wGrid := (A_ScreenWidth / cols) + (16 / cols), hGrid := (A_ScreenHeight / rows) + (16 / rows)
Thumbnail_GetSourceSize(hThumb, wSource, hSource)
area_Ratio := wGrid / hGrid, win_Ratio := wSource / hSource
if (win_Ratio < area_Ratio)
hDest := hGrid - Spacing, wDest := round(wSource / hSource * hDest)
else
wDest := wGrid - Spacing, hDest := round(hSource / wSource * wDest)
if ( wDest > wSource or hDest > hSource )
hDest := hSource, wDest := wSource
pos_Cols := ( C := Mod( ItemIndex, cols ) ) ? C : cols, pos_Rows := Ceil( ItemIndex / cols )
if (Coord = "Screen")
xDest := (wGrid/2)-(wDest/2) + (wGrid*(pos_Cols-1)) + 8, yDest := (hGrid/2)-(hDest/2) + (hGrid*(pos_Rows-1)) + 8
if (Coord = "Win")
xDest := (wGrid/2)-(wDest/2) + (wGrid*(pos_Cols-1)), yDest := (hGrid/2)-(hDest/2) + (hGrid*(pos_Rows-1))
}
ThumbAnimate(hThumb, xOld, yOld, wOld, hOld, xNew, yNew, wNew, hNew, Steps="2") ; Single thumbnail animation only -> used in the Start_Preview, End_Preview subroutine(s)
{
abs(wNew - wOld) != 0 or abs(hNew - hOld) != 0 ? ((wNew > wOld or hNew > hOld) ? action := "+" : action := "-") : wDest := wOld += abs(wNew - wOld), hDest := hOld += abs(hNew - hOld)
xSource := 0, ySource := 0, Thumbnail_GetSourceSize(hThumb, wSource, hSource)
Loop
{
xsteps := round(abs(xNew - xOld) / Steps), ysteps := round(abs(yNew - yOld) / Steps)
if action in +,-
wsteps := round(abs(wNew - wOld) / Steps), hsteps := round(abs(hNew - hOld) / Steps)
xDest := (xNew > xOld) ? (xOld += xsteps) : (xOld -= xsteps)
yDest := (yNew > yOld) ? (yOld += ysteps) : (yOld -= ysteps)
if (action = "-")
wDest := wOld -= wsteps, hDest := hOld -= hsteps
else if (action = "+")
wDest := wOld += wsteps, hDest := hOld += hsteps
Thumbnail_SetRegion(hThumb, xDest, yDest, wDest, hDest, xSource, ySource, wSource, hSource)
Sleep, 21
} Until xsteps <= 0 && ysteps <= 0 && wsteps <= 0 && hsteps <= 0
}
; The next two functions were taken from holomind's Real Expose Clone (http://www.autohotkey.com/community/viewtopic.php?t=13001) -> the inspiration for this script
Window_Hidden() {
global
Return w < min_w or h < min_h or title = "" or active_Title = ""
}
WinActivate(ID)
{
WinGet, ActiveID, ID, A
if ActiveID <> ID
WinActivate ahk_id %ID%
}
Digitize(var) ; Removes non-numerical characters in a string
{
StringReplace, var, var, %A_Space%,, a
Loop, Parse, var
{
if A_LoopField is not Integer
StringReplace, var, var, %A_LoopField%,, a
}
return var
}
String2Hotkey(String, Label, KeyType="Normal", Options="") ; Converts 2-character string into a hotkey. Useful for the 'Hotkey' command. It just actually inserts " & " in between.
{
StringReplace, String, String, %A_Space%,, A
Len := StrLen(String)
if KeyType = Normal
{
Loop, Parse, String
{
if A_Index = % Len
String := A_LoopField
else
String := A_LoopField " & "
Key .= String
}
}
if KeyType = Numpad
{
Loop, Parse, String
{
String := "Numpad" A_LoopField
if A_Index = % Len
String := String
else
String := String " & "
Key .= String
}
}
Hotkey, %Key%, %Label%, %Options%
}
FadeOut(window = "A", end = 0, speed = 10, close = 1) ; http://www.autohotkey.com/community/viewtopic.php?t=71886
{
WinGet, currentTrans, Transparent, %window%
If (currentTrans == "")
{
WinSet, Trans, 255, %window%
WinGet, currentTrans, Transparent, %window%
}
While, (currentTrans > end)
{
Sleep, % speed / 2
Trans := currentTrans - speed
WinSet, Trans, %Trans%, %window%
WinGet, currentTrans, Transparent, %window%
}
If (close == 1)
WinClose, %window%
}
EmptyMem(PIDtoEmpty) ; http://www.autohotkey.com/forum/topic32876.html (first line removed)
{
h:=DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", PIDtoEmpty)
DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1)
DllCall("CloseHandle", "Int", h)
}
WM_MOUSEMOVE(wParam,lParam) ; http://www.autohotkey.com/community/viewtopic.php?t=9192
{
Global
MouseGetPos, X, Y
Pos := 1 + X*cols//wWorkArea + Y*rows//hWorkArea * cols
Prev_State <= 0 ? ((Count := num_Win), (Pos := Pos), ThumbPosGrid(thumb_%Pos%, Pos, Count, left, top, right, bottom)) : ((Count := "1"), (Pos := "1"), ThumbPosGrid(thumb_Prev, Pos, Count, left, top, right, bottom, "0", "Win"))
right := (left + right), bottom := (top + bottom)
if (Pos <= Count and X >= left and X <= right and Y >= top and Y <= bottom)
DllCall("SetCursor","UInt",hCurs)
Return
}
/**************************************************************************************************************
title: Thumbnail functions
wrapped by maul.esel
Credits:
- skrommel for example how to show a thumbnail (http://www.autohotkey.com/forum/topic34318.html)
- RaptorOne & IsNull for correcting some mistakes in the code
NOTE:
*This requires Windows Vista or Windows7* (tested on Windows 7)
Quick-Tutorial:
To add a thumbnail to a gui, you must know the following:
- the hwnd / id of your gui
- the hwnd / id of the window to show
- the coordinates where to show the thumbnail
- the coordinates of the area to be shown
1. Create a thumbnail with Thumbnail_Create()
2. Set its regions with Thumbnail_SetRegion()
a. optionally query for the source windows width and height before with <Thumbnail_GetSourceSize()>
3. optionally set the opacity with <Thumbnail_SetOpacity()>
4. show the thumbnail with <Thumbnail_Show()>
***************************************************************************************************************
*/
/**************************************************************************************************************
Function: Thumbnail_Create()
creates a thumbnail relationship between two windows
params:
handle hDestination - the window that will show the thumbnail
handle hSource - the window whose thumbnail will be shown
returns:
handle hThumb - thumbnail id on success, false on failure
Remarks:
To get the Hwnds, you could use WinExist()
***************************************************************************************************************
*/
Thumbnail_Create(hDestination, hSource) {
VarSetCapacity(thumbnail, 4, 0)
if DllCall("dwmapi.dll\DwmRegisterThumbnail", "UInt", hDestination, "UInt", hSource, "UInt", &thumbnail)
return false
return NumGet(thumbnail)
}
/**************************************************************************************************************
Function: Thumbnail_SetRegion()
defines dimensions of a previously created thumbnail
params:
handle hThumb - the thumbnail id returned by <Thumbnail_Create()>
int xDest - the x-coordinate of the rendered thumbnail inside the destination window
int yDest - the y-coordinate of the rendered thumbnail inside the destination window
int wDest - the width of the rendered thumbnail inside the destination window
int hDest - the height of the rendered thumbnail inside the destination window
int xSource - the x-coordinate of the area that will be shown inside the thumbnail
int ySource - the y-coordinate of the area that will be shown inside the thumbnail
int wSource - the width of the area that will be shown inside the thumbnail
int hSource - the height of the area that will be shown inside the thumbnail
returns:
bool success - true on success, false on failure
***************************************************************************************************************
*/
Thumbnail_SetRegion(hThumb, xDest, yDest, wDest, hDest, xSource, ySource, wSource, hSource) {
dwFlags := 0x00000001 | 0x00000002
VarSetCapacity(dskThumbProps, 45, 0)
NumPut(dwFlags, dskThumbProps, 0, "UInt")
NumPut(xDest, dskThumbProps, 4, "Int")
NumPut(yDest, dskThumbProps, 8, "Int")
NumPut(wDest+xDest, dskThumbProps, 12, "Int")
NumPut(hDest+yDest, dskThumbProps, 16, "Int")
NumPut(xSource, dskThumbProps, 20, "Int")
NumPut(ySource, dskThumbProps, 24, "Int")
NumPut(wSource+xSource, dskThumbProps, 28, "Int")
NumPut(hSource+ySource, dskThumbProps, 32, "Int")
return DllCall("dwmapi.dll\DwmUpdateThumbnailProperties", "UInt", hThumb, "UInt", &dskThumbProps) ? false : true
}
/**************************************************************************************************************
Function: Thumbnail_Show()
shows a previously created and sized thumbnail
params:
handle hThumb - the thumbnail id returned by <Thumbnail_Create()>
returns:
bool success - true on success, false on failure
***************************************************************************************************************
*/
Thumbnail_Show(hThumb) {
static dwFlags := 0x00000008, fVisible := 1
VarSetCapacity(dskThumbProps, 45, 0)
NumPut(dwFlags, dskThumbProps, 0, "UInt")
NumPut(fVisible, dskThumbProps, 37, "Int")
return DllCall("dwmapi.dll\DwmUpdateThumbnailProperties", "UInt", hThumb, "UInt", &dskThumbProps) ? false : true
}
/**************************************************************************************************************
Function: Thumbnail_Hide()
hides a thumbnail. It can be shown again without recreating
params:
handle hThumb - the thumbnail id returned by <Thumbnail_Create()>
returns:
bool success - true on success, false on failure
***************************************************************************************************************
*/
Thumbnail_Hide(hThumb) {
static dwFlags := 0x00000008, fVisible := 0
VarSetCapacity(dskThumbProps, 45, 0)
NumPut(dwFlags, dskThumbProps, 0, "Uint")
NumPut(fVisible, dskThumbProps, 37, "Int")
return DllCall("dwmapi.dll\DwmUpdateThumbnailProperties", "UInt", hThumb, "UInt", &dskThumbProps) ? false : true
}
/**************************************************************************************************************
Function: Thumbnail_Destroy()
destroys a thumbnail relationship
params:
handle hThumb - the thumbnail id returned by <Thumbnail_Create()>
returns:
bool success - true on success, false on failure
***************************************************************************************************************
*/
Thumbnail_Destroy(hThumb) {
return DllCall("dwmapi.dll\DwmUnregisterThumbnail", "UInt", hThumb) ? false : true
}
/**************************************************************************************************************
Function: Thumbnail_GetSourceSize()
gets the width and height of the source window - can be used with <Thumbnail_SetRegion()>
params:
handle hThumb - the thumbnail id returned by <Thumbnail_Create()>
ByRef int width - receives the width of the window
ByRef int height - receives the height of the window
returns:
bool success - true on success, false on failure
***************************************************************************************************************
*/
Thumbnail_GetSourceSize(hThumb, ByRef width, ByRef height) {
VarSetCapacity(Size, 8, 0)
if DllCall("dwmapi.dll\DwmQueryThumbnailSourceSize", "Uint", hThumb, "Uint", &Size)
return false
width := NumGet(&Size + 0, 0, "int")
height := NumGet(&Size + 0, 4, "int")
return true
}
/**************************************************************************************************************
Function: Thumbnail_SetOpacity()
sets the current opacity level
params:
handle hThumb - the thumbnail id returned by <Thumbnail_Create()>
int opacity - the opacity level from 0 to 255 (will wrap to the other end if invalid)
returns:
bool success - true on success, false on failure
***************************************************************************************************************
*/
Thumbnail_SetOpacity(hThumb, opacity) {
static dwFlags := 0x00000004
VarSetCapacity(dskThumbProps, 45, 0)
NumPut(dwFlags, dskThumbProps, 0, "UInt")
NumPut(opacity, dskThumbProps, 36, "UChar")
return DllCall("dwmapi.dll\DwmUpdateThumbnailProperties", "Uint", hThumb, "UInt", &dskThumbProps) ? false : true
}
/*
Function: Thumbnail_SetIncludeNC()
sets whether the source's non-client area should be included. The default value is true.
Parameters:
HANDLE hThumb - the thumbnail id returned by <Thumbnail_Create()>
BOOL include - true to include the non-client area, false to exclude it
Returns:
BOOL success - true on success, false on failure
*/
Thumbnail_SetIncludeNC(hThumb, include)
{
static dwFlags := 0x00000010
_ptr := A_PtrSize ? "UPtr" : "UInt"
VarSetCapacity(dskThumbProps, 45, 0)
NumPut(dwFlags, dskThumbProps, 00, "UInt")
NumPut(!include, dskThumbProps, 42, "UInt")
return DllCall("dwmapi.dll\DwmUpdateThumbnailProperties", _ptr, hThumb, _ptr, &dskThumbProps) >= 0x00
}