vimage icon indicating copy to clipboard operation
vimage copied to clipboard

Suppress taskbar icon (silent mode)

Open Dragodraki opened this issue 3 years ago • 8 comments

Hi there,

wow, that's an amazing app - I'm as grateful as impressed especially speaking of the possibility to show animated GIFs with a transparent background and the fact it runs highdpiaware by default. Almost no software for windows is capable of doing these. :)

But there is one thing left I'd like you to ask for - I plan to use your software like a splash viewer. My image should be displayed but there shouldn't be any instance of vimage visible in the taskbar. With other words - the user shouldn't be able to interact with the program.

-> Please, can you add an parameter to make vimage runs without taskbar icon, e.g. like -silent or something like that?

Dragodraki avatar Aug 18 '22 18:08 Dragodraki

There's the -taskbarIcon command which you can use as a launch argument or custom action. If you make a custom action you can either bind it to a button or add it to the context menu.

Torrunt avatar Aug 19 '22 01:08 Torrunt

I'm afraid, this doesn't work for me.

"C:\Users\Drago\Downloads\vimage\vimage.exe" "C:\Users\Drago\Downloads\vimage\custom.gif" -taskbarIcon -toggleSync -clickThrough -alwaysOnTop grafik

As you can see, the taskbar icon isn't hidden. Did I something wrong with the paramaters? I also tried the -taskbarIcon command only and start with a fresh config.txt but here is the taskbar icon visible too.

Dragodraki avatar Aug 20 '22 11:08 Dragodraki

Those parameters are correct and should work. Does it work if you go to settings, create a custom action with that parameter then activate it with the context menu / binding?

What version of Windows are you using?

Torrunt avatar Aug 20 '22 11:08 Torrunt

Not key binding with the parameter doesn't work too. My computer is Windows 7 Pro x64 and I don't like to change.

But now I tested it in my Vmware Windows 10 - here it works... maybe you can adjust it for Windows 7 too, that would be very great.

Dragodraki avatar Aug 20 '22 16:08 Dragodraki

I don't have a machine with Windows 7 on it so I wouldn't be able to test it.

The project's open source so you could have a go if you wanted.

Here's how it currently works: https://github.com/Torrunt/vimage/blob/master/vimage/Source/Display/DWM.cs#L20-L36 Using user32.dll SetWindowLong function.

Torrunt avatar Aug 21 '22 04:08 Torrunt

Thanks you very much, but unfortunately I'm not much of a common-language programmer - I'm more active in scripting. So I wouldn't go so far as to say that I can do it better myself. I'll have a look at it by time, a try can't hurt...

Dragodraki avatar Aug 21 '22 19:08 Dragodraki

I fixed it

Line 20-36 have to be changed to:

        [DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        private const int SW_HIDE = 0x00;
        private const int SW_SHOW = 0x05;

        public static void TaskBarIconSetVisible(IntPtr hWnd, bool visible)
        {

            TaskbarIconVisible = visible;
            if (TaskbarIconVisible)
            {
                SetWindowLong(hWnd, GWL_EX_STYLE, (GetWindowLong(hWnd, GWL_EX_STYLE)) & ~WS_EX_TOOLWINDOW & ~WS_EX_APPWINDOW);
            }
            else
            {
                ShowWindow(hWnd, SW_HIDE);      // Makes hiding possible in Windows Vista/7
                SetWindowLong(hWnd, GWL_EX_STYLE, (GetWindowLong(hWnd, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW); // Hiding TaskBar-Icon
                ShowWindow(hWnd, SW_SHOW);      // Makes hiding possible in Windows Vista/7
            }
        }

It makes Windows Vista/7/8 can launch vimage.exe without TaskIcon with the parameter -taskbarIcon.

But this is about starting silent only. It don't fixes the bug that TASKBAR TOGGLE key binding isn't possible in the first place - neither on Windows 10 nor on Windows 7.

I'm satisfied so far, so for myself I don't need to toggle it.

Dragodraki avatar Aug 24 '22 13:08 Dragodraki

Nice!

Maybe when adding the fix there should be a OS check so it only does those extra commands if on Windows 7 or older. Something like this:

 bool isOlderThanWindows8 = Environment.OSVersion.Version < new Version(6, 2);

The TASKBAR TOGGLE key bind might be wrong in the "Custom Actions" tab. It should just be set to -taskbarIcon.

Torrunt avatar Aug 24 '22 16:08 Torrunt

I'm gonna close this issue now. I accidently already pushed the fix for it in d1696199503758738d71adb94ad73adc1f54985b. I added the isOlderThanWindows8 check and made it hide/show the window like we mentioned. The toggle button doesn't work still in Windows 7 but I don't think that will affect anyone. Pretty much no one uses Windows 7 anymore and I don't think anyone uses that toggle button anyway,

Torrunt avatar Nov 26 '22 08:11 Torrunt