Quote:
Originally Posted by Xijezu
Would be another method, but I personally don't like the solution with Winsock. I personally would have handled it via SendMessage, but obviously this doesn't work. :/
|
Code:
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.Dll", EntryPoint = "PostMessageA")]
static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern byte VkKeyScan(char ch);
[DllImport("user32.dll", SetLastError = true)]
static extern bool ShowWindow(IntPtr handle, ShowWindowCommand command);
const uint WM_KEYDOWN = 0x100;
private enum ShowWindowCommand : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11,
}
string tool = Process.GetCurrentProcess().ProcessName;
Process[] pr = Process.GetProcessesByName("sframe");
Process[] _tool = Process.GetProcessesByName(tool);
if (pr.Length > 0)
{
ShowWindow(pr[0].MainWindowHandle, ShowWindowCommand.SW_RESTORE);
Thread.Sleep(100);
SetForegroundWindow(pr[0].MainWindowHandle);
Thread.Sleep(100);
SendKeys.SendWait("{ENTER}");
SendKeys.SendWait("^V"); //zwischenspeicher
SendKeys.SendWait("{ENTER}");
ShowWindow(_tool[0].MainWindowHandle, ShowWindowCommand.SW_RESTORE);
Thread.Sleep(100);
SetForegroundWindow(_tool[0].MainWindowHandle);
}
:p