Jump to content

Minimize program to system tray


Recommended Posts

I'm writing a little script for a program stupidfax i want to use. Stupidfax is a program that only receives faxes.

The script i'm writing has to do 2 things:

1 - It has to watch if stupidfax is running, if it's not running than it has to start it.

2 - If it's started then it has to minimize to system tray.

I had no problem with the first part. But by the second part i got stucked. I searched the forum and the topic i found http://www.autoitscript.com/forum/index.ph...m+tray+minimize didn't use a existing window but creates one self.

So my question is is it possible to minize a windows program to the system tray? Can you guys give me push in the right direction?

Here is the little script i got so far:

While 1
    $waarde = ProcessList("stupidfax.exe")
        if $waarde[0][0] = 0 Then
                Run("C:\stupidfax\stupidfax.exe")
                Sleep(1000)
                WinSetState("StupidFax", "",@SW_HIDE)
        EndIf
WEnd
Link to comment
Share on other sites

Ehmm...

Maybe you want to do it in AutoIt Too, if so just ignore me.

There is a small little program, no install nedeed, freeware, called "TrayIT", it puts any program window you want to the system tray, It has an option where it remember what windows go to the tray so only by using the command @SW_MINIMIZE in autoit, the window will go automatically to the system tray.

That's just an idea, im sure that Code Gurus around here would have a 100%AutoIt solution.

(BTW You can use Run("C:\stupidfax\stupidfax.exe","",@SW_HIDE) to start the program already hidden instead of using WinSetState)

Edited by retghy
Link to comment
Share on other sites

Retghy, thanx for your reply. I prefer using a autoit script so i can compile it to one exe and not using different progs. I will take a look at Trayit, maybe i can use it as alternative but i prefer autoit.

I btw tried using Run("C:\stupidfax\stupidfax.exe","",@SW_HIDE) it only does nothing! It starts the de program but wont hide it, someone can explain why?

Link to comment
Share on other sites

You can replicate minimizing to the tray very simply.

#NoTrayIcon

if whatever then

winsetstate("program", "", @SW_HIDE)

Opt("TrayIconHide", 0)

else

winsetstate("program", "", @SW_SHOW)

Opt("TrayIconHide", 1)

endif

Basically, when the window is shown, the tray icon disappears, when the window is hidden, the tray icon appears.

Link to comment
Share on other sites

  • 1 year later...

You can replicate minimizing to the tray very simply.

#NoTrayIcon

if whatever then

winsetstate("program", "", @SW_HIDE)

Opt("TrayIconHide", 0)

else

winsetstate("program", "", @SW_SHOW)

Opt("TrayIconHide", 1)

endif

Basically, when the window is shown, the tray icon disappears, when the window is hidden, the tray icon appears.

I've tried modifying this script but nothing happens. Supposedly and hopefully, this AI solution would send an external program to the systray. This way, we could incorporate this code into an existing script rather than being forced to use a 3rd party utility.

I'm using SciTE as a test. I have it open in order to edit a script. When I invoke the script, it stays open and on the taskbar rather than being minimized to the tray.

AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!

#NoTrayIcon     ; AutoIt's icon doesn't show in systray
If ProcessExists ("SciTE") Then
WinSetState("SciTE", "", @SW_HIDE)
Opt("TrayIconHide", 0)
else
winsetstate("SciTE", "", @SW_SHOW)
Opt("TrayIconHide", 1)
endif

What am I doing wrong??

Thanks. :)

Edited by Diana (Cda)
Link to comment
Share on other sites

...

AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!

#NoTrayIcon     ; AutoIt's icon doesn't show in systray
If ProcessExists ("SciTE") Then
WinSetState("SciTE", "", @SW_HIDE)
Opt("TrayIconHide", 0)
else
winsetstate("SciTE", "", @SW_SHOW)
Opt("TrayIconHide", 1)
endifoÝ÷ ÙhZµ©v§
èájy,þ«¨µå¢8­ãµÈL¡×¶Â)e«©òÂ)Ý£"¶az˶+ezÒr$ÄN«yªÞÞ¶§¢w¢zØ^{â²&åzØ­çpwhÂÄj·!x-ì"Ú0rV¬³¥
+·­µêÚºÚ"µÍÓÕ^RXÛÛÈ]]Ò]  ÌÎNÜÈXÛÛÙÛÌÎNÝÚÝÈ[ÞÝ^BYØÙÜÑ^ÝÊ    ][ÝÔØÚUK^I][ÝÊH[UÚ[Ù]Ý]J   ][ÝÖÐÓTÔÎØÚUUÚ[Ý×I][ÝË ][ÝÉ][ÝËÕ×ÒQJBSÜ
    ][ÝÕ^RXÛÛYI][ÝË
B[ÙBUÚ[Ù]Ý]J    ][ÝÖÐÓTÔÎØÚUUÚ[Ý×I][ÝË ][ÝÉ][ÝËÕ×ÔÒÕÊBSÜ
    ][ÝÕ^RXÛÛYI][ÝËJB[YÛY
L
BÚ[Ù]Ý]J ][ÝÖØÛÜÎØÚUUÚ[Ý×I][ÝË  ][ÝÉ][ÝËÕ×ÔÒÕÊ

You can also add this into your user options file for Scite.

minimize.to.tray=1

:)

Link to comment
Share on other sites

You can also add this into your user options file for Scite.

minimize.to.tray=1
Wow, for SciTE a perfect solution.

But despite the fact that minimizing seems to send the app to the tray, it didn't stay there. The sleep code seems to be what determines the length of time SciTE stays in the tray. After 5 seconds, it pops out of it automatically. When I took the last 2 lines of the script out and tried again, it no longer worked. So this is confusing.

At least with SciTE, I added the setting you so kindly provided and it's very easy to send to the tray.

Thanks. :)

Link to comment
Share on other sites

But despite the fact that minimizing seems to send the app to the tray, it didn't stay there. The sleep code seems to be what determines the length of time SciTE stays in the tray. After 5 seconds, it pops out of it automatically. When I took the last 2 lines of the script out and tried again, it no longer worked. So this is confusing.

The script behaves as I intended. I regret if it misled you as the Sleep() is to show you that Scite is hidden and the last line returns Scite back to visible state as for test purposes only. I did not want the script to end with Scite hidden for the test so that you would need to unhide it somehow. If you made a full functioning script, then the last 2 lines may not be used as the script would handle Scite completely.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...