Posts Tagged ‘GUIProgramming’


PowerShell GUI Apps: Why think in events?

Monday, January 4th, 2016 by June Blender
Always committed to starting the New Year right, I’m heading to Scottsdale, Arizona on Tuesday, January 5 at 5:30 PM to meet with the newly revived Arizona PowerShell User Group. We’ll meet at the Microsoft Store in Scottsdale Fashion Square. (I will not be distracted by the Surface Pro 4 on display. I will not…)   I’ll be there to lead an interactive hands-on lab in which participants build a basic PowerShell GUI application – essentially, a graphic user interface for a PowerShell script. When you press a button, it runs part of the script. When you type text in…   More »

Spotlight on the Label Control

Wednesday, December 16th, 2015 by June Blender
The Spotlight on Controls series describes the controls, that is, the objects in the System.Windows.Forms namespace, so you can use them effectively when building GUI apps in PowerShell Studio and PrimalScript. Each post focuses on one control and lists its most important properties, methods, and events, including the default event that PowerShell Studio adds to your script when you double-click the control. The posts include many examples written in Windows PowerShell, so you can use them right away. Read more: Spotlight on Controls: Common properties and methods This post describes the Label control. Label Control [System.Windows.Forms.Label] Creates a clickable text…   More »

Scope in a PowerShell GUI App

Wednesday, September 9th, 2015 by June Blender
If you search the SAPIEN blog, you'll realize that this is the not our first blog about scope in PowerShell GUIs. In March 2013, SAPIEN CTO Alex Riedel wrote First Rule of PowerShell Scoping Rules, a title that implies the final word in a discussion that wasn't easy to end. Alex's blog explained the differences between scoping rules in PowerShell and other languages, like VB Script. Then, just a month later, SAPIEN Senior Developer David Corrales wrote PowerShell Scoping Revisited, another great post about function scope in PowerShell. A quick search reveals even older posts by Don Jones and Jeffery…   More »

PowerShell GUI Debugging Tip: Duplicate Event Handlers

Tuesday, September 8th, 2015 by June Blender
I'm not a professional tester, but I am an expert at making mistakes. I take risks. I try everything. I gravitate to "corner cases" and odd circumstances. That makes me a great amateur tester and, due to a lifetime of experience with breaking things, a pretty good debugger. But, at the Omaha PowerShell User Group meeting in August 2015, I was stumped. What caused this bug? David Jones, an Omaha PSUG member and talented PowerSheller, showed me the following code. $FormGetService_Load = { $textboxComputerName.Text = $env:ComputerName } Looks perfect. But when he ran his script, on load, the $TextboxComputerName textbox was empty.  …   More »

The Methods that Register Events

Monday, August 31st, 2015 by June Blender
If you create PowerShell GUI apps in PowerShell Studio, you become very familiar with the events of the Windows Forms types, like the Load event of forms, the Click event of buttons, and the TextChanged event of textboxes. PowerShell Studio handles most of the background details of event management for you, but it's useful and interesting to understand how events work in the Microsoft .NET Framework. This knowledge comes in especially handy when something doesn't work and you need to understand enough to fix it. One of the little mysteries that I couldn't understand were the methods the .NET uses…   More »

PowerShell GUIs: Where do I start?

Thursday, July 16th, 2015 by June Blender
Follow @juneb_get_help I've been using Windows PowerShell since the very first version of Monad in 2005, but PowerShell-based applications with a graphic user interface (GUI) are a whole new world. Instead of thinking of cmdlets and parameters or properties and methods, you need to think in object events. And because there's no console with .ps1xml-directed views, you need manage all output streams, including standard output and errors. Most importantly, because you're dealing with real users, you need to assume that people will type and click whatever they please in whatever order you let them. It reminds me of turning the…   More »

Displaying Output in a GUI Application

Monday, December 15th, 2014 by June Blender
After many years of writing scripts for the Windows PowerShell console, I'm now learning the next level of automation -- writing GUI applications that run Windows PowerShell commands. PowerShell Studio forms provide a gentle and well-guided introduction to GUI applications, but it's still taken me some time to break old habits. I constantly need to remind myself that things that "just work" in the console don't make any sense in a GUI. Writing output is one of them. Writing Output to the Console When you generate output in the Windows PowerShell console, the output appears as text strings in the…   More »