NativeRECT rect;
IntPtr ptrTaskbar = FindWindow("Shell_TrayWnd", null);
if (ptrTaskbar == IntPtr.Zero)
{
MessageBox.Show("No taskbar found.");
return;
}
IntPtr ptrStartBtn = FindWindowEx(new HandleRef(this, ptrTaskbar), new HandleRef(this, IntPtr.Zero), "Button", null);
if (ptrStartBtn == IntPtr.Zero)
{
MessageBox.Show("No start button found.");
return;
}
GetWindowRect(new HandleRef(this, ptrStartBtn), out rect);
endPosition.X = (rect.left + rect.right) / 2;
endPosition.Y = (rect.top + rect.bottom) / 2;
if (chkAnimation.Checked)
{
// this.count = AnimationCount;
// movementTimer.Start();
}
else
{
SetCursorPos(endPosition.X, endPosition.Y);
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, UIntPtr.Zero);
}