Place an application's icon into system tray - c#

I'm making a desktop mascot with unity, and I do not want to see the icon appearing on the task bar, I want the icon in the system tray. Is there a way to do this?
PS: This is NOT a windows form (it's a game), so I believe Form.ShowInTaskbar will not work.

I've never programmed in Unity, but I'm assuming you are working in a Windows window. If you make the top level window for the application not appear in the main area of the Taskbar, make the window a "Tool Window" (by setting the WS_EX_TOOLWINDOW extended style on the window), then the window/app will not show up on the taskbar.
I'll leave it to someone how knows enough Unity to tell you how to set that style. Here's a reference to start with (on the Windows side, not the Unity side): Managing Taskbar Buttons

Related

MFC app - Class library WPF window icon does not show up in taskbar

I have an MFC window-based app. I added a C# class library that provides a second window for login to the app. This second window is meant to show before the main MFC window and once the user successfully logs in, it will go away and the main window will launch. The problem I am having is that when the login window is showing there is no taskbar icon for it. This did work correctly when the login window was an MFC dialog.
To make debugging this window easier I made a small MFC test app from which I can launch the login window with a button click. (the main program is cumbersome to test with). I added a C# class library to it just as it is in the main program. When I launch the app the main MFC dialog app shows up and the app's icon appears on the taskbar. When I click the button to launch the WPF window, it appears but there is no icon in the taskbar. This window does not show on the taskbar as a second window of the app as I would expect.
I am having a really hard time with google finding relevant info.
I have tried specifying an icon for the window vs. not specifying one.
I have tried adding ShowInTaskbar="True" to the window.
I have tried changing WindowStyle
I have tried playing with TaskbarItemInfo.
I tried following New taskbar icon when opening a window in WPF, but I don't really understand it well enough to say that it will fix my issue since I do not get my window showing up at all and if I did I would be fine with it being stacked.
I am not sure where else to go with this. Please let me know if there is anything unclear.

Cycle through open windows in C# using ALT+TAB/ESC and have the current window in focus and forced to be maximized (if already minimized to taskbar)?

I am writing a small application to automatically rotate through open windows on Windows 7/8.1/10 PC's. I have written the majority of the code and it is working well except I cannot figure out or find out what key presses to use to cycle through open applications.
I have tried SendKeys.Send("%{Tab 2}"); but this seems to only actually press the TAB button once as it keeps switching between the same two windows (even though more are open).
I have tried SendKeys.Send("%+{Esc}"); but this doesn't maximize windows that are minimized to the taskbar. It will effectively cycle through each open windows and bring them into focus (as evident by watching the white semi-transparent overlay on the taskbar item) but it won't show them on screen - I'm assuming because they started minimized. Only the maximized ones will show on screen when it's their turn.
Can anyone please assist? I'm sure it's a simple fix of maximizing the window it cycles to but I'm unsure how to implement this.
I haven't included the code of the entire application as I don't think it is relevant. If you do require it please let me know and I will add it.
Many thanks.

systemTray-only application always has an open window

I'm developing C# a WPF application where all windows are hidden/closed by default. I have a system tray Icon (System.Windows.Forms.NotifyIcon) with a context menu to show/hide the windows. All windows have ShowInTaskbar="False".
The problem is that the startup windows is still visible when I press alt+tab.
If I close the form that has the NotifyIcon my application stops, which I don't want.
I'm looking for a way to hide the windows completely without closing my application.
Any help?
Thanks
Make sure you have BOTH ShowInTaskbar="False" and Visibility="Hidden" set in the XAML and WPF should do this automatically.
The cause is likely you have window state set to minimized instead of visibility set to hidden.

Change Minimize Animation

I have an application that minimizes to the system tray. That all works well, the problem is that when minimized the animation goes towards the left side of the screen.
Is there a way to change it so the animation goes towards the tray?
No. This animation is handled by Windows, and since you are invoking the Minimize routine on the window, Windows will automatically animate the window into the location where the window's button is on the taskbar. If you're looking for a "quick solution", there isn't one.
The most you could do is change the window's behavior so that when it's minimized, it actually closes instead. This would prevent the fly-down animation into the taskbar, and Windows would perform the window close animation instead, which may look more consistent with your application design. A lot of other tray icon programs handle it this way.
If you really want to change the window's animation, you will need to override any Windows window management features with your own, that way when the window is "minimized" (or closed), you can animate your window to appear to move into the notification area on the right.

Creating Your own taskbar

Am making my own taskbar that will appear on top of other windows. how do I make it push other windows down such that when maximised they don't overlap my taskbar
See this question. In short, don't use Window.Topmost, as this will put your window above all other windows, which is just rude! Instead, set the "Owner" property of the other windows to be the window that you appear on top.

Categories

Resources