sandboxie-plus / Sandboxie

Sandboxie Plus & Classic
https://Sandboxie-Plus.com
GNU General Public License v3.0
13.49k stars 1.5k forks source link

Hide Tray Icon #4075

Open JordaneParis opened 2 months ago

JordaneParis commented 2 months ago

Is your feature request related to a problem or use case?

My demand is not realy related to an issue, it's more a GUI confort use case.

Since I use sandboxie classique to execute always the same program with a shordcute on my desktop. After getting ready with my setup, I would like to be able to hide the tray icon.

Describe the solution you'd like

Is it possible to work this way to give me the possibility to do it in the sandboxie.ini or anything else ?

It would be awesome to add the line in sandboxie.ini so if I want the tray icon back I can remove the line from the .ini.

Or something like that.

Describe alternatives you've considered

I tried the way to do it manually. But I cannot remove it from active icons with windows settings. And particulary if I want to automate it with a script. It' a pain to edit binary data from tray menu in windows and can corrupt my whole system.

offhub commented 2 months ago

This setting is available in the Plus UI.

bastik-1001 commented 2 months ago

The old user interface is no longer being worked on. David, the developer, said that it is not supposed to get new features or options to enable features. (Otherwise, there is no objection against this feature request.)

Like offhub said, with SandMan, the new UI of Sandboxie-Plus you have the option to display classic icons, the plus icons or no icons in the tray.

Options > Global Settings > Shell Integration > [System Tray] > "Show Icon in Systray" there is a drop-down menu.

JordaneParis commented 2 months ago

I'm not sure where to follow the developers' discussions. Nevertheless, I don't quite understand if the feature request will be approved or not. I would love to get that improvement even without a GUI modification. Sandboxie.ini is enough to me.

e-t-l commented 1 month ago

I would love to get that improvement even without a GUI modification. Sandboxie.ini is enough to me.

@JordaneParis the sandboxie.ini file only sets parameters for the sandboxes and the programs that run inside them. The tray icon is a hard-coded part of the interface for the sandboxie program executable itself. So your feature request is, by definition, a "GUI modification" that would require updating the entire sandboxie classic program. Devs have already decided this will not happen (although I don't blame you for not knowing that ahead of time).

We highly recommend you switch to Sandboxie Plus, which gives you the option to hide the tray icon along with lots of others. There are no benefits to sticking with Classic, and it's not hard to switch. All your same sandboxes and ini files will work exactly the same in Plus as they did in Classic.

Syrinx2024 commented 1 month ago

I would like this request but for the SBIE+ UI. Currently if the UI (SandMan.exe) is set to: Global Settings > Shell Integration > System Tray > Show Icon in SysTray: Don't show any icon along with: Global Settings > Shell Integration > System Tray > On main window close: Close to Tray (with Minimize to tray checked [aka enabled]) the UI will 'Exit itself', not simply use no Tray Icon...meaning Auto-Delete or anything else handled strictly by the UI won't work afterward.

As a workaround I've tried to leave 'Show Plus icon' on and use a script I already have running (See *! below for more info) to delete\remove the SandMan tray entry via shell32.dll\Shell_NotifyIcon but that then causes the Auto-Delete phase to pop-up a window that normally isn't shown when the notification icon actually exists...it's short lived and small in size but still slightly annoying and makes the experience a bit 'uglier' than I had hoped. Example of how to remove it written using a modified version of an existing AHK Script (updated for AHK V2 and this specific case, I'm not a Dev!): Just the functions...you still need to call RemoveSandManTray()

RemoveSandManTray()
{
    If FileExist(A_ProgramFiles "\Sandboxie-Plus\SandMan.exe") ;If file does not exist it isn't even installed, so nevermind!
    {
        wasRemoved := 0
        Loop 8
        {
            If (wasRemoved = 0)
            {
                Try
                {
                    taskBarIndex := TrayIcon_GetTrayBar() ;https://www.autohotkey.com/boards/viewtopic.php?t=1229, TrayIcon library
                    pidTaskbar := WinGetPID("ahk_class Shell_TrayWnd")
                    hProc := DllCall("kernel32.dll\OpenProcess", "UInt", 0x38, "Int", 0, "UInt", pidTaskbar)
                    prB := DllCall("kernel32.dll\VirtualAllocEx", "Ptr", hProc, "Ptr", 0, "UPtr", 20, "UInt", 0x1000, "UInt", 0x04)
                    bTn := Buffer(A_Is64bitOS ? 32 : 20, 0)
                    nFo := Buffer(A_Is64bitOS ? 32 : 24, 0)
                    trayEntries := SendMessage(TB_BUTTONCOUNT := 0x0418, 0, 0, "ToolbarWindow32" taskBarIndex, "ahk_class Shell_TrayWnd")
                    Loop trayEntries
                    {
                        Try
                        {
                            SendMessage(TB_GETBUTTON := 0x0417, A_Index - 1, prB, "ToolbarWindow32" taskBarIndex, "ahk_class Shell_TrayWnd")
                            DllCall("kernel32.dll\ReadProcessMemory", "Ptr", hProc, "Ptr", prB, "Ptr", bTn.Ptr, "UPtr", bTn.Size, "UPtr", 0)
                            dwData := NumGet(bTn, A_Is64bitOS ? 16 : 12, "UPtr")
                            DllCall("kernel32.dll\ReadProcessMemory", "Ptr", hProc, "Ptr", dwData, "Ptr", nFo.Ptr, "UPtr", nFo.Size, "UPtr", 0)
                            currentHwnd := NumGet(nFo, 0, "Ptr")
                            uId := NumGet(nFo, A_Is64bitOS ? 8 : 4, "UInt")
                            currentExe := TryWinGetProcessName(currentHwnd)
                            If (currentExe = "SandMan.exe")
                            {
                                If (TrayIcon_Remove(currentHwnd, uID))
                                {
                                    wasRemoved := 1
                                }
                            }
                        }
                    }
                    DllCall("kernel32.dll\VirtualFreeEx", "Ptr", hProc, "Ptr", prB, "UPtr", 0, "UInt", 0x8000)
                    DllCall("kernel32.dll\CloseHandle", "Ptr", hProc)
                }
                DllCall("kernel32.dll\Sleep", "UInt", 250)
            }
        }
    }
    Return
}

TrayIcon_Remove(hWnd, uId) ;Remove a Tray icon, Parameters ...: hWnd - Window handle., uId - Application defined identifier for the icon. Part of TrayIcon library
{
    notifyIconData := Buffer(2 * 384 + A_PtrSize * 5 + 40, 0)
    NumPut("UPtr", notifyIconData.Size, notifyIconData, 0)
    NumPut("UPtr", hWnd, notifyIconData, A_PtrSize)
    NumPut("UPtr", uId, notifyIconData, A_PtrSize * 2)
    Return DllCall("shell32.dll\Shell_NotifyIcon", "UInt", 0x2, "UInt", notifyIconData.Ptr)
}

TrayIcon_GetTrayBar() ;Part of TrayIcon library
{
    taskBarIndex := ""
    toolBars := ""
    For classArray In WinGetControls("ahk_class Shell_TrayWnd")
    {
        If (RegExMatch(classArray, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)", &toolBars))
        {
            Loop toolBars[]
            {
                Try
                {
                    hWnd := ControlGetHwnd("ToolbarWindow32" A_Index, "ahk_class Shell_TrayWnd")
                    hParent := DllCall("user32.dll\GetParent", "Ptr", hWnd)
                    windowClass := WinGetClass("ahk_id " hParent)
                    If (windowClass == "SysPager") ;Removed ' or windowClass == "NotifyIconOverflowWindow"'
                    {
                        taskBarIndex := A_Index
                    }
                }
            }
        }
    }
    Return taskBarIndex
}

Re-Launching the UI (SandMan.exe) still opens the window for the existing copy 'actually running' in the background (Thankfully!) when I need it to check or change settings.

*! Which controls more than just my sandboxes and has its own Tray Icon already reacting to things happening. They actually exist more as AppContainers I'm 'now' launching directly into Sandboxie....from before I started trying to re-append Sandboxie back into my setup (I abandoned it after Sophos did) and I don't want to undo all that unless and until I'm sure I will keep using it for years to come... =(