AutoHotkey Community

It is currently May 26th, 2012, 10:33 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 292 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20  Next

Would you like to see this script rewritten and easy to understand ?
No, I dont care, i just use the executable
Yes, as this script is popular some may learn from it
You may select 1 option

View results
Author Message
 Post subject:
PostPosted: May 17th, 2008, 6:59 pm 
Offline

Joined: April 15th, 2008, 9:34 pm
Posts: 44
Ok, while this may not be the best implementation I have changed the functionality so that if no window is zoomed then all thumbnails are refreshed. If there is a zoomed window then only the zoomed window is refreshed. All I did was copy/paste some of the draw_thumbnails functionality into the draw_active function.

I did notice that some windows, especially non-maximized windows behaved differently if they were in different positions of the grid. For example, a non maximized notepad window that was in the top right hand corner of the grid would move to the left side if the window was zoomed. If the same window was maximized then when zoomed it was stuck to the right hand side of the screen (correct functionality). A minor annoyance but if anyone wants to take a shot at it...:)

Again, my implementation may be not the ideal one but it suits my need to have all thumbnails refreshed if there are no zoomed windows.

The other issue I am having is the bottom row of the grid...the windows when zoomed do not have their bottom edge aligned with the bottom edge of the screen (the bottom part of the window is below the bottom edge)...again a minor annoyance but would be great to have a fix for it.

Code:
;v1.20080517 -- expose.ahk - Thumbnails of windows over the working area, active thumbnails when no zoom,                                            ;zoomed window means redraw only zoomed window

OnExit handle_exit
#SingleInstance Force
#NoEnv
SetBatchLines -1
SetWinDelay 0               ; larger values also fail under heavy load, changing windows
Process Priority,,Above Normal
CoordMode Mouse, Relative

Main:
  Gosub, Read_Keymapping
  Gosub, Read_Config
  Gosub, Detect_Screensize
  Gosub, Create_Gui
  Gosub, Create_Buffers
  ; wait for key/mouse
Return

Read_Keymapping:
  Hotkey, #TAB    ,      Window_Choose
  Hotkey, MButton ,     Window_Choose
  Hotkey, IfWinActive , »Expose«
  Hotkey, #TAB    ,      Window_Activate
  Hotkey, MButton ,     Window_Activate
  Hotkey, LButton ,      Window_Activate
  HotKey, RButton ,     Window_Preview
  Hotkey, Esc     ,        hide_gui
  Hotkey, WheelUp ,    Handle_Zoom
  Hotkey, WheelDown, Handle_Zoom
  Hotkey, +MButton ,   handle_exit ; panik-key
  Hotkey, #F12 ,          Debug_Info
Return

Read_Config:
  min_w                        = 110  ; min width of windows to be shown
  min_h                        = 110  ; min height of windows to be shown (hides taskbar etc)
  scale_thumb_space    = 1    ; scale thumbnails to best fit to box?
  live_redraw                 = 1    ; 1/0 = Yes/No
  time_gap                   = 100   ; ms, time left for others after each thumbnail draw
  thumb_border             = 1   ; 1 for gap between thumbnail  s
  animate_in_delay       = 5
  animate_in_steps       = 5
  animate_out_delay     = 5
  animate_out_steps     = 5
  show_taskbar             = 1
  ;fade_in_steps           = 5
  ;fade_in_delay           = 5
  ;fade_out_steps         = 5
  ;fade_out_delay         = 50
  quality_low                = 3 ; allowed: 1 (terrible) , 3 (accepatable) 4 (good = slow)
  quality_high               = 4 ; allowed: 1 (terrible) , 3 (accepatable) 4 (good = slow)
  BackGroundColor       = 004E98
  count := 0
  zoom_preview = 0.8
  do_zoom := 0  ; // off at first
Return

Debug_Info:
ListLines

Window_Hidden() {
   global
   Return w < min_w or h < min_h or title ="»Expose«" or title =""
}

Handle_Zoom:
   If (zoom_preview < 4 and ( A_ThisHotKey = "WheelUp" or A_ThisHotKey = "^+Up" ))
      zoom_preview += 0.1         ; sqrt(sqrt(2))
   If (zoom_preview >  -1 and ( A_ThisHotKey = "WheelDown" or A_ThisHotKey = "^+Down" ))
      zoom_preview -= 0.1
   TrayTip,,% "Zoom = " Round(100*(1+zoom_preview)) "%"
Return

In(x,a,b) {                      ; closest number to x in [a,b]
   IfLess x,%a%, Return a
   IfLess b,%x%, Return b
   Return x
}


Detect_ScreenSize:
  Th=0
  Tw=0
  Ty=0
  Tx=0
  if show_taskbar
   WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,,
  WorkArea_Top    :=      ( Tw > Th  and  Tx = 0  and  Ty = 0) * Th
  WorkArea_Left   :=      ( Tw < Th  and  Tx = 0  and  Ty = 0) * Tw
  WorkArea_Height := A_ScreenHeight - ( Tw > Th  ) * Th
  WorkArea_Width  := A_ScreenWidth  - ( Tw < Th  ) * Tw
Return

Create_Gui:
  Gui +AlwaysOnTop -Caption  +Toolwindow +Owner +LastFound
  ;Gui Color, %BackGroundColor%
  Gui Show, Hide  w%WorkArea_Width% h%WorkArea_Height% x%WorkArea_Left% y%WorkArea_Top%, »Expose«
  ;Gui, Add, Pic, x0 y0 w%WorkArea_Width% h%WorkArea_Height%, c:\test.bmp
  DetectHiddenWindows ON
  WinGet Expose_ID , ID, »Expose«
  WinGet Desktop_ID, ID, Program Manager
  DetectHiddenWindows OFF
Return

Create_Buffers:
  hdc_frontbuffer  := GetDC( Expose_ID )

  hdc_printwindow := CreateCompatibleDC(    hdc_frontbuffer)
  hbm_printwindow := CreateCompatibleBitmap(hdc_frontbuffer,WorkArea_Width,WorkArea_Height)
  hbm_old         := SelectObject(          hdc_printwindow,hbm_printwindow)

  hdc_thumbnails  := CreateCompatibleDC(    hdc_frontbuffer)
  hbm_thumbnails  := CreateCompatibleBitmap(hdc_frontbuffer,WorkArea_Width,WorkArea_Height)
  hbm_old         := SelectObject(          hdc_thumbnails,hbm_thumbnails)

  hdc_backbuffer  := CreateCompatibleDC(    hdc_frontbuffer)
  hbm_backbuffer  := CreateCompatibleBitmap(hdc_frontbuffer,WorkArea_Width,WorkArea_Height)
  hbm_old         := SelectObject(          hdc_backbuffer,hbm_backbuffer)

  hdc_desktop     := CreateCompatibleDC(    hdc_frontbuffer)
  hbm_desktop     := CreateCompatibleBitmap(hdc_frontbuffer,WorkArea_Width,WorkArea_Height)
  hbm_old         := SelectObject(          hdc_desktop,hbm_desktop)

  Gui Show
  PaintDesktop( hdc_frontbuffer ) ; 0=window, 1=Child(no toolbars)
  BitBlt(hdc_desktop     , 0, 0, WorkArea_Width, WorkArea_Height
      ,  hdc_frontbuffer , 0, 0 ,0xCC0020) ; SRCCOPY
  BitBlt(hdc_thumbnails  , 0, 0, WorkArea_Width, WorkArea_Height
      ,  hdc_frontbuffer , 0, 0 ,0xCC0020) ; SRCCOPY
  Gui Hide

Return

Window_Choose:
   WinGet ActiveID, ID, A
   SetTimer Window_Choose_Thread, 0       ; new thread to make thumbnail draws interruptible
Return

Window_Choose_Thread:
   Stop_Drawing  =
   yield         := time_gap        ; yield time to other tasks after each thumbnail drawn
   SetTimer Window_Choose_Thread, OFF     ; run once
   GoSub Window_Info           ; list window IDs, sizes, etc.
   Gosub Animate_In
   GoSub Draw_Thumbnails
Return

Window_Activate:
   Stop_Drawing = 1
   MouseGetPos X, Y
   pos := 1 + X*cols//WorkArea_Width + Y*rows//WorkArea_Height * cols
   task_id := task_ids_%pos%

 If (pos <= num_win and X >= 0 and X <= WorkArea_Width and Y >= 0 and Y <= WorkArea_Height)
   {
      Gosub Animate_Out
         WinActivate(task_id)                 ; activate selected window
      Gosub fade_out
   }
Gui_Hide()

Return

WinActivate(ID) {
   WinGet ,ActiveID2, ID, A
   if ActiveID2 <> ID
       WinActivate ahk_id %ID%
}

Window_Info:
   WinGet ids, list,,,Program Manager      ; all active windows-tasks (processes)
   task_info =
   num_win = 0
   Loop %ids% {
      task_id := ids%A_Index%              ; id of this window
      WinGetClass class, ahk_id %task_id%
      WinGetTitle title, ahk_id %task_id%
      WinGetPos,,, w, h, ahk_id %task_id%
      If Window_Hidden()                 ; small windows not shown (e.g. taskbar)
         Continue
      num_win++
      task_info := task_info class "|" ids%A_Index% "|" w "|" h ","
   }
   StringTrimRight task_info, task_info, 1
   Sort task_info, D,                      ; keep positions of thumbnails
   cols := ceil(sqrt(num_win))
   rows := ceil(sqrt(num_win))
   If (cols*(rows-1) >= num_win)           ; minimize table size
       rows--
   thumb_w := WorkArea_Width  // cols
   thumb_h := WorkArea_Height // rows
   ratio_of_screen := WorkArea_Width / WorkArea_Height * rows / cols
   Loop Parse, task_info, `,               ; task_info has been set up in get_wins()
   {
      StringSplit z, A_LoopField, |        ; separate ID, w, h
      task_ids_%A_Index% := z2             ; needed for activation
      if ( z2 = ActiveID )
      pos = %A_Index%
     w%A_Index% := z3                     ; w
      h%A_Index% := z4                     ; h
      ratio_of_win := z3 / z4              ; w/h
      If ( scale_thumb_space  )  {
         If (ratio_of_win < ratio_of_screen) { ; tall window
            thumb_h%A_Index% := thumb_h - thumb_border
            thumb_w%A_Index% := Floor(thumb_w * ratio_of_win / ratio_of_screen) - thumb_border
         } Else {                              ; wide window
            thumb_w%A_Index% := thumb_w - thumb_border
            thumb_h%A_Index% := Floor(thumb_h * ratio_of_screen / ratio_of_win) - thumb_border
         }
      } Else {
         thumb_w%A_Index% := z3//cols - 2*thumb_border
         thumb_h%A_Index% := z4//cols - 2*thumb_border  ; cols >= rows, keep aspect ratio of window
      }
     if ( thumb_w%A_Index% > w%A_Index% or thumb_h%A_Index% > h%A_Index% )
     {
        thumb_w%A_Index% := w%A_Index%
         thumb_h%A_Index% := h%A_Index%
      }
   }
Return

Draw_Thumbnails:


    If ( Stop_Drawing )
   {
      tooltip,
           Return
   }

   WinGet ids_count, list,,,Program Manager      ; all active windows-tasks (processes)
     SetStretchBltMode(hdc_thumbnails,quality_high) ; 3: Lower quality at 1st draw
   
   if ( old_ids_count <> ids_count )
      gosub Window_Info   ; detect if windows were added in expose mode
   
   ; layout changed full refresh (start with empty desktop)
   if ( cols <> old_cols or rows <> old_rows)
       BitBlt( hdc_frontbuffer, 0, 0, WorkArea_Width, WorkArea_Height
           , hdc_desktop, 0, 0 , 0xCC0020) ; SRCCOPY
       BitBlt( hdc_thumbnails, 0, 0, WorkArea_Width, WorkArea_Height
           , hdc_desktop, 0, 0 , 0xCC0020) ; SRCCOPY
   
   ; clear "now empty" places , only needed when less, more are filled automatically
   gaps := old_num_win - num_win
    if ( gaps )
   {
     loop %gaps%
     {
        a_index2 := num_win + gaps
       pos_x := thumb_w * Mod(A_Index2-1,cols)
       pos_y := thumb_h * ((A_Index2-1)//cols)
 
       BitBlt( hdc_thumbnails, pos_x, pos_y, thumb_w, thumb_h
              , hdc_desktop,    pos_x, pos_y ,0xCC0020) ;
   
        BitBlt( hdc_frontbuffer, pos_x, pos_y, thumb_w, thumb_h
              , hdc_thumbnails,  pos_x, pos_y ,0xCC0020) ;
      }   
   }

    old_ids_count := ids_count
    old_rows := rows
    old_cols := cols
   old_num_win := num_win

    Loop %num_win%  {                       ; task_ids, dims have been set up in win_list
     ;  Sleep %yield%                        ; CPU cycles to other tasks @ frequent redraw
      If Stop_Drawing
         Break
   
      pos_x := thumb_w * Mod(A_Index-1,cols)
      pos_y := thumb_h * ((A_Index-1)//cols)
     
      PrintWindow( task_ids_%A_Index%, hdc_printwindow, 0) ; 0=window, 1=Child(no toolbars)
   
      BitBlt( hdc_thumbnails, pos_x , pos_y, thumb_w, thumb_h
            , hdc_desktop   , pos_x , pos_y ,0xCC0020) ; Clear slot . (could load Image here ?)
   
      ; prevent flicker with backbuffer , store it in hdc_thumbnails for later reuse!
      StretchBlt( hdc_thumbnails , pos_x + ( thumb_w - thumb_w%A_Index% ) // 2
                            , pos_y + ( thumb_h - thumb_h%A_Index% ) // 2     
                            , thumb_w%A_Index%
                          , thumb_h%A_Index%
             ,hdc_printwindow, 0, 0, w%A_Index%, h%A_Index% ,0xCC0020) ; SRCCOPY
 
        BitBlt( hdc_frontbuffer, pos_x , pos_y , thumb_w, thumb_h
             ,hdc_thumbnails,  pos_x , pos_y ,0xCC0020) ; Clear slot . (could load Image here ?)
   }
 
   MouseGetPos X, Y
      pos := 1 + X*cols//WorkArea_Width + Y*rows//WorkArea_Height * cols
 
   winid := task_ids_%pos%
   WinGetTitle title, ahk_id %winid%

   tooltip, %title% ; + %old_pos2% + %pos%

     
    If live_redraw 
    {
       Gosub draw_active
       Return
      }
Return

Window_Preview:

   do_zoom := 1 - do_zoom ; toggle state
   BitBlt(hdc_frontbuffer, 0, 0, WorkArea_Width, WorkArea_Height
             ,  hdc_thumbnails, 0, 0 ,0xCC0020) ; SRCCOPY
   
return

draw_active:

  zoom :=  zoom_preview

  sleep %yield%                        ; CPU cycles to other tasks @ frequent redraw
       If ( Stop_Drawing )
   {
      tooltip,
           Return
   }
      MouseGetPos X, Y
      pos := 1 + X*cols//WorkArea_Width + Y*rows//WorkArea_Height * cols
 
      winid := task_ids_%pos%

      pos_x := thumb_w * Mod(pos -1,cols)
      pos_y := thumb_h * ((pos -1)//cols)
 
       A_Index2 := pos
       task_id := task_ids_%A_Index2%
   
   diff_x := WorkArea_Left
   diff_y := WorkArea_Top
   diff_w := WorkArea_Width
   diff_h := WorkArea_Height


   WinGetPos, diff_x, diff_y, diff_w, diff_h , ahk_id %task_id%
   diff_x := X - diff_w // 2 ; -  ( WorkArea_Width - WorkArea_Left ) // 2

   diff_y := Y - diff_h // 2 ; - ( WorkArea_Height - WorkArea_Top ) // 2
   

   if ( pos_x + diff_x + (diff_w//2) *zoom > Work_AreaWidth )
       diff_x := Work_AreaWidth - ( (diff_w//2) *zoom)
       
   if diff_x < 1
      diff_x :=1

   if diff_y < 1
      diff_y := 1

;   if ( diff_y + thumb_h * zoom > Work_AreaHeight )
;          diff_y := Work_AreaHeight - thumb_h * zoom

   diff_x := diff_x - ( pos_x + (thumb_w - thumb_w%A_Index2% ) // 2 ) - WorkArea_Left
   diff_y := diff_y - ( pos_y + (thumb_h - thumb_h%A_Index2% ) // 2 ) - WorkArea_Top
   diff_w := diff_w - ( thumb_w%A_Index2% )
   diff_h := diff_h - ( thumb_h%A_Index2% )

   
      ; you can comment this line to get bit speed, acceptable
      BitBlt( hdc_backbuffer, 0, 0, WorkArea_Width, WorkArea_Height
              , hdc_thumbnails, 0, 0, 0xCC0020) ; SRCCOPY
      PrintWindow( task_ids_%A_Index2%, hdc_printwindow, 0) ; 0=window, 1=Child(no toolbars)
      SetStretchBltMode(hdc_backbuffer,quality_high) ; 3: Lower quality at 1st draw
      SetStretchBltMode(hdc_frontbuffer,quality_high) ; 3: Lower quality at 1st draw
   
     if ( do_zoom = 1 ) {   
   
      StretchBlt( hdc_backbuffer, pos_x + (thumb_w - thumb_w%A_Index2% ) // 2 + diff_x * zoom
                           , pos_y + (thumb_h - thumb_h%A_Index2% ) // 2 + diff_y * zoom
                           , thumb_w%A_Index2% + diff_w * zoom
                           , thumb_h%A_Index2% + diff_h * zoom
                           ,hdc_printwindow, 0, 0, w%A_Index2%, h%A_Index2% ,0xCC0020) ; SRCCOPY
      BitBlt(hdc_frontbuffer, 0, 0, WorkArea_Width, WorkArea_Height
               ,  hdc_backbuffer, 0, 0 ,0xCC0020) ; SRCCOPY
   
   }
else  {

     Loop %num_win%  {                       ; task_ids, dims have been set up in win_list
     ;  Sleep %yield%                        ; CPU cycles to other tasks @ frequent redraw
      If Stop_Drawing
         Break
   
      pos_x := thumb_w * Mod(A_Index-1,cols)
      pos_y := thumb_h * ((A_Index-1)//cols)
     
      PrintWindow( task_ids_%A_Index%, hdc_printwindow, 0) ; 0=window, 1=Child(no toolbars)
   
      BitBlt( hdc_thumbnails, pos_x , pos_y, thumb_w, thumb_h
            , hdc_desktop   , pos_x , pos_y ,0xCC0020) ; Clear slot . (could load Image here ?)
   
      ; prevent flicker with backbuffer , store it in hdc_thumbnails for later reuse!
      StretchBlt( hdc_thumbnails , pos_x + ( thumb_w - thumb_w%A_Index% ) // 2
                            , pos_y + ( thumb_h - thumb_h%A_Index% ) // 2     
                            , thumb_w%A_Index%
                          , thumb_h%A_Index%
             ,hdc_printwindow, 0, 0, w%A_Index%, h%A_Index% ,0xCC0020) ; SRCCOPY
 
        BitBlt( hdc_frontbuffer, pos_x , pos_y , thumb_w, thumb_h
             ,hdc_thumbnails,  pos_x , pos_y ,0xCC0020) ; Clear slot . (could load Image here ?)
     }
}

   
   MouseGetPos X, Y

   pos := 1 + X*cols//WorkArea_Width + Y*rows//WorkArea_Height * cols
 
   winid := task_ids_%pos%
   WinGetTitle title, ahk_id %winid%

   tooltip, %title% ; + %old_pos2% + %pos%

   

   If live_redraw 
   {
      Gosub draw_active
      Return
   }

return

Animate_In:
    if !animate_in_steps
        return

    SetStretchBltMode(hdc_backbuffer, quality_low) ; 3: Lower quality at 1st draw
   
     A_index2 := pos
    pos_x := thumb_w * Mod(A_Index2-1,cols)
    pos_y := thumb_h * ((A_Index2-1)//cols)
 
    PrintWindow(task_ids_%A_Index2%,hdc_printwindow,0)
 
    task_id := task_ids_%A_Index2%
   WinGetPos, diff_x, diff_y, diff_w, diff_h , ahk_id %task_id%

    diff_x := diff_x - ( pos_x + (thumb_w - thumb_w%A_Index2% ) // 2 ) - WorkArea_Left
    diff_y := diff_y - ( pos_y + (thumb_h - thumb_h%A_Index2% ) // 2 ) - WorkArea_Top
    diff_w := diff_w - ( thumb_w%A_Index2% )
    diff_h := diff_h - ( thumb_h%A_Index2% )
   
   Loop %animate_in_steps%
   {
       sleep %animate_in_delay%
       zoom := 1 - ( A_Index / animate_in_steps )
     
        BitBlt( hdc_backbuffer, 0, 0, WorkArea_Width, WorkArea_Height
                 , hdc_thumbnails, 0, 0 , 0xCC0020) ; SRCCOPY
   
      if ( zoom = 0 )
         SetStretchBltMode(hdc_backbuffer, quality_high) ; 3: Lower quality at 1st draw
         StretchBlt( hdc_backbuffer , pos_x + (thumb_w - thumb_w%A_Index2% ) // 2 + diff_x * zoom     
                           , pos_y + (thumb_h - thumb_h%A_Index2% ) // 2 + diff_y * zoom     
                           , thumb_w%A_Index2% + diff_w * zoom   
                           , thumb_h%A_Index2% + diff_h * zoom
                           , hdc_printwindow, 0, 0, w%A_Index2%, h%A_Index2% ,0xCC0020) ; SRCCOPY
     
       if ( zoom = 0 )
         SetStretchBltMode(hdc_backbuffer, quality_low) ; 3: Lower quality at 1st draw
         Gui_Show()
         BitBlt(hdc_frontbuffer, 0, 0 ,WorkArea_Width ,WorkArea_Height
                 ,hdc_backbuffer , 0, 0 ,0xCC0020) ; SRCCOPY
   }

   old_cols := cols ; prevent full refresh on next draw
   old_rows := rows

Return

; should be reverse of animate in ? combine them ...
Animate_Out:
   
   if !animate_out_steps
         return

   A_index2 := pos
    pos_x := thumb_w * Mod(A_Index2-1,cols)
    pos_y := thumb_h * ((A_Index2-1)//cols)
 
    If (!(pos <= num_win and X >= 0 and X <= WorkArea_Width and Y >= 0 and Y <= WorkArea_Height))
       return

   ;SetStretchBltMode(hdc_frontbuffer,quality_low) ;
    PrintWindow( task_ids_%A_Index2%, hdc_printwindow ,0) ; get selected window
   
   ; clear
     BitBlt( hdc_backbuffer, pos_x, pos_y, thumb_w, thumb_h
              , hdc_desktop   , pos_x, pos_y, 0xCC0020) ; clear with desktopimage

   task_id := task_ids_%A_Index2%
   WinGetPos, diff_x, diff_y, diff_w, diff_h , ahk_id %task_id%

   diff_x := diff_x - ( pos_x + (thumb_w - thumb_w%A_Index2% ) // 2 ) - WorkArea_Left
   diff_y := diff_y - ( pos_y + (thumb_h - thumb_h%A_Index2% ) // 2 ) - WorkArea_Top
   diff_w := diff_w - ( thumb_w%A_Index2% )
   diff_h := diff_h - ( thumb_h%A_Index2% )

   SetStretchBltMode(hdc_backbuffer,quality_low) ; 3: Lower quality at 1st draw
    Loop %animate_out_steps%
   {
       sleep %animate_out_delay%
          zoom := ( A_Index / animate_out_steps )
       
      ; you can comment this line to get bit speed, acceptable
      BitBlt( hdc_backbuffer, 0, 0, WorkArea_Width, WorkArea_Height
              , hdc_thumbnails, 0, 0, 0xCC0020) ; SRCCOPY
     
      StretchBlt( hdc_backbuffer, pos_x + (thumb_w - thumb_w%A_Index2% ) // 2 + diff_x * zoom
                           , pos_y + (thumb_h - thumb_h%A_Index2% ) // 2 + diff_y * zoom
                           , thumb_w%A_Index2% + diff_w * zoom
                           , thumb_h%A_Index2% + diff_h * zoom
                           ,hdc_printwindow, 0, 0, w%A_Index2%, h%A_Index2% ,0xCC0020) ; SRCCOPY
   
       BitBlt(hdc_frontbuffer, 0, 0, WorkArea_Width, WorkArea_Height
                ,  hdc_backbuffer, 0, 0 ,0xCC0020) ; SRCCOPY
     }
   
Return

fade_in:
   ; not used ?
Return

fade_out:
   ; fade last animate_out with real desktop
Return

Gui_Show() {
   global
   if Shown
      return
   Gui, Show
   Shown = 1
}

Gui_Hide() {
   global
   tooltip,
   if !Shown
     return
   Gui, Hide
   Shown =
}

hide_gui:
   Stop_Drawing = 1
   Gui_Hide()
   WinActivate(ActiveID)                   ; activate last active window
Return

handle_exit:
   Gui Destroy
   ReleaseDC(hw_frame,hdc_frontbuffer)     ; free lock?
   DeleteObject( hbm_printwindow)
   DeleteDC(     hdc_printwindow)
   DeleteObject( hbm_window)
   DeleteDC(     hdc_window)
   DeleteObject( hbm_backbuffer)
   DeleteDC(     hdc_backbuffer)
 ;  WinActivate ahk_id %ActiveID%    ; activate last active window
ExitApp

; --------------------------------------------------------------------------------------------------
; Library: no need to modify below

; Libary (could be put in extra file )
; #include <GDI.ahk>
; for documentation of commands see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/wingdistart_9ezp.asp

; -- highlevel not direct dllcall mapping , simplifiers
CreateDCBuffer(ByRef hdc_from, ByRef hdc_to, ByRef hbm_to, w ,h ) {
   ; does not work, something wrong with ByRef and global
   hdc_to  := CreateCompatibleDC(hdc_from) ; buffer
   hbm_to  := CreateCompatibleBitmap(hdc_from,w,h)
   old     := SelectObject(hdc_to,hbm_to)
}

; -- mfc wrapper
GetDC( hw ) {
   return DLLCall("GetDC", UInt, hw )
}

CreateDC( driver,device,output,mode  ) {
   return DLLCall("GetDC", UInt, driver, UInt, device, UInt, output, UInt, mode )
}

SetStretchBltMode( hdc , value ) {
     return DllCall("gdi32.dll\SetStretchBltMode", UInt,hdc, "int",value)
}

CreateCompatibleDC( hdc ) {
   return DllCall("gdi32.dll\CreateCompatibleDC", UInt,hdc)
}

CreateCompatibleBitmap( hdc , w, h ) {
     return DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc, Int,w, Int,h)
}

SelectObject( hdc , hbm ) {
   return DllCall("gdi32.dll\SelectObject", UInt,hdc, UInt,hbm)
}

DeleteObject( hbm ) {
   return DllCall("gdi32.dll\DeleteObject", UInt,hbm)   
}

DeleteDC( hdc ) {
   return DllCall("gdi32.dll\DeleteDC", UInt,hdc )
}

ReleaseDC( hwnd, hdc ) {
   return DllCall("gdi32.dll\ReleaseDC", UInt,hwnd,UInt,hdc )
}

PrintWindow( window_id , hdc , mode ) {
   return DllCall("PrintWindow", UInt, window_id , UInt,hdc, UInt, mode)
}

StretchBlt( hdc_dest , x1, y1, w1, h1, hdc_source , x2, y2, w2, h2 , mode) {
   return DllCall("gdi32.dll\StretchBlt"
          , UInt,hdc_dest  , Int,x1, Int,y1, Int,w1, Int,h1
             , UInt,hdc_source, Int,x2, Int,y2, Int,w2, Int,h2
          , UInt,mode)
}

BitBlt( hdc_dest, x1, y1, w1, h1 , hdc_source, x2, y2 , mode ) {
   return DllCall("gdi32.dll\BitBlt"
          , UInt,hdc_dest   , Int, x1, Int, y1, Int, w1, Int, h1
             , UInt,hdc_source    , Int, x2, Int, y2
          , UInt, mode)
}

PaintDesktop(  hdc ) {
   return DllCall("PaintDesktop", UInt, hdc )
}

; constants
; see: http://www.adaptiveintelligence.net/Developers/Reference/Win32API/GDIConstants.aspx
; #SRCCOPY = 0xCC0020


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2008, 2:17 pm 
Offline

Joined: May 12th, 2008, 2:23 pm
Posts: 30
Location: Germany
Hi

using this function
Code:
minAnimation(set="")
{
   VarSetCapacity(AnimationInfo, 8,0)
   cbSize := VarSetCapacity(AnimationInfo)
   NumPut(cbSize, AnimationInfo, 0, "UInt")

   if set =
   {
      DllCall("SystemParametersInfo", UInt, 0x48, UInt, cbSize, "UInt", &AnimationInfo, UInt, 1 )
      return NumGet(AnimationInfo,4)
   }
   
   if (set = 0 || set = 1)
   {
      NumPut(cbSize, AnimationInfo, 0, "UInt")
      NumPut(set, AnimationInfo, 4, "Int")
     
      DllCall("SystemParametersInfo", UInt, 0x49, UInt, cbSize, "UInt", &AnimationInfo, UInt, 1 )
      return 1
   }
   return 0
}

you can enable/disable the OS animations for min/maximizing windows. This way it is possible to WinRestore all minimized windows, show them as thumbnails and WinMinimize them again when hiding the gui window.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2008, 12:06 pm 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Hi, really nice to see the script evolves. somehow i lost my forum notifications and did not check for a while. but the good thing is, that the script was changed in meantime... I didnt think about the refresh-all feature, i turned it off to get more speed, but its good to keep it in not-zoomed mode *clever*.

about the placement of the zoomed window. this is not perfect jet, and you are right that it does not behave as expected on the last row. perhaps it would be better to improve placement. perfect one would be to use the animate-out function/algorithm. which already does perfect scaling of the window. because scaling to 1:1 original window is normally enough.

the minimized feature could be done, thanks for the code to unminimize/minimize the windows. you are right because printwindow can only show windows which are not hidden or minimized. but it can show them if they are offscreen (eg. x=10000, y=10) funny behavior of printwindow.
perhaps it should be an config-option to "show hidden windows : on/off" ? because there are some windows which dont behave well after unminimize/minimize. (or one could exclude them ?)

greetings,
Holomind


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 7:42 am 
Offline

Joined: September 12th, 2005, 2:12 am
Posts: 190
This script doesn't work for me. When I hit Win-Tab the active window loses focus but nothing appears on the screen.

I use the alternative shell Litestep with Windows XP. Could this be the reason?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 8:37 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Mistrel wrote:
This script doesn't work for me. When I hit Win-Tab the active window loses focus but nothing appears on the screen.

I use the alternative shell Litestep with Windows XP. Could this be the reason?


The simple answer is yes. Litestep changes much Internal APIs of Windows and breaks AHK and GDI/GDIPlus functions. I guess many other Scripts here using GDI will not work correctly. (If you use litestep you maybe should use another (commercial) expose-application like "TopDesk". )

Perhaps Litestep also Uses the Win-Tab-Key. Have you tried the Mouse-Key Middle-Click in some Implementations of Expose-Clone ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2008, 11:38 am 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
Thanks for sharing this useful script. I am using
Code:
; v1.01 -- expose.ahk
which I downloaded from the first post in this thread, is this the latest?

And what about combining this with the ideas here: http://www.autohotkey.com/forum/viewtopic.php?t=32824
or was this already done? (Sorry I didn't read anything in this thread, just wanted to share my thoughts quickly here.)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 4th, 2009, 2:29 pm 
Offline

Joined: March 16th, 2007, 9:50 am
Posts: 4
Sometimes is difficult to recognize a window.
Perhaps adding the icon and/or the name of the window it would be easier to locate it

Thanks in advance


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2009, 6:03 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Interesting script you got here, holomind.
However, there are a few issues I encountered while testing and I thought it worth posting.
1. The script assumes the taskbar is at the bottom, thus exposing a portion of the screen that may in fact belong to program windows when taskbar is elsewhere (mine's at the top).
2. The snapshots are all scrambled (will try to provide a screenshot at a later time); this is probably Win9x's fault, although your screenshot script works fine with both fullscreen and thumbnail captures.
Will come back later, gotta go now.

[EDIT]
3. How about multi-monitor environment? :wink:

Here's what I meant with taskbar spacing and scrambled snapshots:
Image

_________________
AHK tools by Drugwash (AHK 1.0.48.05 and Win98SE)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2009, 7:44 am 
Offline

Joined: October 9th, 2008, 6:04 am
Posts: 180
Location: Finland
it doesnt show all windows, but...

I`M LOVIN` IT !!! :D

Good work indeed...

EDIT:
I doesnt like scite4autoit =P when i start scite it doesnt work anymore, bizarre stuff, ye!

_________________
was i wrong, it makes me a very sad panda!


Last edited by Tseik on February 6th, 2009, 10:38 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2009, 10:26 am 
Offline

Joined: May 14th, 2008, 9:48 pm
Posts: 110
I would recommend restoring all the windows before you go to show them. The reason why those windows don't show is cause they are minimized.

Code:
WinRestore [, WinTitle, WinText, ExcludeTitle, ExcludeText]

________
SILVER SURFER VAPORIZER


Last edited by jmanx on February 10th, 2011, 9:40 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2009, 1:26 pm 
Offline

Joined: December 13th, 2006, 7:10 am
Posts: 118
holomind wrote:
I use the alternative shell Litestep with Windows XP. Could this be the reason?

The simple answer is yes. Litestep changes much Internal APIs of Windows and breaks AHK and GDI/GDIPlus functions...


I'm using litestep for years and your script works (but I didn't try the lastest drops)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2009, 11:16 am 
Offline

Joined: March 16th, 2007, 9:50 am
Posts: 4
jmanx wrote:
I would recommend restoring all the windows before you go to show them. The reason why those windows don't show is cause they are minimized.

Code:
WinRestore [, WinTitle, WinText, ExcludeTitle, ExcludeText]


Where it would be this line?

And could anyone use this function to include icons, it's from ALT-TAB replacement with icons and window titles http://www.autohotkey.com/forum/viewtopic.php?t=6422&highlight=alt+tab+list

Quote:
Get_Window_Icon(wid, Use_Large_Icons_Current) ; (window id, whether to get large icons)
{
Local NR_temp, h_icon
Window_Found_Count += 1
; check status of window - if window is responding or "Not Responding"
NR_temp =0 ; init
h_icon =
Responding := DllCall("SendMessageTimeout", "UInt", wid, "UInt", 0x0, "Int", 0, "Int", 0, "UInt", 0x2, "UInt", 150, "UInt *", NR_temp) ; 150 = timeout in millisecs
If (Responding)
{
; WM_GETICON values - ICON_SMALL =0, ICON_BIG =1, ICON_SMALL2 =2
If Use_Large_Icons_Current =1
{
SendMessage, 0x7F, 1, 0,, ahk_id %wid%
h_icon := ErrorLevel
}
If ( ! h_icon )
{
SendMessage, 0x7F, 2, 0,, ahk_id %wid%
h_icon := ErrorLevel
If ( ! h_icon )
{
SendMessage, 0x7F, 0, 0,, ahk_id %wid%
h_icon := ErrorLevel
If ( ! h_icon )
{
If Use_Large_Icons_Current =1
h_icon := DllCall( "GetClassLong", "uint", wid, "int", -14 ) ; GCL_HICON is -14
If ( ! h_icon )
{
h_icon := DllCall( "GetClassLong", "uint", wid, "int", -34 ) ; GCL_HICONSM is -34
If ( ! h_icon )
h_icon := DllCall( "LoadIcon", "uint", 0, "uint", 32512 ) ; IDI_APPLICATION is 32512
}
}
}
}
}
If ! ( h_icon = "" or h_icon = "FAIL") ; Add the HICON directly to the icon list
Gui_Icon_Number := DllCall("ImageList_ReplaceIcon", UInt, ImageListID1, Int, -1, UInt, h_icon)
Else ; use a generic icon
Gui_Icon_Number := IL_Add(ImageListID1, "shell32.dll" , 3)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2009, 4:46 am 
This is a branch from the official version from the Wiki. I use this one but it was strange when I came here back to see for updates...at wiki it is still 1.0x :)

I made some combination...turned off the tooltips and destroyed the desktop (I prefer black image .. or maybe some other solid color)

WinRestore will be probably good idea.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2009, 4:51 am 
Sometimes when there is a gap (empty slot) it is filled with part of the previous item. Partial thumbnail from previos win+tab. Can someone track this error.

For some application there is no content from the inside of the window (open office for example. Only the border + title of the window).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2009, 10:37 pm 
Offline

Joined: January 13th, 2008, 6:00 pm
Posts: 115
To include minimized windows, I added the following two lines:
GroupAdd, AllWindows ; inserted at the autoexecute section at the top
WinRestore, ahk_group AllWindows ; inserted in the Window_Choose subroutine as shown below

Code:
Window_Choose:
   WinGet ActiveID, ID, A
   WinRestore, ahk_group AllWindows
   SetTimer Window_Choose_Thread, 0       ; new thread to make thumbnail draws interruptible
Return


It looks like development on this has stopped or paused. It works great, and I'm really appreciative of those who made it![/code][/i]


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 292 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Bing [Bot], Cristi®, jrav and 14 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