I have created a program that I want to show in the taskbar the whole time. It launches a few keyboard shortcuts when I press their buttons. The program works great, but the windows taskbar needs to be set to always on-top or programs will maximize over it too.
If I have both my programs and the windows taskbar set to be always on top, My program is on-top of the taskbar until I click anywhere in the taskbar, for example to activate another program.
My code is as follows:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Me.Bounds = Screen.PrimaryScreen.Bounds
Me.TopMost = True
'...
End Sub
I considered using a timer to activate my program once in a while, but the downside to that approach is, that if I am typing in another application and the focus is moved to my program, this is very annoying.
So my question is as follows: Is there a way I can interact with the taskbar so my program is always ontop of it, regardless of anything else, or is it possible to periodically restore the on-top status so my program becomes on-top of the taskbar again without the focus going to my program?
I prefer that my program is always ontop if the taskbar, and clicking the taskbar does not temporarily make my program invisible. For example, if I can set the z-order of my application to a higher level than the taskbar, that would be best. If otherwise I can somehow spawn my program as part of the taskbar, that would also work.
PS: I have enabled the search bar in the taskbar and my program is supposed to cover it entirely. I don't use the search bar and it gives me a dedicated space without worrying covering any open programs.
PS2: This is just for me, no need to worry about anyone who has different preferences. My goal is to optimize my workflow, so the least hastle I have daily, the better.
This is what it looks like when the app runs, but clicking the taskbar makes the window invisible.:
So... How can I make sure my program stays on-top of the taskbar, even if I click somewhere in the taskbar?
Apparently the solution was pretty simple.
I was afraid of side-effects, but the solution I applied works perfectly.
I added a timer, enabled it, and every tick it simply does:
me.Topmost = true
If I now click the taskbar, the program is obviously pushed to the back, but every 100ms when the timer ticks, the program is automatically put back on top without the app actually receiving focus.