Jump to content

Trying to make a firefox.exe hider/shower


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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

Link to comment
Share on other sites

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
Link to comment
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

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...