## Powershell script to snap an app in Windows 8

That doesn’t mean there is no other way 🙂

At work, we have to test our app in a snapped state, so we need a way to programmatically make it happen. We discovered that there are two keyboard shortcuts for this action. Windows Key + . (the period key) snaps to the right edge, and Windows Key + Shift + . snaps to the left edge.

So all we have to do is send these keys to the operating system. Sending the Windows Key is tricky, and not supported using only [System.Windows.Forms.SendKeys]::SendWait.

So here’s an alternative:

1 2 [Reflection.Assembly]::LoadFile("C:\path\to\InputSimulator.dll") [WindowsInput.InputSimulator]::SimulateModifiedKeyStroke('LWIN', 'OEM_PERIOD')