 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
skrommel
Joined: 30 Jul 2004 Posts: 180
|
Posted: Sun Feb 25, 2007 2:06 am Post subject: Vista taskbar thumbnails |
|
|
Anyone running Vista?
I thought I'd make a window watcher using Vista's WDM, but my code won't work. Could it be my struct handling? There's a byte and two booleans in there...
The code is stolen from http://msdn2.microsoft.com/en-us/library/aa969541.aspx.
| Code: | #SingleInstance,Force
#NoEnv
Gui,Show,w200 h200
Gui,+LastFound
WinGet,target,Id,A
VarSetCapacity(thumbnail,4,0)
VarSetCapacity(size,8,0)
InsertInteger(100,size,0)
InsertInteger(100,size,4)
source:=DllCall("FindWindow","Str","Progman","UInt",0)
hr:=DllCall("dwmapi.dll\DwmRegisterThumbnail","UInt",target,"UInt",source,"UInt",&size,"UInt",&thumbnail)
VarSetCapacity(rcDestination,16,0)
InsertInteger( 0,rcDestination,0)
InsertInteger( 0,rcDestination,4)
InsertInteger(100,rcDestination,8)
InsertInteger(100,rcDestination,12)
VarSetCapacity(rcSource,16,0)
InsertInteger( 0,rcSource,0)
InsertInteger( 0,rcSource,4)
InsertInteger(100,rcSource,8)
InsertInteger(100,rcSource,12)
; public struct ThumbnailProperties
; {
; public int Flags; 4
; public Rectangle rcDestination; 16
; public Rectangle rcSource; 16
; public Byte Opacity; 1
; public bool Visible; 1
; public bool SourceClientAreaOnly; 1
; }
; dwFlags = DWM_TNP_RECTDESTINATION | DWM_TNP_VISIBLE | DWM_TNP_SOURCECLIENTAREAONLY
dwFlags:=0X00000001 | 0x00000008 | 0x00000010
opacity:=150
fVisible:=1
fSourceClientAreaOnly:=1
VarSetCapacity(dskThumbProps,39,0)
InsertInteger(dwFlags,dskThumbProps,0)
InsertInteger(rcDestination,dskThumbProps,4)
InsertInteger(rcSource,dskThumbProps,20)
InsertInteger(opacity,dskThumbProps,36,1)
InsertInteger(fVisible,dskThumbProps,37,1)
InsertInteger(fSourceClientAreaOnly,dskThumbProps,38,1)
; //display the thumbnail
hr:=DllCall("dwmapi.dll\DwmUpdateThumbnailProperties","UInt",thumbnail,"UInt",&dskThumbProps)
MsgBox,%hr%
Return
ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
{
Loop %pSize% ; Build the integer by adding up its bytes.
result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1)
if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
return result ; Signed vs. unsigned doesn't matter in these cases.
; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
return -(0xFFFFFFFF - result + 1)
}
InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
{
Loop %pSize% ; Copy each byte in the integer into the structure as raw binary data.
DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
} |
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Sun Feb 25, 2007 4:31 am Post subject: |
|
|
Looks interesting. It's unfortunate that I don't have Vista yet.
Anyway, all seem fine except one thing. May add this 1-line after DwmRegisterThumbnail call:
| Code: | | thumbnail := ExtractInteger(thumbnail) |
BTW, you said BOOLEAN, not BOOL. Although I think BOOLEAN seems a bit more natural here, should make it clear:
BOOLEAN: 1 byte
BOOL: 4 byte |
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 180
|
Posted: Sun Feb 25, 2007 9:25 am Post subject: Really? |
|
|
I think you're right about | Quote: | | thumbnail := ExtractInteger(thumbnail) | but it still won't work.
Sorry.
Skrommel |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Sun Feb 25, 2007 11:51 am Post subject: |
|
|
The documentations are confusing. The size parameter is absent here:
http://msdn2.microsoft.com/en-us/library/aa969521.aspx
So, first have to check which one gives a meaningful result.
And, the type is really BOOL in the last struct, so the size should be changed from 39 to 45. This struct looks a bit awkward to me, but documentation is documentation. |
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 180
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|