Source: blogs.technet.com --- Saturday, December 26, 2015
Summary : Boe Prox shows us how to manage window placement in Windows PowerShell. Honorary Scripting Guy and Cloud and Datacenter Management MVP, Boe Prox, here today filling in for my good friend, the Scripting Guy. Today I start a little weekend fun by using a technique known as platform invoke, or PInvoke for short. What is PInvoke, you ask? Well, PInvoke allows us to utilize the low-level Windows API to call functions that would normally not be available to us natively. This allows us to do some pretty cool things, such as looking at files with a file path that is greater than the MAX_PATH allowed when using normal means, such as Get-ChildItem —or even with privileges in PowerShell. Of course, all of this sounds nice and fun, but how do we actually accomplish something like this? We have a few options to make this happen: Use reflection to define the methods needed to call the API Use a private reference Find signatures online that are written in C# and copy them to compile into a usable type that we can use in PowerShell (the focus of this post) I feel the easiest approach to working with PInvoke using PowerShell is looking for the proper PInvoke signatures needed to accomplish my goal. And what is my goal today? It is to show how we can find the X and Y coordinates of a window by using its process and its size. Then I’ll take that one step further by actually moving the window to another location on the screen. It may not b ...
from Windows http://ift.tt/1IvaIZ4
No comments:
Post a Comment