Restarted my PC, works as expected.
Weird behavior.
Tray App no output
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.
Re: Tray App no output
No. This is something that every developer learns. When building and debugging the system can become unpredictable. Also having multiple notifications stacked and not removed can cause the icon group be have oddly. This is likely due to running under a debugger but can be caused by certain coding. The icon group and the system notification software can get at odds. Some code in an icon is executed by a callback to the program that created the icon. This can cause the thread that is called back into to get stuck in memory. That can make the notification system behave oddly. Rebooting or logging of and on will clear this most of the time. Making system calls inside the callback delegate can aggravate this to the point of requiring a reboot.
The reason I like to see that code is that I am usually pretty good at seeing where the code is misbehaving. Of course a debugger induced issue will not be visible in the code.
Anyway - it is good you resolved the issue so easily. If the issue returns we will have to see your code to see what might be causing this.
The reason I like to see that code is that I am usually pretty good at seeing where the code is misbehaving. Of course a debugger induced issue will not be visible in the code.
Anyway - it is good you resolved the issue so easily. If the issue returns we will have to see your code to see what might be causing this.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Tray App no output
Hello,
I wanted to note, this application was the first thing I started working on when I turned on my PC.. While your points are valid, I just wanted to point that out. I did put my code in my OP but incase, I've made changes to it today. I'm looking to not compress-archive if powershell studio is running.. This isn't happening
I wanted to note, this application was the first thing I started working on when I turned on my PC.. While your points are valid, I just wanted to point that out. I did put my code in my OP but incase, I've made changes to it today. I'm looking to not compress-archive if powershell studio is running.. This isn't happening
- function LoadFile{
- $global:File = (!(Get-Process -Name 'PowerShell Studio' -ErrorAction SilentlyContinue))
- }
- while($false)
- {
- Write-Host "Kompressor Starting..."
- LoadFile
- $Options = @(
- "/E",
- "/l"
- )
- $rclog = Robocopy "C:\users\tech\Documents\SAPIEN" \xxx $Options
- $rclog | out-file C:\users\tech\Documents\SAPIEN\Filecount.txt
- Compress-Archive -Path C:\users\tech\Documents\SAPIEN -DestinationPath C:\Windows\Utilities\Sapien.zip -CompressionLevel NoCompression -Update
- Write-Host "Kompressor Completed..."
- Start-Sleep -Seconds 1800
- }
- while ($true)
- {
- Write-Host "Reseting timer..."
- Start-Sleep 10
- }
Re: Tray App no output
But the code you posted has nothing to do with notify icon. It is just some code that compresses a file and sleeps for 30 minutes. That is very odd and can cause issues if an event is blocking like that.
Also the loop in the code will never run.
while ($false) {
This statement will never allow the contents to run.
Also the loop in the code will never run.
while ($false) {
This statement will never allow the contents to run.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Tray App no output
I don't think you're following what I'm asking.. I'm looking to build a Windows Tray App... btw this code is now working for me.. I had the logic wrong
- function LoadFile{
- $global:File = (Get-Process -Name 'PowerShell Studio' -ErrorAction SilentlyContinue)
- }
- while ($true)
- {
- Write-Host "Kompressor Starting..."
- LoadFile
- #If PowerShell Studio is not running, perform compression.
- if (!($File))
- {
- $Options = @(
- "/E",
- "/l"
- )
- $rclog = Robocopy "C:\users\tech\Documents\SAPIEN" \xxx $Options
- $rclog | out-file C:\users\tech\Documents\SAPIEN\Filecount.txt
- Compress-Archive -Path C:\users\tech\Documents\SAPIEN -DestinationPath C:\Windows\Utilities\Sapien.zip -CompressionLevel NoCompression -Update
- Write-Host "Kompressor Completed..."
- Start-Sleep -Seconds 1800
- }
- #If powershell studio is running,
- else
- {
- Start-Sleep -Seconds 10
- Write-Host "Close PowerShell Studio..."
- Start-Sleep -Seconds 10
- Write-Host "Reseting timer..."
- }
- }
Re: Tray App no output
I posted an example of a tray app (really a NotifyIcon Form) earlier. Somewhere I have a demo of a non-form icon script that posts messages to the system notification center and shows how to add menu items to the tray icon. The method is much the same as the form example.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Tray App no output
I just downloaded your first posts example
when I build it.. It just shows the icon..
To be clear, my toast notifications are working and using the Windows Tray App script engine seems to be working well
when I build it.. It just shows the icon..
To be clear, my toast notifications are working and using the Windows Tray App script engine seems to be working well
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Tray App no output
Just as a last post.. I've found that BurntToast does notifications much slicker
https://www.powershellgallery.com/packa ... oast/0.6.3
https://www.powershellgallery.com/packa ... oast/0.6.3
Re: Tray App no output
Now that is real "Toast". It provides a complete wrapper and decent commands. I also have that module and have for a very long time. I still prefer to hand code this as many apps do not layout the same way.
- apowershelluser
- Posts: 194
- Last visit: Fri Mar 22, 2024 4:38 am
Re: Tray App no output
I just found the fact I can add an icon cool.. its the little things.. now I'm just stuck on detecting if my flash drive is detected or not... I'm thinking that will be a do while script