Для робота, использующего WinAPI пишется команда — щелкнуть кнопку, такого вида. Кнопка находится, но щелчок не отрабатывает. в чем может быть причина?
[Cmdlet(VerbsCommunications.Send, "Click")]
public class SendClickCommand : Cmdlet
{
private IntPtr handleControl;
[Parameter(Position = 0)]
public IntPtr HandleControl {
get { return handleControl; }
set { handleControl = value; }
}
[DllImport("user32.dll", EntryPoint = "PostMessage", CharSet = CharSet.Auto)]
private static extern int PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
protected override void ProcessRecord() {
uint WM_LBUTTONDOWM = 0x0201;
uint WM_LBUTTONUP = 0x0202;
PostMessage(handleControl, WM_LBUTTONDOWM, 0, 0);
PostMessage(handleControl, WM_LBUTTONUP, 0, 0);
string feedback = string.Empty;
if (handleControl != IntPtr.Zero)
{
feedback = feedback + "found.";
}
WriteObject(feedback + "Click sent");
}
} // class SendClickCommand
спасибо.