rbtray icon indicating copy to clipboard operation
rbtray copied to clipboard

Command-Line option: Start new program minimized

Open patricknelson opened this issue 6 years ago • 13 comments

NOTE: I've copied/modified this request from the Sourceforge feature request here: https://sourceforge.net/p/rbtray/feature-requests/11/


It would be nice, if one could also use RBTray to start a new program minimized.

For example:

"C:\RBTray.exe Notepad.exe"

Would start Notepad.exe minimized in the system tray. I would use this, to start some programs service-like but still accessible in the system tray.

patricknelson avatar Jan 17 '19 06:01 patricknelson

Hi @patricknelson,

I can see how this would be useful, but so far I haven't been able to think of a good way to implement it due to limitations in the APIs that Windows provides.

-Benbuck

benbuck avatar Jan 30 '19 09:01 benbuck

Hi @patricknelson,

I was just researching this a little, and found that there is at least one utility that can do it called Actual Window Minimizer (https://www.actualtools.com/windowminimizer/). So for sure it's possible, but seeing how they did it, the UI and settings required may be more than I care to add to RBTray, but I'll think about it.

Also, it looks like you may be able to cobble something together with AutoHotKey if you care to invest the time and effort: https://www.autohotkey.com/boards/viewtopic.php?t=4373.

-Benbuck

benbuck avatar Feb 04 '19 05:02 benbuck

Just want to say that I would appreciate this feature too

pstein avatar Sep 27 '20 06:09 pstein

This would be a great feature.

parkstraat9 avatar Feb 11 '21 12:02 parkstraat9

Just want to say that I would appreciate this feature too

tuaone avatar Jan 02 '22 13:01 tuaone

i think the reason it cannot be implemented easily is because you have to fake clicks which requires you to get the client screen size, then get the window size... and then calculate where the minimize button is mathematically, and then fake a right click event. ive done this and scheduled a task for when the executable is run, it will automatically run my script which does the calculation and fake mouse right click.

if anyone is interested in the script just let me know. im sure i could add a arg to be able to input the window to be systrayed. if anyone is interested let me know

james28909 avatar Feb 21 '22 17:02 james28909

i think the reason it cannot be implemented easily is because you have to fake clicks [...]

Programming APIs don't need to fake mouse clicks. You invoke a function exposed by a OS provided library which is responsible for GUI manipulation and whatnot.

garoto avatar Feb 21 '22 17:02 garoto

Programming APIs don't need to fake mouse clicks. You invoke a function exposed by a OS provided library which is responsible for GUI manipulation and whatnot.

what function is exposed when you right click the minimize button? is there an open source lib that already has this implemented that someone can study?

james28909 avatar Feb 21 '22 18:02 james28909

Plenty of open-source Windows programs offer the option of being started minimized in the systray. From the top of my head: ditto-cp, hexchat, AltSnap.

Either browse their code or ask the authors directly.

garoto avatar Feb 21 '22 20:02 garoto

ive acheived this task with AutoHotKey script Min2Tray which was released here on the autohotkey forums.

in order to add windows to the "StartUpMinimized" list, you have to minimize them to tray via min2tray script or compiled executable, then right click the minimized windows tray icon and go to "preferences" and select "Windows is on the StartUpMinimized list. i also selected "Minimize window immediately (skip the task bar)" as well. also, im on the latest win 11 and it seems to be functioning flawlessly for me. have enabled the option to minimize to tray when right clicking the close button too.

works very good for such an old piece of software

james28909 avatar Feb 21 '22 22:02 james28909

Why is it closed?

What do you mean? This issue is open.

Mansarde avatar Feb 09 '23 17:02 Mansarde

I see the confusion. Looks like #68 was closed, not this one 😄

patricknelson avatar Feb 09 '23 18:02 patricknelson

It seems min2tray that james28909 mention not work for me. I have done a simple script for this issue. However, I dont think this is a elegant implementation because you can see the program start minimize in taskbar and minimize to tray quickly. https://gist.github.com/JamesHoi/3d884caaeaa3626ae0ee3d8367c8ae75

By the way, I use SW_MINIMIZE for starting new program without display so the function in RestoreWindowFromTray should be changed to SW_SHOWNORMAL. I have also tried using the flag SW_HIDE, but somehow it cannot be restored window by rbtray. https://github.com/benbuck/rbtray/blob/2de7ba80967ab36039c6a95b46c0ca3a265d6d82/RBTray.cpp#L147

JamesHoi avatar Feb 15 '24 06:02 JamesHoi