Build a PowerShell systray tool with sub menus
https://www.systanddeploy.com/2019/09/buld-powershell-systray-tool-with-sub.html
In this post I will demonstrate how to build a tool that displays context menu and sub menus in the systray bar.
In a previous post I explained how to build a systray tool with PowerShell.
I have been asked how to do the same with sub menus in the context menu.
Now let's see how to proceed.
In the following example we will create a tool in the systray that will display the below context menus:
- Menu 1
- Menu2
- Restart the tool
- Exit
Both Menu 1 and Menu 1 will display two submenus.
The restart part will allow you to close the systray tool and open it again 10 seconds later (in case of bug).
The Exit button will allow you to close the systray tool
A simple click on the systray icon will display a basic WPF GUI
How it works ?
1 / Add parameter for the restart
2 / Load assemblies
3 / Prepare the basic GUI
4 / Associate a system icon for the systray tool
5 / Create the systray tool
6 / Create the menus
7 / Add context menus to the systray tool
8 / Create submenus
9 / Display the basic GUI after clicking on the systray tool
10 / Display some message box after clicking on sub menus
11 / Close the systray tool after clicking on Exit
12 / Restart the tool after clicking on Restart the tool
13 / Add some code to manage memory and
Full script
See below the full script
Enregistrer un commentaire