OnExit handle_exit Hotkey, F12, start_expose Hotkey, MButton, start_expose Hotkey, +F12, handle_exit Main: Gosub, read_config ; now wait for keypress Return read_config: gui_active := 0 translevel := 225 delay_guiinit := 50 fade_delay := 5 fade_steps := 5 return start_expose: ; toggle off if already active if gui_active = 1 { Gosub, stop_expose return } ; show gui gui_active := 1 Gosub, create_gui ; prepare gui to draw onto it Gosub, calculate_sizes ; sets "cols" , "rows" Gosub, draw_thumbnails return stop_expose: ; hide gui if gui_active = 1 { Gosub, destroy_gui gui_active = 0 } return calculate_sizes: num_win := get_num_win() cols := ceil( sqrt( num_win )) rows := ceil( sqrt( num_win )) ; if ( cols * ( rows -1 ) ) >= num_win ) { rows -- } ; optimize space thumb_w := ceil( A_ScreenWidth / cols ) thumb_h := ceil( A_ScreenHeight / cols ) ; using rows would distort image ! ; now we could do some fancy animations ; i will skip this for a moment return draw_thumbnails: pos_x := 0 pos_y := 0 win_now := 0 WinGet ids, list,,,Program Manager ; all active windows-tasks (processes) Loop %ids% { task_id := ids%a_index% ; id of this window WinGetPos ,,, w, h, ahk_id %task_id% WinGetTitle,title, ahk_id %task_id% if (w > 300 and h > 200 and title<>"Expose") { ; small windows not shown (eg taskbar) win_now++ Gui 1: Add, Pic , gActivateWin x%pos_x% y%pos_y% w%thumb_w% h%thumb_h% vPic%win_now% ; register "onclick" pwin := DllCall("PrintWindow", UInt,task_id, UInt,hdc_buffer, UInt,0) ;tooltip, pwin %pwin% task_ids_%win_now% := task_id ; paint/copy ratio := A_ScreenWidth / A_ScreenHeight thumb_w2 := w / cols thumb_h2 := h / rows center_x := (thumb_w - thumb_w2 ) / 2 center_y := (thumb_h - thumb_h2 ) / 2 DllCall("gdi32.dll\StretchBlt", UInt,hdc_frame, Int,pos_x + center_x, Int,pos_y+center_y, Int,thumb_w2, Int, thumb_h2 , UInt,hdc_buffer, Int,0, Int,0, Int,w, Int,h ,UInt,0xCC0020) ; SRCCOPY pos_x += thumb_w if ( pos_x >= (A_ScreenWidth ) ) { pos_x :=0 pos_y += thumb_h } } } Gosub, fade_in return fade_in: Gui 1: +LastFound ; Make the GUI window the last found window. loop %fade_steps% { WinSet, Transparent, % a_index * translevel / fade_steps sleep %fade_delay% } Gui 1: +LastFound ; Make the GUI window the last found window. WinSet, Transparent, off return fade_out: Gui 1: +LastFound ; Make the GUI window the last found window. loop %fade_steps% { WinSet, Transparent, % translevel - (a_index * translevel / fade_steps) sleep %fade_delay% } return ActivateWin: StringReplace, pos , A_GuiControl, Pic ; find the clicked pic-id task_id := task_ids_%pos% WinActivate, ahk_id %task_id% Gosub, destroy_gui return get_num_win() { num_win := 0 ; WinGet ids, list,,,Program Manager ; all active windows-tasks (processes) Loop %ids% { task_id := ids%a_index% ; id of this window WinGetPos ,,, w, h, ahk_id %task_id% WinGetTitle,title, ahk_id %task_id% if (w > 300 and h > 200 and title<>"Expose") { ; small windows not shown (eg taskbar) num_win++ } } return num_win ; } create_gui: Gui 1: +AlwaysOnTop -Caption +Owner +Background #000000 ; window for the dock Gui 1: Color, #333333 Gui 1: +LastFound ; Make the GUI window the last found window. WinSet, Transparent, 0 ; %translevel% Gui 1: Show, w%A_ScreenWidth% h%A_ScreenHeight% x0 y0, Expose WinGet hw_frame, id, Expose 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) DllCall( "gdi32.dll\SelectObject", UInt,hdc_buffer, UInt,hbm_buffer) sleep, %delay_gui_init% ; give windows time to initialize return destroy_gui: Gosub, fade_out Gui 1: Destroy DllCall("gdi32.dll\DeleteObject", UInt,hbm_buffer) DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame ) DllCall("gdi32.dll\DeleteDC", UInt,hdc_buffer) return handle_exit: ; clean up Gosub, stop_expose ExitApp