实现打开IE浏览器并打开指定网页,移动鼠标到指定坐标并左键单击,但是运行出错,不知道错在什么地方了,请指点一下,
procedure TForm1.Button1Click(Sender: TObject);begin
    ShellExecute(Handle, 'open', 'IExplore.EXE', 'http://www.126.com', nil, SW_SHOWNORMAL);
    sleep(5000);
    setcursorpos(500,500);
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
end;

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,ShellAPI; (没有加载SHELLAPI)type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
        ShellExecute(Handle, 'open', 'IExplore.EXE', 'http://www.126.com', nil, SW_SHOWNORMAL);
        sleep(5000);
        setcursorpos(500,500);
        mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    end;end.
      

  2.   

     不是没加载ShellAPI的缘故,程序上加了,运行提示的信息是Format '1%' invalid or incompatible with argument
      

  3.   

    附上我的全部的代码:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,shellapi, StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    shellexecute(0,'open',pchar('C:\Program Files\Internet Explorer\IEXPLORE.EXE'),pchar('http://www.baidu.com/'),0,sw_showmaximized);
    sleep(8000);
    setcursorpos(0,0);
    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
    end;end.
      

  4.   

    DELPHI6里面是正常的,要么你的DELPHI7里面少文件。
      

  5.   

    好奇怪,我无意中往Form中添加了个Webbrowser控件,关于它的啥操作和事件都没写,一运行就可以了,而且我把这个控件删除了,运行也可以了,不知道是什么问题?