Hello,
I would like to create a systray application with powershell studio.
I don't see method that I have to use.
I already tried to use a notifyicon object in my Form.
But
when I do $Form.hide or $Form.visible=$false, my form exit.
when I do $Form.WindowState = 'Minimized' and $Form.ShowInTaskbar = $false, my form exit.
So
I bought PowerShell Studio 2019 to be able to create "windows Tray App"
But when I create a Tray App, I don't see how to use my notification icon to hide or show my form.
_ Maybe I have to use $SAPIENHost. ? But I found nothing about this new variable.
_ Is there some click events that I could use ? Like with notifyicon object in a form.
Regards,
systray application
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.
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.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: systray application
Please see:
https://www.sapien.com/blog/2017/07/10/ ... owershell/
and
https://www.sapien.com/blog/2019/01/10/ ... lications/
https://www.sapien.com/blog/2017/07/10/ ... owershell/
and
https://www.sapien.com/blog/2019/01/10/ ... lications/
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: systray application
Thank you, but I already read them.
That why I know that $SAPIENHost object exist.
I found nothing about this new object. (any method to explore it ?)
I don't want to click on a menu, but just on the icon.
Like it's possible to do with the $notifyicon object.
If I build with $notifyicon, I can't hide the aplication
If I build with "Windows Tray App", I'm unable to handle the event MouseClick in the systray icon
That why I know that $SAPIENHost object exist.
I found nothing about this new object. (any method to explore it ?)
I don't want to click on a menu, but just on the icon.
Like it's possible to do with the $notifyicon object.
If I build with $notifyicon, I can't hide the aplication
If I build with "Windows Tray App", I'm unable to handle the event MouseClick in the systray icon
Re: systray application
The first example test code does not work as it is missing files and was built to only run on the 2017 version of PSS.
The second linked example suffers from most of the same deficiencies.
The URL file should not be stored in "Programs" and the icon file needs to be in the app folder.
Change this: "C:\projects\2019 Products and versions\PrimalScript 2019\x64\Debug\ScriptPackage.ico" to point to an icon.
Change the URL file to the app folder or to a user folder under AppData\Local
The second linked example suffers from most of the same deficiencies.
The URL file should not be stored in "Programs" and the icon file needs to be in the app folder.
Change this: "C:\projects\2019 Products and versions\PrimalScript 2019\x64\Debug\ScriptPackage.ico" to point to an icon.
Change the URL file to the app folder or to a user folder under AppData\Local
Re: systray application
Thank you for your answer, but I don't understand what I can copy/past for you ?
I'm asking "how to make a systray application".
MainForm.psf :
1th example :
I don't want to show a popoup.
I want to show a form. (my form will be more complex than just say "hello")
2nd example :
I don't want a menu on the systray icon.
I just want to click on the icon, to show my form,
AND be able to close the form and still have the systray icon, to be able to show my form again.
I'm asking "how to make a systray application".
MainForm.psf :
- $form1_Load={
- $textbox1.Text = "Hello " $env:USERNAME
- }
I don't want to show a popoup.
I want to show a form. (my form will be more complex than just say "hello")
2nd example :
I don't want a menu on the systray icon.
I just want to click on the icon, to show my form,
AND be able to close the form and still have the systray icon, to be able to show my form again.
Re: systray application
You will have to create a custom systray application that does what you want. The Sapien Systray host does not allow us to add an event to the icon. We can only add menu items.
Here is a simple example of how to create an icon form that can respond to the click on the icon. The form is semi-transparent and can be fully hidden in code. The click can unhide the form or launch a new form.
It is the most basic example that I have and has no fancy gadgets. You can use it as a start. Build it with the forms host.
Here is a simple example of how to create an icon form that can respond to the click on the icon. The form is semi-transparent and can be fully hidden in code. The click can unhide the form or launch a new form.
It is the most basic example that I have and has no fancy gadgets. You can use it as a start. Build it with the forms host.
- Attachments
-
- Demo-IconNotify.psf
- (16.9 KiB) Downloaded 191 times
Re: systray application
Ok. So I have to forget the Sapien Systray.
If I understood, the method would be :
Build a MainForm with 0% Opacity, with a notifyicon, just to stay in memory.
And this notifyicon can show/hide a ChildForm where all my app is.
If that work, that answer all I wanted
Thank you !
My app have to be installed on 5000 workstations, 24/7.
Does this transparent MainForm could disturb my users ?
_ With 0px * 0px size, the MainForm still be a bit big, and could bother some click.
_ Less important, stay in "Alt+Tab" view.
Maybe I have to change language to do it ?
But I need a lot of PowerShell commands in my app.
Any suggestion ?
If I understood, the method would be :
Build a MainForm with 0% Opacity, with a notifyicon, just to stay in memory.
And this notifyicon can show/hide a ChildForm where all my app is.
If that work, that answer all I wanted
Thank you !
My app have to be installed on 5000 workstations, 24/7.
Does this transparent MainForm could disturb my users ?
_ With 0px * 0px size, the MainForm still be a bit big, and could bother some click.
_ Less important, stay in "Alt+Tab" view.
Maybe I have to change language to do it ?
But I need a lot of PowerShell commands in my app.
Any suggestion ?