Windows System Tray App Engine

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
robritenour
Posts: 3
Last visit: Mon Nov 28, 2022 4:56 am

Windows System Tray App Engine

Post by robritenour »

In PS Studio the Windows System Tray App Engine is provided and a initial icon is hard coded as part of the Build process. In the blog posts for this engine there is mention of object #SapienHost as part of the engine, and the additional menu items can be added easily. What I cannot see how to do is change the application icon in the system tray programmatically. That part of the included engine is hidden from us. I've tried using $SapienHost.Icon, no luck. I realize it as simple the below example, but we need to know the variable name Sapien used in the engine.

$Main_Tool_Icon = New-Object System.Windows.Forms.NotifyIcon
$Main_Tool_Icon.Text = "MySystemTrayApp"
$Main_Tool_Icon.Icon = $icon

Is this doable or do I need to forgo this engine and code it all myself?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Windows System Tray App Engine

Post by jvierra »

Have you tried to change the icon in the "Build" settings?
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: Windows System Tray App Engine

Post by Alexander Riedel »

I am assuming he means changing dynamically to indicate status.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
robritenour
Posts: 3
Last visit: Mon Nov 28, 2022 4:56 am

Re: Windows System Tray App Engine

Post by robritenour »

Correct, the desire it to change dynamically/programmatically to indicate status. Setting the icon in the Build properties is hard coding a particular icon, which is great when it launches.
This topic is 3 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked