David's helpful answer proporciona los punteros cruciales y enlaces útiles.
Para ponerlos en uso en un ejemplo de auto-contenido que implementa el escenario de ejemplo en la pregunta, el uso de la API de Windows a través de P/Invoke (System.Windows.Forms
es no involucrados):
using System;
using System.Runtime.InteropServices; // For the P/Invoke signatures.
public static class PositionWindowDemo
{
// P/Invoke declarations.
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOZORDER = 0x0004;
public static void Main()
{
// Find (the first-in-Z-order) Notepad window.
IntPtr hWnd = FindWindow("Notepad", null);
// If found, position it.
if (hWnd != IntPtr.Zero)
{
// Move the window to (0,0) without changing its size or position
// in the Z order.
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
}
}
Gracias por la ¡fuente! :) Es extremadamente útil. –
@DataDink, ¿moverías esta biblioteca a GitHub? – Theraot
localizó el nombre del proyecto: WindowScrape. Actualmente está disponible aquí: http://code.google.com/p/lol-mastery-tool/source/browse/LOL+Mastery+Tool/WindowScrape.dll?r=b88d6a538d88e052a88c69ffb70aaa09fc4a735e con la fuente disponible: https: // bitbucket .org/crwilcox/turbo-click/commits/89a687df7511490effb22ad3fc3e48fc9ab8c47a # chg-WindowScrape/ReadMe.txt Algunos contenidos de su archivo Léame, para búsquedas futuras 'La clase HwndObject encapsula un conjunto de funcionalidades alrededor de un identificador de Windows a un objeto UI. – mbrownnyc