Powershell GUI toolbar

Go The Power

Senior Administrator, Windows Update Expert, Contributor
Staff member
Joined
Mar 5, 2012
Posts
6,291
Location
Adelaide, South Australia
Hi guys,

I have created Little toolbar inside Powershell to use at work, I have worked out how to make the Toolbar stay on top of all other windows. But I was wondering if it was possible to make this toolbar "Dock" to the top of screen.

Ideally what I would like is my toolbar is to be sitting at the top of the screen and other windows re-size around it. Is there a way to make it so windows automatically arrange around it? that way if a window is maximized it will fit between my toolbar at the top and the start menu at the bottom?

I have done alot of looking on google but haven't had much luck. The closest thing I have been able to find it this, but is for C:
C# does Shell, Part 3 - CodeProject

thank you
 
Ideally what I would like is my toolbar is to be sitting at the top of the screen and other windows re-size around it.

First part is easy, set the startup position, and get the screen width divided by 2, and subtract the width of the toolbar divided by 2 to center it, Y will be 0 obviously.

As for making other windows resize around it, you'll have to P/Invoke MoveWindow() (Documentation). There are no native .NET stuff provided within the BCL that allow you to interact with other process' in this way. Why bother though if you have it configured so that this toolbar always stays on top of all other windows?

The other thing you'd need is to P/Invoke the EnumWindows() function to get a handle to each top level Window: Documentation

If you want this to be an immovable toolbar, you'll have to override a few things to prevent the user from dragging the form around.
 
Last edited:
Thanks for the reply. I will have a look at this when I get to work

I currently have it ontop of all windows, but if I open up a program that is maximized it cuts of all the top of the window that is maximized. Then to have to close the window you have to move the tool bar to click on close

thanks again
 
Thanks for the reply. I will have a look at this when I get to work

I currently have it ontop of all windows, but if I open up a program that is maximized it cuts of all the top of the window that is maximized. Then to have to close the window you have to move the tool bar to click on close

thanks again

Then unless you have a timer that utilizes the methods I've explained above, you'd probably have to provide a low level hook which would complicate things by a large amount.
 
Thanks for the reply. I will have a look at this when I get to work

I currently have it ontop of all windows, but if I open up a program that is maximized it cuts of all the top of the window that is maximized. Then to have to close the window you have to move the tool bar to click on close

thanks again

Could you not shorten your toolbar to leave a little gap on the right hand side for the minimize/maximise/close buttons?
 
Thanks for the reply. I will have a look at this when I get to work

I currently have it ontop of all windows, but if I open up a program that is maximized it cuts of all the top of the window that is maximized. Then to have to close the window you have to move the tool bar to click on close

thanks again

Could you not shorten your toolbar to leave a little gap on the right hand side for the minimize/maximise/close buttons?

That would be an easier way of doing it. I use the toolbar for remote connections to users machine, if when a command is run to open MSTSC for example, might be easier if i can tell powershell to open the MSTSC session on the Secondary Monitor.
 
I would take on niemiro's suggestion and expand the toolbar to as wide as you need it depending on what exists on that toolbar. The math behind determining the width shouldn't be difficult..
 
How are you doing on this? Is this issue all sorted? I probably won't help with the low level hook because it would require similar concepts of a malicious intent, but if you have further questions you know where to ask them :).
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top