title: Do Something on WPF Form Minimize –PowerShell (version 5)
body: <p>I have PowerShell script that creates a WPF form from inserted XML code. This form will run on a kiosk station and has no window (so no maximize, minimize, or close buttons) and consumes the entire screen. </p>
  
  <p>Even though the form itself has no window buttons, a person can still press the <kbd>WIN</kbd> key on a keyboard, get the task bar, right click on the form in the task bar and choose to minimize, maximize, or close for the form.</p>
  
  <p>So, I set an action for close to lock the workstation (which is better option for this kiosk instead of preventing the form from closing at all) by doing this: </p>
  
  <pre><code>$form.Add_Closing({
      $shell = New-Object -ComObject "Wscript.Shell"
      $shell.Run("%windir%\System32\rundll32.exe user32.dll,LockWorkStation")
  })
  </code></pre>
  
  <p>I would also like to do this for Minimize if possible, but can’t seem to figure out how.</p>
  
  <p>FYI. I’m not intending this to be a <em>security</em> feature per-se, but more so something that is better done then not for this kiosk station. </p>