level 1
哎呦喂Ω℃℉◆
楼主
我想实现一个在QQ游戏的窗口中单击某个按钮的功能,FINDWINDOW的窗口标题和按钮坐标都是spy++截获的,应该没错,代码也检查了几遍,但是点击启动按钮后,程序没有单击窗口中的按钮!
以下是代码,初来乍到帮个忙呗
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,GameProc;
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
Start;
end;
end.
//下面是调用的子程序
//
unit GameProc;
interface
uses windows,Messages;
procedure Start;
implementation
//游戏开局
procedure Start;
var
Gameh:HWND;
begin
Gameh:=FindWindow(nil,'QQ游戏' );
//模拟鼠标单击
SendMessage(Gameh,Messages.WM_LBUTTONDOWN,0,$00F600B8);//按下
SendMessage(Gameh,Messages.WM_LBUTTONUP, 0, $00F600B8);//抬起
end;
end.