Systray Application

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 2 years and 9 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
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Systray Application

Post by stevens »

Hi,

I'm trying to make a systray application and found this topic: viewtopic.php?t=13935

So I tested some basic stuff but not getting really where I wanted = 1 icon (now there are 2(?) which opens a form in which I load a gridview with local software installed.
On that gridview there will be actions on one or multiple items in that gridview (f.e. uninstall item 1, 3, 5 of that list).

Please advise.
J.
Demo-IconNotify.Package.ps1
systray testing
(97.5 KiB) Downloaded 217 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Systray Application

Post by jvierra »

The PS1 file is mopstly useless in answering your question. Please either post teh PSF or the project if it is a project. You have to ZIP the proect to upload it.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Systray Application

Post by stevens »

Sorry, thought I attached the psf.
Here it is. Note that it is really basic, just try to grap the basics here.
Demo-IconNotify.psf
Demo
(22.64 KiB) Downloaded 374 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Systray Application

Post by jvierra »

Works fine for me. It writes the outtput to the console.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Systray Application

Post by jvierra »

Here is a fixed version that displays in a message box. Removed reductant NI control.
Attachments
Demo-IconNotify.psf
(23.64 KiB) Downloaded 324 times
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Systray Application

Post by stevens »

Thanks but I still see 2 icons. One ugly yellow and green and one other icon :-(
screenshot
screenshot
Screenshot_2.png (3.12 KiB) Viewed 5663 times
Note: that's once I created an exe out of if and run this exe.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Systray Application

Post by jvierra »

Works fine for me.

Reset the "Opacity" of the form. 0% with a NotifyIcon causes odd behaviors.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Systray Application

Post by stevens »

Thanks, but I don't want the form to show at all. Is that possible (or is that the reason of having two icons -where is the green and yellow icon -see my screenshot- one coming from?-)?

Actually what I would like to do:
-a tray icon application runs a scheduled task once a week (got that code which creates the task
-that scheduled task lists all the locally installed programs If one of those programs is on a list of not allowed software (a csv which I have), the icon should change to red and popup "unallowed software found, please remove".
-when the user clicks red icon, it will show a form listing the unapproved software in a form with a button "uninstall"
-when he clicks on an uninstall button the uninstallstring will be triggered
note: I'd add a startmenu item too, so a user can manually check for not allowed software too

That's possible?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Systray Application

Post by jvierra »

If you hide any form that has a systray declared in the form then the systray will not work as expected. To do this then you wiill have to manually create the systray icon and object outside of the form then if the systray object is global you can manage it from the form.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Systray Application

Post by stevens »

Well, maybe sapien powershell studio isn't the best match here.
Found this https://github.com/byteben/Toast and if it can run some actions, that sound much more what I'm looking for.
With WPF you can also create systray icons. Besides, the Sapien GUI, as far as I can see, is not offering but outdated GUI outlays, to bad.
This topic is 2 years and 9 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