; Window_RollUp_or_MinimizeToTray Integrated Function ; This script integrates the functionality of rolling up any window ; to its title bar with the ability to minimize the window to the tray. ; You can do either, independently. You can restore windows ; individually or all at once. If the script exits for any reason, ; all the windows, whether rolled or minimized or both, will be restored. ; The original scripts are separate and are by Chris (minimize to tray) ; and Rajat (window shading). ; If you prefer to have the tray menu empty of all the standard items, ; then delete the Y from the following: mwt_StandardMenu = Y ; The next 3 settings allow consecutive hotkey usage without releasing ; the modifier(s). They are not needed if you choose to have the ; script use the keyboard hook via #InstallKeybdHook or other means: #HotkeyModifierTimeout 100 SetWinDelay 10 SetKeyDelay 0 if not mwt_StandardMenu { Menu, Tray, NoStandard Menu, Tray, Add, E&xit, OnExitRoutine } Menu, Tray, Add Menu, Tray, Add, Show &All Ahk-Hidden Windows, RestoreAllFromTray Menu, Tray, Add, Show and &Unroll Windows, RestoreAllWindows Menu, Tray, Add, snd&vol32.exe /tray, AhkTray_Sound ; optional Menu, Tray, Add ; separates Menu commands from list of Ahk-hidden windows OnExit, OnExitRoutine SplashTextOn,700,70, script updated, `nconfiguration complete Sleep, 300 SplashTextOff ; if you wish to integrate this script into another, ; 1) copy the section above into your existing auto-execute section. ; 2) disregard "return" below, and copy the remaining code anywhere else. ; 3) integrate the OnExitRoutine with your existing OnExit routine, if any. ; 4) remove/rename/integrate any functions with duplicate names return ; END OF AUTO-EXECUTE SECTION ;------------------------------------ OnExitRoutine: Gosub, RestoreAllWindows EXITAPP ; delete this part if you use Rajat's Volume OSD (on-screen display) AhkTray_Sound: Run, C:\WINNT\system32\sndvol32.exe /tray return StringR(in, charsToKeep, charsToTrim="") { StringRight, out, in, %charsToKeep% if charsToTrim StringTrimRight, out, out, %charsToTrim% return out } StringL(in, charsToKeep, charsToTrim="") { StringLeft, out, in, %charsToKeep% if charsToTrim StringTrimLeft, out, out, %charsToTrim% return out } StringM(in, StartChar, Count, L="") { if L = L StringMid, Out, in, %StartChar%, %Count%, L else StringMid, Out, in, %StartChar%, %Count% return out } ;---------------------------------------------------------------------------- #-:: ; roll-up active window Window_RollUp_or_MinimizeToTray("windowRollup") return !#m:: ; hide active window to Ahk tray Window_RollUp_or_MinimizeToTray("minimizeToTray") return +!#m:: RestoreAllFromTray: ; show all windows in Ahk tray Window_RollUp_or_MinimizeToTray("restoreAllFromTray") return RestoreAllWindows: ; show Ahk tray windows + unroll all windows Window_RollUp_or_MinimizeToTray("restoreAllWindows") return ;------------------------------------------------------------------------------ Window_RollUp_or_MinimizeToTray(mode) { if mode = windowRollup Gosub Window_Rollup else if mode = minimizeToTray Gosub mwt_Minimize else if mode = restoreAllFromTray GoSub []_RestoreAllFromTray else if mode = restoreAllWindows { ; []_ indicates this function subroutine name is similar to an external subroutine name Gosub, []_RestoreAllFromTray Gosub, Windows_Unroll } RETURN ;------------------------------- Window_RollUp: ; original is by Rajat. this version in function and modified. static ws_ID_and_Height_List ; RM: Uncomment this next line if this subroutine is to be converted ; into a custom menu item rather than a hotkey. The delay allows ; the active window that was deactivated by the displayed menu to ; become active again: ; Sleep, 200 WinGet, ws_ID, ID, A Loop, Parse, ws_ID_and_Height_List, |, `n { IfInString, A_LoopField, Win%ws_ID% { ; RM: Match found, so this window should be restored (unrolled). WinMove, ahk_id %ws_ID%,,,,, % StringR( A_LoopField, ( StrLen(A_LoopField) - InStr(A_LoopField, "H") ) ) StringReplace, ws_ID_and_Height_List, ws_ID_and_Height_List, |%A_LoopField% return } } WinGetPos,,,, ws_Height, A WinMove, ahk_id %ws_ID%,,,,, 26 ; last param = height of title bar. change to preference ws_ID_and_Height_List = %ws_ID_and_Height_List%|Win%ws_ID%H%ws_Height% ;`n return ;------------------------------- mwt_Minimize: ; revision. original is by Chris Mallett. static mwt_ID_List if WinActive("Program Manager") OR WinActive(ahk_class Shell_TrayWnd) RETURN WinGet, ActiveID, ID, A WinGetTitle, ActiveTitle, ahk_id %ActiveID% ; CM: Because hiding the window won't deactivate it, activate the window ; beneath this one (if any). I tried other ways, but they wound up ; activating the task bar. This way sends the active window (which is ; about to be hidden) to the back of the stack, which seems best: Send, !{esc} ; CM: Don't hide until after the above, since by default hidden windows are ; not detected: WinHide, ahk_id %ActiveID% ; Modify the list of unique identifiers, and add the item to the menu ; if the ID doesn't already exist in the list, which can happen if the ; window's app unhid it. ActiveTitle := StringL(ActiveTitle, 240) ifNotInString, mwt_ID_List, %ActiveTitle% { mwt_ID_List = %mwt_ID_List%%ActiveTitle%`n Menu, Tray, add, %ActiveTitle%, RestoreWindowFromTrayMenu } else ifNotInString, mwt_ID_List, % ActiveTitle . " ¤_" . ActiveID { mwt_ID := ActiveTitle . " ¤_" . ActiveID mwt_ID_List = %mwt_ID_List%%mwt_ID%`n ;mwt_ID_List := mwt_ID_List . ActiveTitle . " ¤_" . ActiveID . "`n" ;msgbox %mwt_ID_List% Menu, Tray, add, %mwt_ID%, RestoreWindowFromTrayMenu } return ;------------------------------- RestoreWindowFromTrayMenu: ; menu: show Ahk-hidden window Menu, Tray, delete, %A_ThisMenuItem% ifNotInString, A_ThisMenuItem, % " ¤_" { WinShow, % A_ThisMenuItem WinActivate % A_ThisMenuItem ; Sometimes needed. } else { mwt_ID := StringR( A_ThisMenuItem, ( StrLen(A_ThisMenuItem) - InStr(A_ThisMenuItem, "¤_") - 1) ) WinShow, ahk_id %mwt_ID% WinActivate ahk_id %mwt_ID% ; Sometimes needed. } StringReplace, mwt_ID_List, mwt_ID_List, %A_ThisMenuItem%`n return []_RestoreAllFromTray: ; menu/OnExit: show all Ahk-hidden windows if mwt_ID_List = RETURN Loop, Parse, mwt_ID_List, `n, `r { ;msgbox %A_LoopField% if A_LoopField = BREAK ifNotInString, A_LoopField, % " ¤_" { WinShow, % A_LoopField WinActivate % A_LoopField } else { mwt_ID := StringR( A_LoopField, ( StrLen(A_LoopField) - InStr(A_LoopField, "¤_") - 1) ) WinShow, ahk_id %mwt_ID% WinActivate ahk_id %mwt_ID% } Menu, Tray, delete, %A_LoopField% } mwt_ID_List = return Windows_Unroll: ; menu/OnExit: unrolls any rolled up windows Loop, Parse, ws_ID_and_Height_List, |, `n { if A_LoopField = ; First field in list is normally blank. continue ; So skip it. ws_ID := StringM( A_LoopField, "4", InStr(A_LoopField, "H") - 4 ) ; in, start, count WinActivate, ahk_id %ws_ID% ; auto-restores WinWaitActive, ahk_id %ws_ID% WinMove, ahk_id %ws_ID% ,,,, , % StringR(A_LoopField, (StrLen(A_LoopField) - InStr(A_LoopField, "H"))) } ws_ID_and_Height_List = return } ;=========================== End Function: Window_RollUp_or_MinimizeToTray()
Window_RollUp_or_MinimizeToTray() integrated
Started by
Decarlo110
, Oct 29 2005 08:07 PM
1 reply to this topic
#1
-
Posted 29 October 2005 - 08:07 PM
1) The Open Source Definition http://www.opensourc...ition_plain.php
2) Intuitive. Logical. Versatile. Adaptable. <>
2) Intuitive. Logical. Versatile. Adaptable. <
Nice Idea but... the function
Line 99 to 103
It doesn't seem to work but I love the idea and also could you make a command that unhides every thing that you hide :?:
and The Tray Icon for this program just doesn't show up at all...
Line 99 to 103
+!#m:: RestoreAllFromTray: ; show all windows in Ahk tray Window_RollUp_or_MinimizeToTray("restoreAllFromTray") return
It doesn't seem to work but I love the idea and also could you make a command that unhides every thing that you hide :?:
and The Tray Icon for this program just doesn't show up at all...
#2
-
Posted 11 November 2006 - 06:06 PM