 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jk7800
Joined: 06 Jan 2008 Posts: 40 Location: Gdi+ v1.1
|
Posted: Thu Aug 14, 2008 12:13 pm Post subject: Vista Window Thumbnail Copy |
|
|
Hi.
I wrote this some time ago, and I thought, that maybe I could share it, although it's not finished.
It's just a copy of the Windows Vista window preview, which shows up, when a taskbar button is hovered. The limitation of the script is that some apps need to be "seen" before, to draw them correctly. It also can't show minimized apps or grouped apps.
To run the script, you'll need COM Standard Library and ACC Standard Library by Sean (http://www.autohotkey.com/forum/viewtopic.php?t=24234). You can edit it as much as you like.
| Code: | #Include ACC.ahk
#Include COM.ahk
#NoTrayIcon
ExcludeList:="Mozilla Firefox" ;Seperate with a |
SetBatchLines, -1
SetWinDelay, -1
SetTitleMatchMode, 3
SetTitleMatchMode, Fast
ACC_Init()
Shown:=0
Stop:=0
WasMinimized=
LastWin=
SysGet, MonitorWorkArea, MonitorWorkArea, 1
WorkAreaH:=MonitorWorkAreaBottom
CoordMode, Mouse, Screen
OnExit, Close
Gui, +AlwaysOnTop +LastFound -Caption +Owner +E0x20
Gui, Show, w200 h200
GUI_ID:=WinExist()
WinSet, Transparent, 1, ahk_id %GUI_ID%
Sleep, 100
PrintWindow:=DllCall("GetProcAddress",UInt,DllCall
("GetModuleHandle",Str,"user32"),Str,"PrintWindow")
StretchBlt:=DllCall("GetProcAddress",UInt,DllCall
("GetModuleHandle",Str,"gdi32"),Str,"StretchBlt")
gdi32:=DllCall("LoadLibrary",Str,"gdi32.dll")
hdc_TMP:=DLLCall("GetDC", UInt, GUI_ID )
hdc_PreviewTMP := DllCall("CreateCompatibleDC", UInt,hdc_TMP)
hbm_PreviewTMP := DllCall("CreateCompatibleBitmap", UInt,hdc_TMP, Int,1024, Int,768)
selobj:=DllCall("SelectObject", UInt,hdc_PreviewTMP, UInt,hbm_PreviewTMP)
Gui, Hide
Hotkey, LButton, LButtonDown
Hotkey, LButton up, LButtonUp
Hotkey, LButton, Off
Hotkey, LButton up, Off
SetTimer, Loopp, 100
Return
Loopp:
MouseGetPos, X, Y, Title, Control
if(Title=WinExist("ahk_class Shell_TrayWnd"))
if(Control="ToolbarWindow323")
{
Stop:=0
if(Shown=X)
Stop:=1
if(Stop=0)
{
If Not pacc := ACC_AccessibleObjectFromPoint()
Return
If paccChild:=acc_Child(pacc, _idChild_)
sResult := acc_Name(paccChild), COM_Release(paccChild)
Else
sResult := acc_Name(pacc, _idChild_)
COM_Release(pacc)
if(sResult=LastWin)
Stop:=1
if(Stop=0)
{
IfWinExist, %sResult%
{
Win:=WinExist()
WinGet, Minimized, MinMax, ahk_id %Win%
if(Minimized>-1)
{
Loop, parse, ExcludeList, |
if(InStr(sResult, A_LoopField))
Return
Hotkey, LButton, On
Hotkey, LButton up, On
WinGetPos,,, w, h, ahk_id %Win%
scale:=200/w
w2:=200
h2:=h*scale
y:=WorkAreaH-h2
x2:=X-100
Gui, Show, NoActivate x%x2% y%y% w%w2% h%h2%
WinSet, Transparent, 1, ahk_id %GUI_ID%
Shown:=X
LastWin:=sResult
GetWindow(sResult, w, h, hdc_PreviewTMP, hdm_PreviewTMP, hdc_TMP, x2, y, w2, h2)
Sleep, 50
if(WasMinimized=sResult)
{
WasMinimized=
WinSet, Redraw, , %sResult%
}
WinSet, Transparent, 150, ahk_id %GUI_ID%
if(clickeddown=1)
{
Click up
Sleep, 25
Click up
clickeddown:=0
}
Hotkey, LButton, Off
Hotkey, LButton up, Off
}Else{
WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
WasMinimized:=sResult
LastWin=
}
}Else{
WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
LastWin=
}
}
}
}Else{
if(Shown<>0)
{
WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
LastWin=
}
}
Else{
if(Shown<>0)
{
WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
LastWin=
}
}
Return
GetWindow(Win, w, h, hdc_PreviewTMP, hdm_PreviewTMP, hdc_TMP, x2, y, w2, h2)
{
global PrintWindow, StretchBlt
DllCall(PrintWindow, UInt, WinExist(Win) , UInt,hdc_PreviewTMP, UInt, 0)
DllCall(StretchBlt, UInt,hdc_TMP, Int,0, Int,0, Int,w2, Int,h2, UInt,hdc_PreviewTMP, Int,0, Int,0,
Int,w, Int,h, UInt,0xCC0020)
}
LButtonDown:
Sleep, 150
clickeddown:=1
Click down
Return
LButtonUp:
Sleep, 200
clickeddown:=0
Click up
Return
Close:
COM_Release(psv)
ACC_Term()
DllCall("DeleteObject", UInt, selobj)
DllCall("DeleteDC", UInt, hdc_PreviewTMP)
DllCall("DeleteDC", UInt, hdc_TMP)
DllCall("FreeLibrary",UInt,gdi32)
ExitApp |
_________________ My first app: Note
(Please, vote if you like my apps!)
None of my apps took me more than a day to create... After this time I get bored with it (maybe except the note one)...
Last edited by jk7800 on Mon Nov 10, 2008 3:24 pm; edited 3 times in total |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Sun Sep 14, 2008 2:24 pm Post subject: |
|
|
Hi jk7800, I tried this script on 2k and it only shows transparent black windows. _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
Ice_Tea
Joined: 12 Jan 2008 Posts: 114
|
Posted: Mon Sep 15, 2008 1:48 am Post subject: |
|
|
| Serenity wrote: | | Hi jk7800, I tried this script on 2k and it only shows transparent black windows. |
Works for me, 2k Doesn't support transparency, instead of a transparent picture w2k renders a solid black color....
Nice Script, but it seems kinda buggy when you move the mouse through many windows, or when you're at the desktop, I didn't look through this problem properly...
| Code: | #Include ACC.ahk
#Include COM.ahk
SetBatchLines, -1
SetWinDelay, -1
SetTitleMatchMode, 3
SetTitleMatchMode, Fast
ACC_Init()
Shown:=0
Stop:=0
WasMinimized=
LastWin=
SysGet, MonitorWorkArea, MonitorWorkArea, 1
WorkAreaH:=MonitorWorkAreaBottom
CoordMode, Mouse, Screen
OnExit, Close
Gui, +AlwaysOnTop +LastFound -Caption +Owner +E0x20
Gui, Show, w200 h200
GUI_ID:=WinExist()
;WinSet, Transparent, 1, ahk_id %GUI_ID%
Sleep, 100
hdc_TMP:=DLLCall("GetDC", UInt, GUI_ID )
hdc_PreviewTMP := DllCall("gdi32.dll\CreateCompatibleDC", UInt,hdc_TMP)
hbm_PreviewTMP := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc_TMP, Int,1024, Int,768)
selobj:=DllCall("gdi32.dll\SelectObject", UInt,hdc_PreviewTMP, UInt,hbm_PreviewTMP)
Gui, Hide
SetTimer, Loopp, 100
Return
Loopp:
MouseGetPos, X, Y, Title, Control
if(Title=WinExist("ahk_class Shell_TrayWnd"))
if(Control="ToolbarWindow323")
{
Stop:=0
if(Shown=X)
Stop:=1
if(Stop=0)
{
If Not pacc := ACC_AccessibleObjectFromPoint()
Return
If paccChild:=acc_Child(pacc, _idChild_)
sResult := acc_Name(paccChild), COM_Release(paccChild)
Else
sResult := acc_Name(pacc, _idChild_)
COM_Release(pacc)
if(sResult=LastWin)
Stop:=1
if(Stop=0)
{
; DllCall("gdi32.dll\RestoreDC", UInt,hdc_TMP, Int,Clear)
IfWinExist, %sResult%
{
Win:=WinExist()
WinGet, Minimized, MinMax, ahk_id %Win%
if(Minimized>-1)
{
WinGetPos,,, w, h, ahk_id %Win%
scale:=200/w
w2:=200
h2:=h*scale
y:=WorkAreaH-h2
x2:=X-100
if(WasMinimized=sResult)
{
WasMinimized=
Return
}
Gui, Show, NoActivate x%x2% y%y% w%w2% h%h2%
;WinSet, Transparent, 1, ahk_id %GUI_ID%
Shown:=X
LastWin:=sResult
GetWindow(sResult, w, h, hdc_PreviewTMP, hdm_PreviewTMP, hdc_TMP, x2, y, w2, h2)
;WinSet, Transparent, 150, ahk_id %GUI_ID%
}Else{
;WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
WasMinimized:=sResult
LastWin=
}
}Else{
;WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
LastWin=
}
}
}
}Else{
if(Shown<>0)
{
;WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
LastWin=
}
}
Else{
if(Shown<>0)
{
;WinSet, Transparent, 1, ahk_id %GUI_ID%
Gui, Hide
Shown:=0
Stop:=0
LastWin=
}
}
Return
GetWindow(Win, w, h, hdc_PreviewTMP, hdm_PreviewTMP, hdc_TMP, x2, y, w2, h2)
{
DllCall("PrintWindow", UInt, WinExist(Win) , UInt,hdc_PreviewTMP, UInt, 0)
DllCall("gdi32.dll\StretchBlt", UInt,hdc_TMP, Int,0, Int,0, Int,w2, Int,h2, UInt,hdc_PreviewTMP, Int,0, Int,0, Int,w, Int,h, UInt,0xCC0020)
}
Close:
COM_Release(psv)
ACC_Term()
DllCall("gdi32.dll\DeleteObject", UInt, selobj)
DllCall("gdi32.dll\DeleteDC", UInt, hdc_PreviewTMP)
DllCall("gdi32.dll\DeleteDC", UInt, hdc_TMP)
ExitApp |
I commented out the winset transparent lines quickly, didn't bother to test it at all, should work on w2k as it doesn't use transparency.. |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Mon Sep 15, 2008 3:16 am Post subject: |
|
|
| 300W wrote: | | I commented out the winset transparent lines quickly, didn't bother to test it at all, should work on w2k as it doesn't use transparency.. |
Thanks, I tried that already and got solid black windows instead. _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
jk7800
Joined: 06 Jan 2008 Posts: 40 Location: Gdi+ v1.1
|
Posted: Sat Oct 25, 2008 5:46 pm Post subject: |
|
|
I know, that this thread is a bit old, but I had no time during last month to answer. If you are still wondering, why the script does not work on win 2000, it's because the PrintWindow function is only available in windows xp and higher. If you still want to use the script, download the user32.dll for windows xp, rename it (e.g. user32_xp.dll), place it in the scripts folder and change this line:
| Code: | | DllCall("PrintWindow" |
to
| Code: | | DllCall("user32_xp.dll\PrintWindow", |
Maybe it will work...
I have updated the script, because of often redraw problems (they were a bit annoying to me...) _________________ My first app: Note
(Please, vote if you like my apps!)
None of my apps took me more than a day to create... After this time I get bored with it (maybe except the note one)... |
|
| 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
|