Sign in to follow this  
Followers 0
Keene Coder

Minimizing Windows To SysTray (clock area)

18 posts in this topic

How do I minimize a window to the system tray (area by clock)?

I want to have an AutoIt script sit in the system tray & when a hotkey or menu item is pressed it will minimize the currently active window to the system tray. Is this possible in AutoIt?

Regards

Brian Keene


[FONT=Arial][SIZE=1][COLOR=yellow][B]When my kids were young this encounter really happened:Dad says: "Quit it kids! Your driving me CRAZY!Kid1 says: "Wheres crazy?"Kid2 says: "Can I go to crazy with you?"

Share this post


Link to post
Share on other sites



u could try to make it just hide, and set a show command on clicking the trayicon


*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...

Share this post


Link to post
Share on other sites

True, but I'm hoping to be able to put multiple windows into the SysTray. So this wouldn't work. Also, I would like to have an icon in the SysTray for the program/window, not just for my script.

Good suggestion though.

Regards

Brian Keene


[FONT=Arial][SIZE=1][COLOR=yellow][B]When my kids were young this encounter really happened:Dad says: "Quit it kids! Your driving me CRAZY!Kid1 says: "Wheres crazy?"Kid2 says: "Can I go to crazy with you?"

Share this post


Link to post
Share on other sites

So has the outlook for this functionality improved yet?

I know that someone has worked on functionality to remove/restore icons from/to the system tray, so is it likely that it could be slightly further extended perhaps to minimise multiple non-AutoIt windows to the tray?

Obviously the biggest problem with this is that if the script quits without 'restoring' the windows then the windows remain hidden, but that shouldn't be a fatal problem.

Share this post


Link to post
Share on other sites

You need the latest BETA to minimize to tray.


FootbaG

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Oh! I didn't realise that it was already doable with AutoIt's native functions. :)

Could you please post some code demonstrating how to minimise a Notepad window to the tray? (Edit: because there are no obvious functions in the help file index that suggest the behaviour.)

Edited by LxP

Share this post


Link to post
Share on other sites

Thanks for the responses guys, but these aren't quite what I'm after (a method to minimise a non-AutoIt window to the tray).

WinSetState("Notepad window title", "", @SW_MINIMIZE)

only minimises Notepad to the taskbar, while this thread demonstrates how to minimise an AutoIt-built GUI to the tray (which is quite handy anyway, JoeCool!).

Any other ideas?

Share this post


Link to post
Share on other sites

You can't minimize a notepad window to the tray, it doesn't have an icon...

But I think for windows like NAV you just close the window and it minimizes.


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

You can't minimize a notepad window to the tray, it doesn't have an icon...

In theory it would be possible for AutoIt (and any other program) to minimise any window it likes to a system tray icon if it follows these steps:
  • Note the icon used by the window.
  • Hide the window.
  • Create a new icon in the tray with the icon noted before.
  • Set the icon so that a left-click shows the window and destroys the icon.
  • Optionally attach a right-click menu of Restore, Maximise and Close to the icon.
Many programs (including PowerPro and The Wonderful Icon) adopt this approach to give the user the possibility of minimising any window they like to the tray.

As stated somewhere above, an AutoIt script could do this for one window at a time because it can only manipulate one tray icon (its own).

Share this post


Link to post
Share on other sites

I thought you meant without external forces. You can't minimize your notepad window to the tray manually can you?


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

I use PowerPro with the right muse button click on the minimize button.

Just an idea (probably lame) how it can be done with autoit: create one host script, that will be do main work and simple tray based script, that will accept params from commandline. When you do something (right mouse click, hotkey etc) in the main script for minimize for example active window, main script take window handle, file name and start instance of second script with this parameters. When second script run, it's hide window and create systray element with icon from file name, given in commandline.

Not tried at all, but I guess this can work.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I thought you meant without external forces. You can't minimize your notepad window to the tray manually can you?

<{POST_SNAPBACK}>

No; there's no standard Windows-certified way of doing this.

Programs that implement this functionality for themselves simply hide their window and set their tray icon to show the window again, while programs that operate on 'foreign' windows do so in the fashion that I described above.

Edited by LxP

Share this post


Link to post
Share on other sites

Not tried at all, but I guess this can work.

That's a very interesting idea, Lazycat. It would work but the downside of it is that for each tray-minimised program, another AutoIt process would be required. On my system a one-line script consisting of a MsgBox() takes up 4½MB of memory.

This will definitely suit my purposes until a single-process solution arises though. Thanks again!

Share this post


Link to post
Share on other sites

It would work but the downside of it is that for each tray-minimised program, another AutoIt process would be required. On my system a one-line script consisting of a MsgBox() takes up 4½MB of memory.

<{POST_SNAPBACK}>

Yes, you right, this is really downside that each minimized window should have own process... But from other side, biggest part of this size - shared libraries, so each identical additional process should take only about 160 kb - autoit stub size.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Why can't you just have one script, one icon, one instance of AutoIt that controls all windows? Why can't they all minimize to the same AutoIt tray icon.

Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Doable but not as intuitive an approach. For instance, if you see Firefox and Cygwin icons in your tray then you pretty much know that Firefox and Cygwin are in memory.

Edit: this would be an interesting idea for the Scripts and Scraps forum nonetheless, and most likely a useful utility for quite a few people! Someone should program it! :)

Edited by LxP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0