Created
February 15, 2017 22:17
-
-
Save KeyWeeUsr/e433ca3f12ffc927c196dd4b30adc302 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CSsource = @" | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Diagnostics; | |
namespace Win { | |
public static class API { | |
[DllImport("user32.dll")] | |
static extern IntPtr FindWindow( | |
string lpClassName, | |
string lpWindowName | |
); | |
[DllImport("user32.dll")] | |
public static extern IntPtr FindWindowEx( | |
IntPtr parentHwnd, | |
IntPtr childAfter, | |
string className, | |
string windowTitle | |
); | |
[DllImport("user32.dll")] | |
static extern bool ShowWindow( | |
IntPtr hWnd, | |
int nCmdShow | |
); | |
[DllImport("user32.dll")] | |
static extern bool MoveWindow( | |
IntPtr hWnd, | |
int X, int Y, | |
int Width, int Height, | |
bool Repaint | |
); | |
public static void Move( | |
string wClass, string wName, | |
string childClass, | |
int top, int left, | |
int width, int height | |
) { | |
IntPtr hwnd = FindWindow(wClass, wName); | |
if ((int) hwnd > 0) { | |
IntPtr subHwnd; | |
if (childClass != String.Empty) { | |
subHwnd = FindWindowEx(hwnd, IntPtr.Zero, childClass, null); | |
} else { | |
subHwnd = IntPtr.Zero; | |
} | |
if ((int) subHwnd > 0) { | |
MoveWindow(subHwnd, left, top, width, height + 50, true); | |
Process.Start("cmd"); //feedback from loop, heh | |
} else { | |
MoveWindow(hwnd, left, top, width, height + 50, true); | |
} | |
} | |
} | |
} | |
} | |
"@ | |
add-type -TypeDefinition $CSsource | |
#[Win.API]::Move('OSKMainClass', 'On-Screen Keyboard', 'DirectUIHWND', 50, 50, 200, 100) | |
#[Win.API]::Move('OSKMainClass', 'Accessibility On-Screen Keyboard', 'DirectUIHWND', 50, 50, 200, 100) | |
[Win.API]::Move('OSKMainClass', 'Accessibility On-Screen Keyboard', '', 50, 50, 200, 100) | |
[Win.API]::Move('Notepad', 'Untitled - Notepad', '', 50, 50, 200, 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment