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
Caspid
  • Members
  • 17 posts
  • Last active: Mar 21 2014 05:43 PM
  • Joined: 21 Dec 2010
Nope, I don't get a dialog. I've tried several combinations of opening/closing programs, minimizing to tray/restoring, and checking/unchecking with a fresh install of Min2Tray v1.7.9 on W7 Ultimate x64.

Thanks for the support!

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

Nope, I don't get a dialog. I've tried several combinations of opening/closing programs, minimizing to tray/restoring, and checking/unchecking with a fresh install of Min2Tray v1.7.9 on W7 Ultimate x64.
Thanks for the support!

i'm using win7/32bit and everything seems to work fine.
i can only guess here, but i tihnk it might be related to win7/x64...

perhaps someone else with 64bit win7 could verify 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???
...
I mean The Sticky Notes on Windows 7 ... for accessing the program just type "sti" ( without quotes) in start menu search bar.

try this:
;----------------------------------------------------------------------------
; WinHideShowIcon.ahk
; created:  2012/04/19
; modified: 2012/08/30 - remove taskbar button (the ugly way ;-)
;----------------------------------------------------------------------------

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

win_title=ahk_class Sticky_Notes_Note_Window
;icon_file=%A_ScriptDir%\whsi.ico
is_hidden := FALSE
no_button := 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 ( ! no_button ) {
      WinGet, winID, ID
      f_NoTaskbarButton( winID, "+" )
      no_button := TRUE
   }

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

f_NoTaskbarButton( ws_ID=FALSE, flag="^" ) {
   ; remove taskbar button of window
   ; by toggling WS_EX_TOOLWINDOW
   ; returns FALSE if window does not exist, otherwise TRUE

   ; check window ID
        If ( ws_ID ) {
      IfWinNotExist, ahk_id %ws_ID%
         Return FALSE
        } Else {
                ; set "last used window"
      WinWait, A, , 1
      If ( ErrorLevel )
         ; it timed out, so return an error
         Return FALSE
      ; retrieve window ID
      WinGet, ws_ID, ID
        }

   wID := f_GetOwnerOrSelf( ws_ID )
   WinHide, ahk_id %wID%
   WinSet, ExStyle, %flag%0x80, ahk_id %wID%
   WinShow, ahk_id %wID%
   Return TRUE
}

f_GetOwnerOrSelf( winID ) {
   ; class substitution [former f_SubstEvilClass()]
   ; winID must be passed to this function
   ; returns winID (either of owner, if any, or passed one) 

   ; find the owner of the window
   If Win_Get(winID, "O", owner)
      Return owner
   
   Return winID
}

Win_Get(Hwnd, pQ="", ByRef o1="", ByRef o2="", ByRef o3="", ByRef o4="", ByRef o5="", ByRef o6="", ByRef o7="", ByRef o8="", ByRef o9="") {
   /*
   (c) by majkinetor
   see: <http://code.google.com/p/mm-autohotkey/>
   Parameters:
                pQ                      - List of query parameters.
                o1 .. o9        - Reference to output variables. R,L,B & N query parameters can return multiple outputs.
   Query:
                C,I             - Class, pId.
                R,L,B,N - One of the window rectangles: R (window Rectangle), L (cLient rectangle screen coordinates), B (ver/hor Border), N (captioN rect).
                                          N returns the size of the caption regardless of the window style or theme. These coordinates include all title-bar elements except the window menu.
                                          The function returns x, y, w & h separated by space. 
                                          For all 4 query parameters you can additionaly specify x,y,w,h arguments in any order (except Border which can have only x(hor) and y(ver) arguments) to
                                          extract desired number into output variable.
                S,E             - Style, Extended style.
           P,A,O                - Parents handle, Ancestors handle, Owners handle.
                M                       - Module full path (owner exe), unlike WinGet,,ProcessName which returns only name without path.
                T                       - Title for a top level window or text for a child window.
                D                       - DC.
                #                       - Non-negative integer. If present must be first option in the query string. Function will return window information
                                          not for passed window but for its ancestor. 1 is imidiate parent, 2 is parent's parent etc... 0 represents root window.
   Returns:
                o1       - first output is returned as function result
   */ 
        c := SubStr(pQ, 1, 1)
        if c is integer 
        {
                if (c = 0)
                        Hwnd := DllCall("GetAncestor", "uint", Hwnd, "uint", 2, "UInt")
                else loop, %c%
                        Hwnd := DllCall("GetParent", "uint", Hwnd, "UInt")

                pQ := SubStr(pQ, 2)
        }
                
        if pQ contains R,B,L
                VarSetCapacity(WI, 60, 0), NumPut(60, WI),  DllCall("GetWindowInfo", "uint", Hwnd, "uint", &WI)
        
        oldDetect := A_DetectHiddenWindows
        DetectHiddenWindows, on
        
        k := i := 0
        loop
        {
                i++, k++
                if (_ := SubStr(pQ, k, 1)) = ""
                        break

                if !IsLabel("Win_Get_" _ )
                        return A_ThisFunc "> Invalid query parameter: " _
                Goto %A_ThisFunc%_%_%

                Win_Get_C:
                                WinGetClass, o%i%, ahk_id %hwnd%                
                continue

                Win_Get_I:
                                WinGet, o%i%, PID, ahk_id %hwnd%                
                continue

                Win_Get_N:
                                rect := "title"
                                VarSetCapacity(TBI, 44, 0), NumPut(44, TBI, 0), DllCall("GetTitleBarInfo", "uint", Hwnd, "str", TBI)
                                title_x := NumGet(TBI, 4, "Int"), title_y := NumGet(TBI, 8, "Int"), title_w := NumGet(TBI, 12) - title_x, title_h := NumGet(TBI, 16) - title_y 
                                WinGet, style, style, ahk_id %Hwnd%                             
                                title_h :=  style & 0xC00000 ? title_h : 0                        ; if no WS_CAPTION style, set 0 as win sets randoms otherwise...
                                goto Win_Get_Rect
                Win_Get_B:
                                rect := "border"
                                border_x := NumGet(WI, 48, "UInt"),  border_y := NumGet(WI, 52, "UInt") 
                                goto Win_Get_Rect
                Win_Get_R:
                                rect := "window"
                                window_x := NumGet(WI, 4,  "Int"),  window_y := NumGet(WI, 8,  "Int"),  window_w := NumGet(WI, 12, "Int") - window_x,  window_h := NumGet(WI, 16, "Int") - window_y
                                goto Win_Get_Rect
                Win_Get_L: 
                                client_x := NumGet(WI, 20, "Int"),  client_y := NumGet(WI, 24, "Int"),  client_w := NumGet(WI, 28, "Int") - client_x,  client_h := NumGet(WI, 32, "Int") - client_y
                                rect := "client"
                Win_Get_Rect:
                                k++, arg := SubStr(pQ, k, 1)
                                if arg in x,y,w,h
                                {
                                        o%i% := %rect%_%arg%, j := i++
                                        goto Win_Get_Rect
                                }
                                else if !j
                                                  o%i% := %rect%_x " " %rect%_y  (_ = "B" ? "" : " " %rect%_w " " %rect%_h)
                                
                rect := "", k--, i--, j := 0
                continue
                Win_Get_S:
                        WinGet, o%i%, Style, ahk_id %Hwnd%
                continue
                Win_Get_E: 
                        WinGet, o%i%, ExStyle, ahk_id %Hwnd%
                continue
                Win_Get_P: 
                        o%i% := DllCall("GetParent", "uint", Hwnd, "UInt")
                continue
                Win_Get_A: 
                        o%i% := DllCall("GetAncestor", "uint", Hwnd, "uint", 2, "UInt") ; GA_ROOT
                continue
                Win_Get_O: 
                        o%i% := DllCall("GetWindowLong", "uint", Hwnd, "int", -8, "UInt") ; GWL_HWNDPARENT
                continue
                Win_Get_T:
                        if DllCall("IsChild", "uint", Hwnd)
                                 WinGetText, o%i%, ahk_id %hwnd%
                        else WinGetTitle, o%i%, ahk_id %hwnd%
                continue
                Win_Get_M: 
                        WinGet, _, PID, ahk_id %hwnd%
                        hp := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", _ ) 
                        if (ErrorLevel or !hp) 
                                continue
                        VarSetCapacity(buf, 512, 0), DllCall( "psapi.dll\GetModuleFileNameEx" (A_IsUnicode ? "W" : "A"), "uint", hp, "uint", 0, "str", buf, "uint", 512),  DllCall( "CloseHandle", hp ) 
                        o%i% := buf 
                continue
                Win_Get_D:
                        o%i% := DllCall("GetDC", "uint", Hwnd, "UInt")
                continue
        }       
        DetectHiddenWindows, %oldDetect%
        return o1
}


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???
...
I mean The Sticky Notes on Windows 7 ... for accessing the program just type "sti" ( without quotes) in start menu search bar.

try this:
......


with a brief trying I couldn't get this to work....

let me explain my problem:

I wnted a script with this specifications & since I don't know anything about scripting. I couldn't do it on my own:

[*:3rb34fzg]Hide Sticky notes taskbar button. (not the whole sticky notes)
[*:3rb34fzg]Show an Icon with "add note" & "delete all notes" in menu items.
[*:3rb34fzg]If Sticky notes is not running, hide the tray Icon.

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

I wnted a script with this specifications & since I don't know anything about scripting. I couldn't do it on my own:

[*:1je4iql9]Hide Sticky notes taskbar button. (not the whole sticky notes)
[*:1je4iql9]Show an Icon with "add note" & "delete all notes" in menu items.
[*:1je4iql9]If Sticky notes is not running, hide the tray Icon.

well, this seems to be more complicated.
i don't have the time to help you here... so rather learn how to program AHK :D

Tweakyworld
  • Members
  • 7 posts
  • Last active: Sep 27 2015 12:14 PM
  • Joined: 04 Oct 2012
Hello and thank you very much for this great tool. I'm trying to set a window as permanently on-top (figured out it's possible after reading the quoted post - I could be wrong of course) but having some trouble since it kind of a "special" window which I'm unable to isolate and add to the StartupMinimize list. It's Yahoo Messenger's v11 pop-up smiley window. When the conversation window is set on top (Min2Tray works great), the smileys are hidden. A workaround is to set the smiley window on-top as well (again, Min2Tray delivers). The question is, can this be set permanently to avoid constantly setting it manually? (pic shows the desired, working state - when the chat window is set on-top, the smileys will become hidden and unusable)

Posted Image

can you make it remember window position, state (on top, minimized to tray, etc) and size and autoadjust them whenever a window is created?

this can be done already:
enable StartupMinimize (adjust interval as desired) and TriggerActions in the prefs of the main program.
now go to the prefs of the hidden window's tray icon:
- add the window to the StartupMinimize list.
- click on TriggerActions button and write to JTA the actions you would like to see executed, e.g. aot1:ON|pos1:20,20,600,500
just experiment with all those nice TriggerActions (TA1 - TA5 and JTA). they should be sufficient for your needs.
Junyx



techie108
  • Members
  • 250 posts
  • Last active: Jul 20 2019 03:19 AM
  • Joined: 05 Aug 2012

And another one!

my contribution to the ahk community:
Min2Tray (v1.7.9, 2011/10/11)

minimize a window to system tray area of taskbar as icon.
BossKey feature for minimizing several windows at once.
make window always-on-top and maximize window vertically
or horizontally. StartupMinimize can hide certain windows
upon start of Min2Tray or assign actions. and much, much more!
requires ms windows nt/2000/xp/vista/7 or newer - not tested under win 8, yet ;-)

partial changelog for Min2Tray v1.7.9:
+ new feature: use right mouse click on the close button of the window's titlebar to minimize it.
* replaced some functions by much faster routines from Forms Framework v0.8 by majkinetor. this speeded up systray icon creation and other things enormously!

please use it, test the new features extensively, give reply and suggest new features or implement them yourself :p

thx...
Junyx


hi Junyx,

this is a really good idea.

however i'm trying to implement this to serve my purpose, and i'm not sure how i could modify it -

when it turns the active window into tray icon, it makes the window inactive too. i need it to stay active at all times (the program is a black overlay, always on-top for adjusting brightness of my monitor). any idea how i can modify it to suit my needs?

thanks!

Junyx
  • Members
  • 124 posts
  • Last active: Nov 01 2015 06:37 PM
  • Joined: 11 Jul 2005
@techie108: [Min2Tray 1.7.9]

well, you could look into the sources at around line 177. there WinHide is called...

your problem /could/ also result from lines 210 to 217. try commenting them out.

did you already try "NoMinimize" option from preferences of minimized window?

@Tweakyworld:

i'm still investigating - so stand by!

Tweakyworld
  • Members
  • 7 posts
  • Last active: Sep 27 2015 12:14 PM
  • Joined: 04 Oct 2012

@Tweakyworld: i'm still investigating - so stand by!

...What can I say? Thanks a lot! :)

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

It's Yahoo Messenger's v11 pop-up smiley window. When the conversation window is set on top (Min2Tray works great), the smileys are hidden. A workaround is to set the smiley window on-top as well (again, Min2Tray delivers). The question is, can this be set permanently to avoid constantly setting it manually? (pic shows the desired, working state - when the chat window is set on-top, the smileys will become hidden and unusable)

took me some time to get it working - mainly because of setting up some yahoo accounts :shock:

the following code works for me and is only tested under WinXP/32bit, yahoo messenger v11.5.0.228.
it will make the IM input window always-on-top and optionally move the window to any desired position on screen.
if you don't want the later, comment out the "WinMove" line.

additionally it will make the smiley popup always-on-top. although this was not needed for me: smiley popups were always above the IM input window!

save the script as "y2f.ahk" and start it. then it will hang there waiting for yahoo messenger windows to appear... check intervall: 300ms.
;
; Yahoo2Front.ahk
;
; Make certain Yahoo Messenger windows always-on-top.
;
; created: 2012-10-16
; by: Junyx
; for: Tweakyworld
;

#NoEnv
#Persistent
#SingleInstance force
#UseHook
SetTitleMatchMode, 2

SetTimer, checkWindows, 300
return

checkWindows:
   ; IM input window
   uID := WinActive("ahk_class CTabbedIMHost", "IM Input Window")
   If (uID) {
      If (not chkWins%uID%) {
         chkWins%uID% := 1
         setWinAOT(uID)
         ; re-positon IM Input Window window (optional)
         WinMove, ahk_id %uID%, , 0, 0, 100, 400
      }
   }
   ; smiley popup
   uID := WinActive("SmileyTablePopup ahk_class #32770")
   If (uID) {
      If (not chkWins%uID%) {
         chkWins%uID% := 1
         setWinAOT(uID)
      }
   }
   return

setWinAOT(winID) {
   ; set LastFoundWindow
   IfWinNotExist, ahk_id %winID%
      Return
   WinSet, AlwaysOnTop, On
}
happy coding!
and don't forget to remove the messenger windows from Min2Tray before starting this script... you never know :wink:

Tweakyworld
  • Members
  • 7 posts
  • Last active: Sep 27 2015 12:14 PM
  • Joined: 04 Oct 2012
Thanks a lot Junyx! What I did was to add the code at the top of the Min2Tray.ahk code and it worked, hope that's ok. It doesn't make the IM input window always-on-top, but I didn't want that anyway. The smiley popup is always on-top and it will never hide the IM window now. (Win 7 x64) :)

Tweakyworld
  • Members
  • 7 posts
  • Last active: Sep 27 2015 12:14 PM
  • Joined: 04 Oct 2012
I guess I was wrong, it seems it doesn't work the way I did it. I'll install AHK and try again, although I'm a bit confused about whether everything should be in a single file/script or not (and AHK usage in general...)

update: maybe I've figured it out: Set min2tray.exe to auto-start as always (I use it for non-Yahoo purposes, too). Installed AHK and set y2f.ahk to autostart with Windows as well. Added #NoTrayIcon to the script to hide the green tray icon. Not sure if this is the way to do it - now everything seems perfectly ok.

alexball
  • Members
  • 8 posts
  • Last active: Nov 17 2012 09:57 AM
  • Joined: 04 Jun 2008
Anybody else tested this on Windows 8. The get windows for minimized starup does not work. Or I am too dump to use it. I gues I just open the minimize list and then select any other windows I want to include in the list. Min2Tray then gets the window data just like AU3_Spy rigth? This does not work for me Win 8 Pro.

Thanks for your suggestions.
Cheer
Alex

Tweakyworld
  • Members
  • 7 posts
  • Last active: Sep 27 2015 12:14 PM
  • Joined: 04 Oct 2012
I'm having trouble with the keyboard shortcuts on Windows 8, it seems it has taken over most WinKey shortcuts.

trante
  • Members
  • 11 posts
  • Last active: Jul 25 2013 06:10 AM
  • Joined: 15 May 2011
Thank you for great script.
I have such a problem, I need some of my executables be minimized when that programs are run.
Min2tray will listen for that executables, if min2tray finds myprogram.exe is open, it will be minimized automatically.
How can I do this?
Thank you