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.
User avatar
stevens
Posts: 451
Last visit: Fri Jul 02, 2021 1:35 am
Has voted: 1 time

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 125 times

jvierra
Posts: 14872
Last visit: Wed Jul 28, 2021 12:11 pm
Answers: 12
Has voted: 3 times
Been upvoted: 10 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: 451
Last visit: Fri Jul 02, 2021 1:35 am
Has voted: 1 time

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 134 times

jvierra
Posts: 14872
Last visit: Wed Jul 28, 2021 12:11 pm
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Systray Application

Post by jvierra »

Works fine for me. It writes the outtput to the console.

jvierra
Posts: 14872
Last visit: Wed Jul 28, 2021 12:11 pm
Answers: 12
Has voted: 3 times
Been upvoted: 10 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 132 times

User avatar
stevens
Posts: 451
Last visit: Fri Jul 02, 2021 1:35 am
Has voted: 1 time

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 2665 times
Note: that's once I created an exe out of if and run this exe.

jvierra
Posts: 14872
Last visit: Wed Jul 28, 2021 12:11 pm
Answers: 12
Has voted: 3 times
Been upvoted: 10 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: 451
Last visit: Fri Jul 02, 2021 1:35 am
Has voted: 1 time

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: 14872
Last visit: Wed Jul 28, 2021 12:11 pm
Answers: 12
Has voted: 3 times
Been upvoted: 10 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: 451
Last visit: Fri Jul 02, 2021 1:35 am
Has voted: 1 time

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.

Locked