notifications - Properly displaying a tray balloon tooltip in PowerShell -


itemprop = "text">

short version : I think I properly implement events in PowerShell as that one Need help with using a Windows message result to get rid of the icon of a balloon tooltip

Long version :.

I have a long-running PowerShell command

that I have to be notified when it completes in a system tray / notification area through a balloon tooltip. Are there. I was able to make a Wright-BalloonTip script (below) that does roughly what I want. The only problem is that, until I do not mouse over it, the tray icon does not disappear. By reusing the same global variable to represent, I am able to reuse this script and only have a system tray icon to keep it (unless I do not mouse over it). It still seems like a hack. I tried to add an event handler so that it will be notified on the event and after that it will be settled in the event handler, I tried all the three techniques I have suggested that there is no use to get rid of the lininging icon Happened.

The annoying part is that a simple . The revolt starts working on subsequent calls to the script, inspiring me to think that the event script block is not being called at all

I have verified that BalloonTycllcled A separate WinForms app is said to be away from the tip.

Am I missing some basic? Any help is much appreciated. ! Thanks

Here is the code for "Right-BalloonTip.ps1":

  the ultimate ($ text, $ title = "", $ icon = "info", $ Timeout = 15000) [System.Reflection.Assembly] :: LoadWithPartialName ("System.Windows.Forms") | OutRick [System.Reflection.Assembly] :: LoadWithPartialName ("System.Drawing") | If Null Out ($ Global: writeBalloonTipIcon) # # Get rid of the last $ $ of this: writeBalloonTipIcon.Dispose ()} $ global: writeBalloonTipIcon = new object System.Windows.Forms.NotifyIcon $ global: writeBalloonTipIcon.Icon = [ System.Drawing.SystemIcons] :: Information # FIXME: It should * have been done after the * cleaning *, but it does not seem to work in the $ global: writeBalloonTipIcon.add_BalloonTipClosed ({# * this * should * work, but It is not. What am I missing global $: writeBalloonTipIcon.Icon = $ null; $ global: writeBalloonTipIcon.Visible = $ false; $ Global: writeBalloonTipIcon.Dispose ();}); $ Global: writeBalloonTipIcon.Visible = $ true; $ Global: writeBalloonTipIcon.ShowBalloonTip ($ timeout, $ headline, $ text, $ icon);  

I think you need to execute this code in the STA thread. PowerShell (v2 shown here) performs in the MTA thread by default:

  PSU: \ & gt; [System.Threading.Thread] :: CurrentThread ManagedThreadId: 5 ExecutionContext: System.Threading.ExecutionContext Priority: Normal IsAlive: True IsThreadPoolThread: Incorrect IsBackground: Incorrect ThreadState: Moving ApartmentState: MTA CurrentUICulture: en-US CurrentCulture: en -US name: pipeline execution thread  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -