Sign in to follow this  
Followers 0
MrChris

Trying to make a firefox.exe hider/shower

8 posts in this topic

I am trying to make a little tray icon that will allow me to hide/show firefox.exe but it does not seem to be working really and am not sure what I may be missing. Bottom line is if I hit the Hide option in the tray it does not make the Firefox windows invisiable yet the title of my Firefox does contain the word "firefox"

#Include <Constants.au3>
#NoTrayIcon

Global $FirefoxPath

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.
Opt("WinTitleMatchMode", 4)

$OpenFirefox = TrayCreateItem("Open Firefox")
$CloseFirefox = TrayCreateItem("Close Firefox")
TrayCreateItem("")
$HideFirefox = TrayCreateItem("Hide Firefox")
$ShowFireFox = TrayCreateItem("Show Firefox")
TrayCreateItem("")
$About = TrayCreateItem("About")
TrayCreateItem("")
$Exit = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = 0
            ContinueLoop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = $About
            Msgbox(64,"About","Firefox Tray Menu")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = $Exit
            ExitLoop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = $HideFirefox
            ;WinActivate("Firefox", "")
            WinSetState("Firefox", "", @SW_HIDE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = $ShowFirefox
            ;WinActivate("Firefox", "")
            WinSetState("Firefox", "", @SW_SHOW)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = $CloseFirefox
            RunWait("TASKKILL /IM FIREFOX.EXE")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case $msg = $OpenFirefox
            Run(@ScriptDir & "\PortableFirefox.exe")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    EndSelect
WEnd

Exit

Share this post


Link to post
Share on other sites



Since you are using WinTitleMatchMode 4, then try using the classname instead. You may find the the title Firefox... is being used also by an invisible window.

:P

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Opt("WinTitleMatchMode", 4)

If you change the above to 2 then it works.

Nice wee script btw :P

Edit: Also, if you want to have the Firefox icon in the task bar instead of the AutoIT one then add this line before the TraySetState() line -

TraySetIcon ("C:\Program Files\Mozilla Firefox\firefox.exe") ; Or whatever the location of your Firefox install

Edited by Alan Robertson

Share this post


Link to post
Share on other sites

Well the prupose of this little trayicon is. I use PortableFirefox but one small problem I have is that since I have a crap load of extenstions installed Firefox often takes FOREVER to Open up. So I was thinking of just making a little systray app that when run @ windows startup will Launch PortableFirefox Hidden and I can just click the option to Show Firefox.

Now that the GUI is kinda working the only left over problem I have is.

Since PortableFirefox is just a launcher for firefox.exe how can I launch portablefirefox.exe and have the firefox.exe window still be hidden?

Make sense?

Regards,

MrChris

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This works for me. I don't have portable firefox, so I can't test with that. But with regular, it does what it should. You'll have to change the $FirefoxPath and possibly the "classname=MozillaUIWindowClass" if portable uses a different classname.

#Include <Constants.au3>

Opt("TrayMenuMode",1)
Opt("WinTitleMatchMode", 4)

$FirefoxPath = "C:\Program Files\Mozilla Firefox\firefox.exe"

Run($FirefoxPath, "", @SW_HIDE)

$OpenFirefox = TrayCreateItem("Open Firefox")
$CloseFirefox = TrayCreateItem("Close Firefox")
TrayCreateItem("")
$HideFirefox = TrayCreateItem("Hide Firefox")
$ShowFireFox = TrayCreateItem("Show Firefox")
TrayCreateItem("")
$About = TrayCreateItem("About")
TrayCreateItem("")
$Exit = TrayCreateItem("Exit")

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = $About
            Msgbox(64,"About","Firefox Tray Menu")
        Case $msg = $Exit
            ExitLoop
        Case $msg = $HideFirefox
            WinSetState("classname=MozillaUIWindowClass", "", @SW_HIDE)
        Case $msg = $ShowFirefox
            WinSetState("classname=MozillaUIWindowClass", "", @SW_SHOW)
        Case $msg = $CloseFirefox
            RunWait("TASKKILL /IM FIREFOX.EXE", "", @SW_HIDE)
        Case $msg = $OpenFirefox
            Run($FirefoxPath)
    EndSelect
WEnd

Exit
Edited by xcal

Share this post


Link to post
Share on other sites

Thanks for the reply,

Yes If I do not use PortableFirefox it works just fine. But since portableFirefox.exe calls firefox.exe Im not sure how I can run("portablefirefox.exe") and still have it hide firefox.exe.

MrChris

Share this post


Link to post
Share on other sites

After the 'run' you could try...

WinWait("classname=MozillaUIWindowClass")

WinSetState("classname=MozillaUIWindowClass", "", @SW_HIDE)

But you'll see it flicker on screen before hiding.

Share this post


Link to post
Share on other sites

Thanks for the reply but thats what I tried with no luck.

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