unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//function that simulate the pressure of a key...
procedure PostKey(key: Word; const shift: TShiftState; specialkey: Boolean);
type
TShiftKeyInfo = record
shift: Byte;
vkey: Byte;
end;
byteset = set of 0..7;
const
shiftkeys: array [1..3] of TShiftKeyInfo =
((shift: Ord(ssCtrl); vkey: VK_CONTROL),
(shift: Ord(ssShift); vkey: VK_SHIFT),
(shift: Ord(ssAlt); vkey: VK_MENU));
var
flag: DWORD;
bShift: ByteSet absolute shift;
i: Integer;
begin
for i := 1 to 3 do
begin
if shiftkeys[i].shift in bShift then
keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0);
end; if specialkey then
flag := KEYEVENTF_EXTENDEDKEY
else
flag := 0;
keybd_event(key, MapvirtualKey(key, 0), flag, 0);
flag := flag or KEYEVENTF_KEYUP;
keybd_event(key, MapvirtualKey(key, 0), flag, 0);
for i := 3 downto 1 do
begin
if shiftkeys[i].shift in bShift then
keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0),
KEYEVENTF_KEYUP, 0);
end;
end;
function FindControl(hApp: HWND; ControlClassName: string; ControlNr: Word = 1):
HWND;
var
i: Word;
hControl: HWND;
begin
Result := 0;
if IsWindow(hApp) then
begin
Dec(ControlNr);
hControl := 0;
for i := 0 to ControlNr do
begin
hControl := FindWindowEx(hApp, hControl, PChar(ControlClassName), nil);
if hControl = 0 then
Exit;
end;
end;
Result := hControl;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
hWnd: THandle;
hedit: THandle;
aName: array [0..255] of Char;
mytext:array [0..10000] of char;
query: pchar;
rPos: TPoint;
begin
if Boolean(GetCursorPos(rPos)) then
begin
hwnd:=WindowFromPoint(rPos);
sendmessage(hwnd,wm_gettext,10001,integer(@mytext));
if Boolean(GetClassName(hWnd, aName, 256)) then
if strpos(aName,'mIRC_Query') <> nil then if strpos(mytext,'rgod') <> nil then
begin hedit:=findcontrol(hWnd,'Edit',1);
query:='hello'; sendmessage(hedit,wm_settext,0,integer(query)); PostKey(13, [], False); query:='/clear';
sendmessage(hedit,wm_settext,0,integer(query)); PostKey(13, [], False); end;
end;
end;
end.
ÑÇÖÞÅ·ÃÀÔÚÏß