Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Min2Tray v1.7.9 - minimize window to tray & much more!


  • Please log in to reply
224 replies to this topic
Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005

He's asking:
How do you hide the Min2Tray icon? The "#NoTrayIcon" in the code isn't working.
I have the same question. I'd like to be able to use the features of Min2Try without the main application icon appearing in my taskbar. Could you please help me accomplish this?

well, for Min2Tray v1.7.9 try uncommenting line 1081 in Min2Tray.ahk.
this should turn off icon creation for the "starter" a.k.a. main app.

also, check out sub routine "h_StealthModeToggle".
StealthMode hotkey will hide all icons of Min2Tray (main app and all "helpers" a.k.a. minimized windows).

Caspid
  • Members
  • 17 posts
  • Last active: Mar 21 2014 05:43 PM
  • Joined: 21 Dec 2010

He's asking:
How do you hide the Min2Tray icon? The "#NoTrayIcon" in the code isn't working.
I have the same question. I'd like to be able to use the features of Min2Try without the main application icon appearing in my system tray. Could you please help me accomplish this?

well, for Min2Tray v1.7.9 try uncommenting line 1081 in Min2Tray.ahk.
this should turn off icon creation for the "starter" a.k.a. main app.

also, check out sub routine "h_StealthModeToggle".
StealthMode hotkey will hide all icons of Min2Tray (main app and all "helpers" a.k.a. minimized windows).

This line? <!-- m -->http://i.imgur.com/nBopX.png<!-- m -->
It's already uncommented. I tried commenting it, and that didn't work.
The Stealth Mode isn't quite what I'm looking for - I just want Min2Tray to run in the background (no statusbar icon) and allow me to, well, minimize things to the tray. Help much appreciated. Thanks :)

Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005

This line? <!-- m -->http://i.imgur.com/nBopX.png<!-- m -->
It's already uncommented. I tried commenting it, and that didn't work.
The Stealth Mode isn't quite what I'm looking for - I just want Min2Tray to run in the background (no statusbar icon) and allow me to, well, minimize things to the tray. Help much appreciated. Thanks :)

sorry man, my bad :cry:
you have to comment out two lines (1080 and 1081) like this:
   IniWrite, %A_Now%, %m2t_lockFileName%, M2Tlock, Date

   OnExit, h_QuitStarter
;   Gosub, m2t_SetTimedCheck
;   f_ShowTrayIcon( h_StarterIcon, h_StarterIcon# )

   ; --- modifiy registry settings
now the main app ("starter") won't have an icon in the system tray, only minimized windows will have one.
you can make the starter icon re-appear by hitting the StealthMode hotkey (CTRL+WIN+ALT+PAGEUP by default).

  • Guests
  • Last active:
  • Joined: --

after starting this script there will be a system tray-icon (looking like AHK's, but you my specify another icon file) that will hide the window with "win_title" in its window title by one-time clicking on the tray icon. the second click will unhide and activate the window again.
to get the window title of your program, use the Window Spy utility provided by AHK. or just guess :shock:

Nice. I've tried it, it works pretty much as expected. I guess it would be not so difficult to modify your original script by me to work like this for my personal use.
Thanks and best regards!

Caspid
  • Members
  • 17 posts
  • Last active: Mar 21 2014 05:43 PM
  • Joined: 21 Dec 2010

This line? <!-- m -->http://i.imgur.com/nBopX.png<!-- m -->
It's already uncommented. I tried commenting it, and that didn't work.
The Stealth Mode isn't quite what I'm looking for - I just want Min2Tray to run in the background (no statusbar icon) and allow me to, well, minimize things to the tray. Help much appreciated. Thanks :)

sorry man, my bad :cry:
you have to comment out two lines (1080 and 1081) like this:
   IniWrite, %A_Now%, %m2t_lockFileName%, M2Tlock, Date

   OnExit, h_QuitStarter
;   Gosub, m2t_SetTimedCheck
;   f_ShowTrayIcon( h_StarterIcon, h_StarterIcon# )

   ; --- modifiy registry settings
now the main app ("starter") won't have an icon in the system tray, only minimized windows will have one.
you can make the starter icon re-appear by hitting the StealthMode hotkey (CTRL+WIN+ALT+PAGEUP by default).

Great stuff, thanks a ton!

Livin
  • Guests
  • Last active:
  • Joined: --
Junyx
Do you think you could add the ability to have a watchdog move an app window to a specific monitor/display? This is critical for if something steals focus and that window does not behave... ie opens back up on the wrong display.

XBMC has a tendency to launch on the wrong display - and it often will lose focus then when told to maximize, it does on the desktop, not the display it was originally on.

thx!

Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005

Do you think you could add the ability to have a watchdog move an app window to a specific monitor/display? This is critical for if something steals focus and that window does not behave... ie opens back up on the wrong display.
XBMC has a tendency to launch on the wrong display - and it often will lose focus then when told to maximize, it does on the desktop, not the display it was originally on.

no, there are no plans on adding such a feature.
i couldn't test it, though... just got one screen :cry:

but i think you could write a small AHK-script by yourself to accomplish the job.

Junyx

Urock
  • Members
  • 2 posts
  • Last active: Aug 15 2012 03:45 PM
  • Joined: 15 Aug 2012
This program rockkkk!!!! You my friend are awesome! I have stumbled upon this holy grail today! T'is a good day. On behalf of the internet, THANK YOU!

I do have a request (not that your program isn't awesome enough already) for a future update if you are not busy. I've been using another AHK program call Sweptaway http://lifehacker.co...ws?tag=software and it does automatic minimize (to task bar only, which is the drawback) after a preset time (in seconds, but I prefer milliseconds) when the windows is not active. I believes he also posted his source code, but I'll put it here also just in case. I'm a little slow with my third mouse button sometime and was wondering if you can incorporate his auto minimize after a certain amount of time into your program. His program also uses an "Exclude" to exclude programs that he doesn't want to automatically minizes, but I find it too much troublesome since exclude a lot of programs. If you can make it "Include" instead, that would be much better.

Again, thank you very much for your creation!

; Swept Away
; Author:         Adam Pash <[email protected]>
; A simple implementation of Spirited Away (http://www.versiontracker.com/dyn/moreinfo/macosx/24877) for Windows
; for Windows:
; Script Function:
;	Designed to minimize unused windows after a pre-defined time 
;	useful for uncluttering your active desktop
;	

#SingleInstance,Force 
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, "%A_ScriptDir%"
DetectHiddenWindows,Off
Gosub,GetProcesses
Gosub,READINI
Gosub,TRAYMENU
Gosub,RESOURCES
collection=
disable := 0
currentTime = %A_Now%
SetTimer, Start, %PollTime%

GetProcesses:
WinGet,windows,List
Loop, %windows% 
{
	StringTrimLeft,windowID,windows%A_Index%,0
	WinGet,process,ProcessName,ahk_id %windowID%
	processes = %processes%,%process%
}
return

START:
WinGet,windows,List
Loop, %windows%
{
	StringTrimLeft,windowID,windows%A_Index%,0
;	WinGet,processID,PID,ahk_id %windowID%
;	next := A_Index + 1
;	StringTrimLeft,windowID2,windows%next%,0
;	WinGet,processID2,PID,ahk_id %windowID2%
;	if (processID = processID2)
;		continue
	if collection not contains %windowID%
	{
		WinGet,winState,MinMax,ahk_id %windowID%
		if winState != -1
		{
			WinGetTitle,title,ahk_id %windowID%
			if title not contains Program Manager
			{
				if title <>
				{
					WinGet,controls,ControlList,ahk_id %windowID%
					if controls not contains SysPager 
					{
						WinGet,processName,ProcessName,ahk_id %windowID%
						if processName not contains .scr
						{
							if exclude not contains %processName%
							{
								collection = %collection%,%windowID%
								%windowID%_Now = %A_Now% 			
								StringTrimLeft,windowID_Now,%windowID%_Now,0
								Menu,ExcludeSub,Add,%processName%,EXCLUDE
								Menu,TRAY,Add,&Exclude,:ExcludeSub
								;MsgBox, exclude didn't contain process
								currentTime = %A_Now%
							}
							else 
							{
							
									Menu,ExcludeSub,Add,%processName%,EXCLUDE
									Menu,ExcludeSub,Check,%processName%
									Menu,TRAY,Add,&Exclude,:ExcludeSub
						
								IfExist collection\%windowID%
								{
									StringReplace,collection,collection,%windowID%,
								}
							}
						}
					;}
					}
				}
			}
		}
		else
		{
			StringReplace,collection,collection,%windowID%,
		}
	}
	IfWinActive, ahk_id %windowID%
	{
		%windowID%_Now = %A_Now% 			
		StringTrimLeft,windowID_Now,%windowID%_Now,0	
	}
}
Loop,Parse,collection,CSV
{
	if A_Index != 1
	{
		StringTrimLeft,windowTime,%A_LoopField%_Now,0	
		diff = %windowTime%
		EnvSub,diff,A_Now,seconds
		Transform,diff,Abs,diff
		if diff > %sweepTime%
		{
			WinGet,mini,MinMax,ahk_id %A_LoopField% 
			if mini != -1 
			{
				IfWinNotActive,ahk_id %A_LoopField%
				{
					;WinMinimize,ahk_id %A_LoopField%
					PostMessage, 0x112, 0xF020,,, ahk_id %A_LoopField% ; 0x112 = WM_SYSCOMMAND, 0xF020 = SC_MINIMIZE
					;WinHide,ahk_id %A_LoopField%
					StringReplace,collection,collection,`,%A_LoopField%,,All
				}
			}
			else
				StringReplace,collection,collection,`,%A_LoopField%,,All
		}
	}
}
return

TRAYMENU:
Menu,TRAY,NoStandard 
Menu,TRAY,DeleteAll 
Menu,TRAY,Add,&Preferences,PREFS
Loop,Parse,processes,CSV 
{
	if A_LoopField <>
	{
		Menu,ExcludeSub,Add,%A_LoopField%,EXCLUDE
		if exclude contains %A_LoopField%
			Menu,ExcludeSub,Check,%A_LoopField%		
	}
}
Menu,TRAY,Add,&Exclude,:ExcludeSub
Menu,TRAY,Add,&Help,HELP
Menu,TRAY,Add
Menu,TRAY,Add,&About...,ABOUT
Menu,TRAY,Add,&Disable,DISABLE
if disable = 1
	Menu,Tray,Check,&Disable
Menu,TRAY,Add,E&xit,EXIT
Menu,TRAY,Default,&Preferences
Menu,Tray,Tip,Swept Away
Return

PREFS:
Gui,Destroy
Gui, Add, Text, x226 y40 w-10 h-10 , Text
Gui, Add, UpDown, x33266 y33010 w-33270 h-34060 , UpDown
Gui, Font, S12 CDefault, Arial
Gui, Add, Text, x16 y10 w170 h20 , Time before minimizing:
Gui, Add, Edit, vSeconds x26 y30 w100 h30 , %sweepTime%
IniRead,PollTime,sweptaway.ini,Preferences,PollTime
Gui, Add, Text, x16 y70 w330 h20 , Polling time in milliseconds:
Gui, Font, S10 CDefault, Arial
;Gui, Add, Text, x26 y90 h40 w330, This setting determines how often Swept Away checks out which windows are active.  If you're having CPU problems, try adjusting the poll time to a higher number.
Gui, Add, Text, x186 y10 w80 h20 , (in seconds)
Gui, Add, Text, x210 y70 w120 h20 ,(requires restart)
Gui, Add, Text, x130 y100 w120 h20 , (1000 = 1 second)
Gui, Font, S12 CDefault, Arial
Gui, Add, Edit, vPoll x26 y90 w100 h30 , %PollTime%
Gui, Font, S10 CDefault, Arial
Gui, Font, S12 CDefault, Arial
Gui, Add, CheckBox,vCheck x46 y130 w240 h20 Checked%update%, Check for updates on start up
IniRead,OnStartup,sweptaway.ini,Preferences,Startup
Gui, Add,Checkbox, vStartup x46 yp+30 Checked%OnStartup%,Run Swept Away on start up
Gui, Font, S10 CDefault, Arial
Gui, Add, Button, x156 y180 w100 h30 gOK default,&OK
Gui, Add, Button, x266 y180 w90 h30 gCANCEL, Cancel
; Generated using SmartGUI Creator 4.0
Gui, Show, h215 w363,Swept Away Preferences
Return

OK:
Gui,Submit
Gui,Destroy
IniWrite,%Seconds%,sweptaway.ini,Preferences,Timer
IniWrite,%Check%,sweptaway.ini,Preferences,UpdateCheck
IniWrite,%Poll%,sweptaway.ini,Preferences,PollTime
If Startup = 1
{
	IfNotExist %A_StartMenu%\Programs\Startup\Swept Away.lnk
		;Get icon for shortcut link:
		;1st from compiled EXE
		if %A_IsCompiled%
		{
			IconLocation=%A_ScriptFullPath%
		}
		;2nd from icon in resources folder
		else IfExist %A_WorkingDir%\resources\sweptaway.ico
		{
			IconLocation=%A_WorkingDir%\resources\sweptaway.ico
		}
		;3rd from the AutoHotkey application itself
		else
		{
			IconLocation=%A_AhkPath%
		}
		;use %A_ScriptFullPath% instead of %A_WorkingDir%\texter.exe
		;to allow compatibility with source version
		FileCreateShortcut,%A_ScriptFullPath%,%A_StartMenu%\Programs\Startup\Swept Away.lnk,%A_WorkingDir%,,,%IconLocation%
}
else
{
	IfExist %A_StartMenu%\Programs\Startup\Swept Away.lnk
	{
		FileDelete %A_StartMenu%\Programs\Startup\Swept Away.lnk
	}
}
IniWrite,%Startup%,sweptaway.ini,Preferences,Startup
Gosub,READINI
return

CANCEL:
Gui,Destroy
return

EXCLUDE:
Menu,ExcludeSub,ToggleCheck,%A_ThisMenuItem%
if exclude not contains %A_ThisMenuItem%
	IniWrite,%exclude%`,%A_ThisMenuItem%,sweptaway.ini,Preferences,Exclusions
else
{
	StringReplace,exclude,exclude,`,%A_ThisMenuItem%,
	IniWrite,%exclude%,sweptaway.ini,Preferences,Exclusions
}
IniRead,exclude,sweptaway.ini,Preferences,Exclusions
return

HELP:
Run,http://lifehacker.com/software//lifehacker-code-swept-away-windows-255055.php
return

ABOUT:
Gui,2: Destroy
Gui,2: Add, Picture, x16 y20 w60 h60 , sweptaway_logo.png
Gui,2: Font, S28 CDefault Bold, Verdana
Gui,2: Add, Text, x96 y20 w340 h60 , Swept Away 0.3
Gui,2: Font, S8 CDefault, Arial
Gui,2: Add, Text, x36 y100 w380 h60 , Swept Away monitors your applications and minimizes any windows that have been inactive for a user-defined period of time.
Gui,2: Add, Text, x36 y145 w380 h70 , Swept Away is written by Adam Pash and distributed by Lifehacker under the GNU Public License.  For detail on how to use Swept Away`, check out the
Gui,2: Font, S8 Cblue Underline, Arial
Gui,2: Add, Text, x116 y175 w170 h30 gHELP, Swept Away homepage
; Generated using SmartGUI Creator 4.0
Gui,2: Show, h225 w459, About Swept Away
Return

DISABLE:
Menu,TRAY,ToggleCheck,%A_ThisMenuItem%
disable := 1 - disable
if disable = 1
{
	loop
		if disable = 0
			break
		else
			sleep,1000
}
else
	Goto,Start
return

READINI:
IfNotExist sweptaway.ini 
{
	MsgBox,4,Check for Updates?,Would you like Swept Away to automatically check for updates when it's run?
	IfMsgBox,Yes
		updatereply = 1
	else
		updatereply = 0
}
sweepTime := GetValFromIni("Preferences","Timer",300)
exclude := GetValFromIni("Preferences","Exclusions","dropcloth.exe,synergys.exe,Workrave.exe,SweptAway.exe,rundll32.exe,sidebar.exe")
update := GetValFromIni("Preferences","UpdateCheck",updatereply)
PollTime := GetValFromIni("Preferences","PollTime",300)
IniWrite,0.3,sweptaway.ini,Preferences,Version
if update = 1
{
	SetTimer,UpdateCheck,20000
}
return

GetValFromIni(section, key, default)
{
	IniRead,IniVal,sweptaway.ini,%section%,%key%
	if IniVal = ERROR
	{
		IniWrite,%default%,sweptaway.ini,%section%,%key%
		IniVal := default
	}
	return IniVal
}

UpdateCheck:
SetTimer,UpdateCheck,Off
UrlDownloadToFile,http://svn.adampash.com/sweptaway/CurrentVersion.txt,%A_WorkingDir%\VersionCheck.txt
if ErrorLevel = 0
{
	FileReadLine, Latest, %A_WorkingDir%\VersionCheck.txt,1
	IniRead,Current,sweptaway.ini,Preferences,Version
	if Latest != %Current%
	{
		MsgBox,4,A new version of Swept Away is available!,Would you like to visit the Swept Away homepage and download the latest version?
		IfMsgBox,Yes
			Run, http://lifehacker.com/software//lifehacker-code-swept-away-windows-255055.php
	}
	FileDelete,%A_WorkingDir%\VersionCheck.txt ;; delete version check
}
return

RESOURCES:
FileInstall,swept away logo.png,%A_ScriptDir%\sweptaway_logo.png,0
return


EXIT:
ExitApp 
return


Urock
  • Members
  • 2 posts
  • Last active: Aug 15 2012 03:45 PM
  • Joined: 15 Aug 2012
Stupid new user question:

How do I disable third button minimize to tray after I use the boss keys to go into stealth mode?

I use another program (Autocad) that uses the middle button for panning. How do I exclude this program from this list?

Thanks.

Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005

Stupid new user question:
How do I disable third button minimize to tray after I use the boss keys to go into stealth mode?
I use another program (Autocad) that uses the middle button for panning. How do I exclude this program from this list?
Thanks.

there are no stupid questions :-)

if i understood your question right, i think you should use "third mouse button on title bar click" as option to minimize a window.

you cannot exclude a program from minimizing via "minmize hotkey" or third mouse button.
there's only the exclude list for the bosskey...

regarding your other feature request: i'll think about including it in a future version of Min2Tray!

ni.va
  • Members
  • 18 posts
  • Last active: Feb 10 2013 10:34 PM
  • Joined: 30 Oct 2011

@jhefko:
well, now it's time for some code 8)

;----------------------------------------------------------------------------
; WinHideShowIcon.ahk
; created: 2012/04/20
;----------------------------------------------------------------------------

#UseHook
#NoEnv
#NoTrayIcon
#Persistent
#SingleInstance force
SetTitleMatchMode, 2
DetectHiddenWindows, On

win_title=Rechner ahk_class SciCalc
;icon_file=%A_ScriptDir%\whsi.ico
is_hidden := FALSE

; setup tray menu+icon
Menu, TRAY, NoStandard
Menu, TRAY, Add, WinHideShowIcon, un_hide
Menu, TRAY, Default, WinHideShowIcon
Menu, TRAY, Add
Menu, TRAY, Add, &Quit, tray_quit
Menu, TRAY, Tip, WinHideShowIcon
Menu, TRAY, Click, 1
;Menu, TRAY, Icon, %icon_file%, 1, 1
Menu, TRAY, Icon
Return

un_hide:
   IfWinNotExist, %win_title%
      Return

   If ( is_hidden ) {
      is_hidden := FALSE
      WinShow
      WinActivate
   }
   Else {
      is_hidden := TRUE
      WinHide
   }
   Return
   
tray_quit:
   ExitApp

after starting this script there will be a system tray-icon (looking like AHK's, but you my specify another icon file) that will hide the window with "win_title" in its window title by one-time clicking on the tray icon. the second click will unhide and activate the window again.
to get the window title of your program, use the Window Spy utility provided by AHK. or just guess :shock:


Can I hide sticky notes from taskbar with this???

Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005

Can I hide sticky notes from taskbar with this???

where can i download the program for testing?

ni.va
  • Members
  • 18 posts
  • Last active: Feb 10 2013 10:34 PM
  • Joined: 30 Oct 2011

Can I hide sticky notes from taskbar with this???

where can i download the program for testing?


I mean The Sticky Notes on Windows 7 ... for accessing the program just type "sti" ( without quotes) in start menu search bar.

Caspid
  • Members
  • 17 posts
  • Last active: Mar 21 2014 05:43 PM
  • Joined: 21 Dec 2010
I haven't been able to get the custom icons working - nothing appears after I check the option and click Apply.
Where are they stored and can I edit them manually somehow?

Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005

I haven't been able to get the custom icons working - nothing appears after I check the option and click Apply.
Where are they stored and can I edit them manually somehow?

if custom icon (ci) is already checked, uncheck it now and hit button apply/ok.

return to the prefs dialog of the minimized window.
check ci and hit button apply/ok.

now a dialog window should appear showing a range of icons of the program the minimized window belongs to.
you could select one icon from this list or select another EXE/DLL/ICO file providing icons.

if it won't work for you just ping me here - i need to know what win version you use and other stuff...
cheers