AutoHotkey Community

It is currently May 27th, 2012, 10:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: March 26th, 2007, 10:32 pm 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2007, 10:42 pm 
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 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2007, 11:45 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Exactly the same behavior, but overall very nice.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 27th, 2007, 12:07 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: sks and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group