 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
kiu
Joined: 18 Dec 2005 Posts: 234 Location: Italy - Galatro(RC)
|
Posted: Mon Mar 26, 2007 9:32 pm Post subject: AltTab replacement with icon and preview |
|
|
This AltTab replacement(alpha) use majkinetor MMenu (http://www.autohotkey.com/forum/viewtopic.php?t=17674) and also some DllCall from various post to create the preview.
Just press F1 to show the menu with current tasks, with their icons and a preview near the menu. In next days I will post screenshots and documentation.
If you like it, please send feedback
To install it just download this script and MMenu API or the zip pack above
alttab replacement
| Code: | #Include includes
#include MMenu.ahk
#include structs.ahk
scale := 240
F1::
alttab()
return
alttab()
{
global
Gui, Destroy
trans_color := 000055
Gui +AlwaysOnTop +LastFound
Gui Color, %trans_color%, 0xcc4444
WinSet, TransColor, %trans_color%
Gui -Caption
;WinSet, Transparent, %translevel_start%
;Gui Add, Pic, x0 y0
CoordMode, Mouse, Screen
MouseGetPos, x,y
if(x<A_ScreenWidth/2)
x2:=x+320
else if(x>A_ScreenWidth/2 and x<A_ScreenWidth-250)
x2:=x-320
else
x2:=x-560
Gui Show, x%x2% y%y% w%scale% h%scale%, Preview 2349
WinGet hw_frame, id, Preview 2349
hdc_frame := DllCall( "GetDC"
, UInt, hw_frame )
DllCall( "gdi32.dll\SetStretchBltMode"
, "uint", hdc_frame
, "int", 4 ) ; Halftone better quality with stretch
hdc_buffer := DllCall("gdi32.dll\CreateCompatibleDC"
, UInt, hdc_frame) ; buffer
hbm_buffer := DllCall("gdi32.dll\CreateCompatibleBitmap"
, UInt,hdc_frame
, Int,A_ScreenWidth
, Int,A_ScreenHeight)
alttab_Menu := MMenu_Create()
;get windows list
Winget, ids, list, , , Program Manager
Loop, %ids%
{
id:=ids%A_Index%
Wingettitle, title, ahk_id %id%
;get icon
WinGet, pid, PID,ahk_id %id%
hProcess := DllCall("OpenProcess", "UInt", 0x0010 | 0x0400, "Int", false, "UInt", pid)
size := VarSetCapacity(filename, 250) ; max. length of filename
DllCall("Psapi.dll\GetModuleFileNameExA", "UInt", hProcess, "Int", 0, "Str", filename, "Int", size)
DllCall("CloseHandle", "UInt", hProcess)
;exclude docks window and not needed ones
If title not contains dock,Preview
if(title!="")
MMenu_Add( alttab_Menu, title, filename ":" 0)
}
MouseGetPos, x,y
MMenu_Show(alttab_Menu,x,y,"selTask","SOnSelect")
Gui, Destroy
return
}
selTask:
WinActivate, %M_STITLE%
MMenu_Destroy( alttab_Menu )
DllCall("gdi32.dll\DeleteObject", UInt,hbm_buffer)
DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
DllCall("gdi32.dll\DeleteDC", UInt,hdc_buffer)
Gui, Destroy
return
OnSelect:
DllCall( "gdi32.dll\SelectObject"
, UInt,hdc_buffer
, UInt,hbm_buffer)
pics_added := 0
WinGet, task_id, Id, %M_STITLE%
WinGetTitle title, ahk_id %task_id%
WinGetPos,,, w, h, ahk_id %task_id%
if(w<30)
return
if(w>h)
{
width:=scale
height:=(h*scale)/w ; w:300=h:x
}
else
{
width:=(w*scale)/h
height:=scale
}
pwin := DllCall("PrintWindow", UInt,task_id, UInt,hdc_buffer, UInt,0)
DllCall("gdi32.dll\StretchBlt"
, UInt, hdc_frame
, Int, "0"
, Int, "0"
, Int, width
, Int, height
, UInt, hdc_buffer
, Int, 0
, Int, 0
, Int, w
, Int, h
, UInt, 0xCC0020) ; SRCCOPY
return
|
_________________ ____________________
______________________
kiu - www.romeosa.com |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Mon Mar 26, 2007 9:42 pm Post subject: |
|
|
Nice!
I do see some flaws though. Explorer windows are not previewed, I see only the title bar. Opera window is not recognised. VLC playlist window I see only the title bar. PSPad sometimes I get good previews, sometimes I get too many entries in the list.
So, still a bit queezy, but very nice  |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Mon Mar 26, 2007 10:45 pm Post subject: |
|
|
Exactly the same behavior, but overall very nice. _________________
 |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Mon Mar 26, 2007 11:07 pm Post subject: |
|
|
The sad thing is that you can expect your script to have lower performance over time cuz of Mmenu. You will not experience it as it will happen when the menu is closed, on deletition. Delete will be slower and slower. You should reload it once in several hours until I solve this for the final version. You can even put automatic reloading every several hours, for instance. This will return the Destroy routine to instant speed and the whole process is repated again.
I plan to redesign some internal structures for MMenu final release so until then, just keep this in mind. For now all very dynamic MMenu usages (like your script, that can create over 100 menus in an hour) should reload the scripts one in while. _________________
 |
|
| 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
|