If you'd like to learn more, check out this article titled Use the ApplicationContext Class to Fully Encapsulate Splash Screen Functionality where the author goes into detail about the ApplicationContext class. I'll be honest, I'm probably not the best person to explain ApplicationContexts in depth. $appContext = New-Object ::Run($appContext)Īccording to Microsoft, " Application.Run begins running a standard application message loop on the current thread, with an ApplicationContext, which specifies the contextual information about an application thread." Now these two lines, along with Hide-PowerShell are always included in my finalized PowerShell-based WPF scripts. This information, along with Johnny J's article about NotifyIcons helped me figure out that the following would probably work, even for WPF. So none of the solutions I found worked, but I remembered that Denniver's NotifyIcon script was responsive, so I went back and noticed his app ended with this important line In addition, the mouse sometimes showed as busy when hoovering over the popup window itself and sometimes the right clicking worked only once. Just search Google for " NotifyIcon doesn't disappear". So I scoured the Internet and found that a lot of other people had the same issue. Then it would take about 5 seconds to disappear.įor about a week, this was the story of my life:Īnd it seemed especially true after hiding the Powershell taskbar application. The NotifyIcon issue took a number of days to resolve as I battled with unresponsiveness when clicking on the ContextMenu to Exit. While neither of the articles were using WPF, extensive testing showed that using ApplicationContexts and Application.Run instead of ShowDialog() made WPF (and WinForms) work far better. I was tipped off to this by Denniver Reining's PowerShell / NotifyIcon article and Johnny J's " Doing a (C#) NotifyIcon program the right way". One of the lessons learned when making Popups and NotifyIcons in PowerShell and WPF is that the WPF window must be run the the proper context. Update Jan 7: Added KeyboardInterop so that TextBoxes will work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |