Enhanced Tray
Posted: 06 Mar 2008, 15:24
I love programs sitting in the tray, therefore I was very pleased to find an entry in the configuration dialog of Salamander, which allows me to minimize it into the tray. And this can also be done by a keyboard shortcut (Shift+ESC). Perfectly, was my first thought. But after a while, it annoyed me a little bit, because I had to click the Icon to get Salamander back to my screen. But I don't want to use my mouse, I want a keyboard shortcut (I will open a feature request for that later).
But because this is not possible at the moment, I wrote a little Autohotkey Script:
I compiled the script to an executable (you have to save it in the same directory as the salamand.exe) and attached it to this post.
Usage:
Start the salamand_tray.exe instead of the salamand.exe. It will start Salamander and hide it. To bring Salamander to the front, simply click the tray icon or press the keyboard shortcut CTRL+ALT+S. Press again to hide it.
Attention: You have to disable the option "minimize to tray" in the salamander configuration !
Hope you have fun with this.
If you want...
... an other keyboard shortcut
... or an other icon
... or that the window is shown after startup
feel free to change the script and recompile it for yourself.
But because this is not possible at the moment, I wrote a little Autohotkey Script:
Code: Select all
#SingleInstance off
; Run programm and save PID
Run salamand.exe, , , NewPID
; set icon for script
menu, tray, Icon , salamand.exe, 4, 1
; No tray items
menu, tray, NoStandard
; add show item
menu, tray, add, Show
; add hide item
menu, tray, add, Hide
; add seperator
menu, tray, add
; add exit item
menu, tray, add, Exit
; set it default
menu, tray, default, Show
; show it with one single click
menu, tray, Click, 1
WinWait, ahk_pid %NewPID%
{
; get window title for tray tool tip
WinGetTitle, TheWinTitle, ahk_pid %NewPID%
; hide window
WinHide, ahk_pid %NewPID%
}
; set tooltip for icon
menu, tray, Tip, %TheWinTitle%
; close this app when the process is gone
Process, WaitClose, %NewPID%
ExitApp
^!S::
{
showhideWin(NewPID)
}
Return
; function that show and hides the window
showhideWin(NewPID)
{
; Hide window if active
IfWinActive, ahk_pid %NewPID%
{
; get window title for tray tool tip
WinGetTitle, TheWinTitle, ahk_pid %NewPID%
; set tooltip for icon
menu, tray, Tip, %TheWinTitle%
; hide window
WinHide, ahk_pid %NewPID%
}
else
{
; show Window
WinGet, WinStat, MinMax, ahk_pid %NewPID%
IfEqual, WinStat, -1
{
WinRestore, ahk_pid %NewPID%
}
else
{
; show window
WinShow, ahk_pid %NewPID%
}
; and set active
WinActivate, ahk_pid %NewPID%
; get window title for tray tool tip
WinGetTitle, TheWinTitle, ahk_pid %NewPID%
; set tooltip for icon
menu, tray, Tip, %TheWinTitle%
}
return
}
Hide:
{
; get window title for tray tool tip
WinGetTitle, TheWinTitle, ahk_pid %NewPID%
; set tooltip for icon
menu, tray, Tip, %TheWinTitle%
; hide window
WinHide, ahk_pid %NewPID%
}
return
Exit:
{
; show window (because it is possible, that it asks s.th.)
WinShow, ahk_pid %NewPID%
; Close app
WinClose, ahk_pid %NewPID%
}
return
Show:
{
; here we can call showhide, because the window will never hide, because
; it does not have the focus in the moment we click the icon or the menu entry
showhideWin(NewPID)
}
return
Usage:
Start the salamand_tray.exe instead of the salamand.exe. It will start Salamander and hide it. To bring Salamander to the front, simply click the tray icon or press the keyboard shortcut CTRL+ALT+S. Press again to hide it.
Attention: You have to disable the option "minimize to tray" in the salamander configuration !
Hope you have fun with this.
If you want...
... an other keyboard shortcut
... or an other icon
... or that the window is shown after startup
feel free to change the script and recompile it for yourself.