FileInstall,i_view32.exe,i_view32.exe,0 FileInstall,s.gif,s.gif,0 #SingleInstance ,Force ; configuration SetBatchLines ,-1 SetWinDelay ,0 CoordMode ,Mouse,Screen CoordMode ,ToolTip,Screen iview = %A_ScriptDir%\i_view32.exe spacer = %A_ScriptDir%\s.gif FileCreateDir , %Temp%\DeskMan lastactiveid = realminimize = 0 maxthumbs = 14 ; how many thumbs to show ( screenheight / maxthumbs = thumbheight )? screenwidth = %A_ScreenWidth% ; eg. 1400 screenheight = %A_ScreenHeight% ; eg. 1050 repainttimer = 1000 ; msecs repaintwait = 10 ; times of repaint until redo thumbheight := screenheight / maxthumbs ; height of thumbnails thumbwidth := screenwidth / maxthumbs ; witdh of dock (also thumbnail-width) workwidth := screenwidth - thumbwidth - 8 - 30 ; 40 is for taskbar on right side (change this for a fix) dockoffsetleft := workwidth + 8 workheight := screenheight - 4 workheighthalf := ceil( ( screenheight - 4 ) / 2 ) workwidthhalf := ceil( ( workwidth ) / 2 ) minwidth := screenwidth / 2 y=0 ; add some picture-placeholder (dock-positions) Loop, %maxthumbs% { Gui, Add, Pic, gRestoreWin x0 y%y% vPic%a_index% ; add dock-slots to gui y += %thumbheight% ; define height of eg. 150 } Gui, -Caption ; window-style / chrome Gui, +ToolWindow Gui, Show, x%dockoffsetleft% y+-20 w%thumbwidth% h%screenheight% , DeskMan - Dock ; display window/Toolbar WinGet, deskman_id, ID, DeskMan - Dock ; fetch deskman_id for fast checks Gosub, TRAYMENU ; init tray Sleep 500 Gosub, WinBottom Gosub , RefreshDock ; first run minimize all ; start loop Return #Up:: ResizeWin( 4, 0, workwidth, workheighthalf ) Return #Down:: ResizeWin( 4, workheighthalf, workwidth, workheighthalf ) Return #Left:: ResizeWin( 4, 0, workwidthhalf, workheight ) Return #Right:: ResizeWin( 4 + workwidthhalf, 0 , workwidthhalf, workheight ) Return #PgUp:: ResizeWin( 4 , 0 , workwidth, workheight ) Return #PgDn:: Send, !{esc} Return ResizeWin( XPos, YPos, XSize, YSize ) { WinGet, active_id, ID, A ; fetch active foreground-window WinGetTitle, title, ahk_id %active_id% ; get Title if ( title = "DeskMan - Dock" ) return WinMove, ahk_id %active_id%, , %XPos% , %YPos% , %XSize% , %YSize% } f10:: RefreshDock: SetTimer, RepaintDock , Off ; clear old timers ; remove thumbnails FileDelete, %Temp%\DeskMan\thumb_*.bmp ; keep active window! WinGet, current_id, ID, A ; start with active Gosub, CaptureThumbActive winIsDocked%capture_id% = 1 capture_id =x ; clear ; loop until current_id is in front (max is all processes) WinGet, ids, list,,, Program Manager loop, %ids% { if ( capture_id <> current_id ) { Gosub, WinBottom Gosub, CaptureThumbActive winIsDocked%capture_id% = 1 } } forcerepaint = 1 Gosub, RepaintDock return ^f9:: RepaintDock: ; remove closed thumbs but dont do much (as this is done in a loop!) SetTimer, RepaintDock , off ; clear old timers ; try to add foreground-window to dock if not in there ( changes are good we hit it shortly after start-new) WinGet, active_id, ID, A WinGetTitle, title, ahk_id %active_id% ; detect and add new windows if ( winIsDocked%active_id% = "" or winIsDockedTitle%active_id% <> title) { winIsDockedTitle%active_id% := title ; store title and repaint if this changes Gosub, CaptureThumbActive winIsDocked%capture_id% = 1 GuiControl,1:,Pic1, *w%thumbwidth% *h%thumbheight% %Temp%\DeskMan\thumb_%capture_id%.bmp } ; test if display has changed ! dockedNewCount = 0 ; start with empty dock Loop, %maxthumbs% { dockIdNew%a_index% = ;clear } ; stack minimized windows into dock ;this way all "non-dead" minimized windows get stacked into dock WinGet, ids, list,,, Program Manager Loop, %ids% { StringTrimRight, id, ids%a_index%, 0 ; find the id of this window if winIsDocked%id% ; is window with this id in dock already ? { dockedNewCount += 1 ; how many slots are used already ? dockIdNew%dockedNewCount% = %id% ; remeber id for this position } } ; fill with spacer if empty loop, %maxthumbs% { val1 := DockId%a_index% val2 := DockIdNew%a_index% if ( val1 <> val2 ) { forcerepaint = 1 } } if forcerepaint <> { dockedCount = 0 ; start with empty dock Loop, %maxthumbs% { dockId%a_index% = ;clear } ; stack minimized windows into dock ;this way all "non-dead" minimized windows get stacked into dock WinGet, ids, list,,, Program Manager Loop, %ids% { StringTrimRight, id, ids%a_index%, 0 ; find the id of this window if winIsDocked%id% ; is window with this id in dock already ? { dockedCount += 1 ; how many slots are used already ? dockId%dockedCount% = %id% ; remeber id for this position ; PAINT IfWinExist , DeskMan - Dock { GuiControl,1:,Pic%dockedCount%, *w%thumbwidth% *h%thumbheight% %Temp%\DeskMan\thumb_%id%.bmp } } } ; fill with spacer if empty loop, %maxthumbs% { if DockId%a_index% = GuiControl,1:,Pic%a_index%, *w%thumbwidth% *h%thumbheight% %spacer% } } ; end forcerepaint forcerepaint = ; try not to draw in next round (but its multithreaded!) somebody can click restore while repaint, SetTimer, RepaintDock , %repainttimer% Return CaptureThumbActive: WinGet, captureactive_id, ID, A winGetTitle, title , ahk_id %captureactive_id% WinGetClass, class, ahk_id %captureactive_id% ;get Class-name capture_id = x if title = DeskMan - Dock ; skip DeskMan Window (recursion!) { return } if class in TPickSessionDlg,TForm,TFormMain,TBaseLoadErrorDlg,TDirectoryViewerForm,Shell_TrayWnd, Progman,tooltips_class32,AutoHotkeyGUI,TForm4,AutoHotkeyGUI ; skip taskman und beyond compare return if title = ; don't add windows with empty titles return Gosub, CaptureThumb return CaptureThumb: capture_id := captureactive_id wingetpos, x, y, width, height, ahk_id %capture_id% ; read width from capture-window w := ceil( thumbwidth ) ; irfanview doesnt like float-numers but integer sizes ! h := ceil( thumbheight ) if ( width < minwidth ) { ; /aspectratio RunWait,%iview% /silent /capture=1 /crop=(0`,0`,%workwidthhalf%`,%workheighthalf%) /resample=(%w%`,%h%) /convert=%Temp%\DeskMan\thumb_%capture_id%.bmp } else { ; /aspectratio w := ceil( thumbwidth ) h := ceil( thumbheight ) RunWait,%iview% /silent /capture=1 /resample=(%w%`,%h%) /convert=%Temp%\DeskMan\thumb_%capture_id%.bmp } return WinBottom: Send, !{esc} return ;---------------------------------------------------------------------- ; ; Restore window size and position ; ; Parameters: ; index - the window index in the window array ; RestoreWin: StringReplace, pos , A_GuiControl, Pic SetTimer, RepaintDock , off Gosub, WinBottom ; undo the click on deskman ; find active window, which is on top of stack, DeskMan is active because of click ; get some lookups forcerepaint = 1 dockIdpos := dockId%pos% id := dockId%pos% if ( winIsDocked%id% <> "" ) { ; activate restored id WinActivate, ahk_id %id% WinGetTitle, title, ahk_id %id% wingetpos, x, y, width, height, ahk_id %id% ; only maximize and move big windows, as small ones eg. dialogboxes dont like maximize if ( width > minwidth ) { WinMove, ahk_id %id%, , 4, 0, %workwidth%, %workheight% } winIsDocked%id% = ; force repaint in next interval } Gosub, RepaintDock Return ^f8:: ReloadScript: Reload ; Assign a hotkey to restart the script. Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached. MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing? IfMsgBox, Yes, Edit Return TRAYMENU: ;Menu,Tray,NoStandard ;Menu,Tray,DeleteAll Menu,Tray,Add,DeskMan,ABOUT Menu,Tray,Add Menu,Tray,Add,&About,ABOUT Menu,Tray,Add,E&xit,EXIT Menu,Tray,Default,DeskMan Return ABOUT: about=DeskMan about=%about%`n about=%about%`nControl all your Windows, similar to Apple-Dock but different ;) about=%about%`n about=%about%`n about=%about%`nThis program uses IrFanView by Irfan Skiljan. about=%about%`n about=%about%`nHolomind @2006 about=%about%`n(based on) Skrommel @2006 www.donationcoders.com/skrommel MsgBox,0,DeskMan,%about% about= Return GuiClose: EXIT: ExitApp