写一个聊天辅助程序
Code
procedure?TForm1.Button1Click(Sender:?TObject);
var
hParent,hButton,hMemo:?HWND;
begin
Memo1.SelectAll;//Memo內容全選
Memo1.CopyToClipboard;//把Memo中選中的語句拷貝到剪貼板中
try
//找發送消息的QQ窗口
hParent?:=?FindWindow(nil,?'發送消息');
//然后找回話時用的編輯窗口,Point函數用于返回一個TPoint類型變量
hMemo?:=?ChildWindowFromPointEx(hParent,?Point(50,?100),?CWP_ALL);
//找到“送訊息”按鈕的句柄?
hButton?:=?FindWindowEx(hParent,0,nil,'送訊息(&S)');
if?(hParent?=?0)?or?(hMemo?=?0)?or?(hButton?=?0)?then
MessageBox(Handle,'沒有找到發送窗口,請重試!','錯誤',MB_ICONWARNING)
else
begin
//向發送消息中的回話編輯框發送粘貼消息
SendMessage(hMemo,WM_PASTE,0,0);
//向“送訊息”按鈕送單擊消息以模仿按鍵發送回話
SendMessage(hButton,BM_CLICK,0,0);
end;
except
//如果發生意外錯誤給出提示
MessageBox(Handle,'發送消息出錯,請重試!','錯誤',MB_ICONWARNING);
end;
end;
procedure?TForm1.Button2Click(Sender:?TObject);
var
hParent,hButton,hMemo:?HWND;
begin
Memo1.SelectAll;
Memo1.CopyToClipboard;//把Memo中選中的語句拷貝到剪貼板中
try
//找對話模式中窗口
hParent?:=?FindWindow(nil,?'對話模式');
//找到對話模式中的回話編輯框
hMemo?:=?ChildWindowFromPointEx(hParent,?Point(50,?300),?CWP_ALL);
hButton?:=?FindWindowEx(hParent,0,nil,'送訊息(&S)');
//如果有任何一個句柄沒有找到都不能完成發送,并給出提示?
if?(hParent?=?0)?or?(hMemo?=?0)?or?(hButton?=?0)?then
MessageBox(Handle,'沒有找到發送窗口,請重試!','錯誤',MB_ICONWARNING)
else
begin
//向對話模式中的回話編輯框發送粘貼消息
SendMessage(hMemo,WM_PASTE,0,0);
//向“送訊息”按鈕送單擊消息以模仿按鍵發送回話
SendMessage(hButton,BM_CLICK,0,0);
end;
except
//如果發生意外錯誤給出提示
MessageBox(Handle,'發送消息出錯,請重試!','錯誤',MB_ICONWARNING);
end;
end;
end.
procedure?TForm1.Button1Click(Sender:?TObject);
var
hParent,hButton,hMemo:?HWND;
begin
Memo1.SelectAll;//Memo內容全選
Memo1.CopyToClipboard;//把Memo中選中的語句拷貝到剪貼板中
try
//找發送消息的QQ窗口
hParent?:=?FindWindow(nil,?'發送消息');
//然后找回話時用的編輯窗口,Point函數用于返回一個TPoint類型變量
hMemo?:=?ChildWindowFromPointEx(hParent,?Point(50,?100),?CWP_ALL);
//找到“送訊息”按鈕的句柄?
hButton?:=?FindWindowEx(hParent,0,nil,'送訊息(&S)');
if?(hParent?=?0)?or?(hMemo?=?0)?or?(hButton?=?0)?then
MessageBox(Handle,'沒有找到發送窗口,請重試!','錯誤',MB_ICONWARNING)
else
begin
//向發送消息中的回話編輯框發送粘貼消息
SendMessage(hMemo,WM_PASTE,0,0);
//向“送訊息”按鈕送單擊消息以模仿按鍵發送回話
SendMessage(hButton,BM_CLICK,0,0);
end;
except
//如果發生意外錯誤給出提示
MessageBox(Handle,'發送消息出錯,請重試!','錯誤',MB_ICONWARNING);
end;
end;
procedure?TForm1.Button2Click(Sender:?TObject);
var
hParent,hButton,hMemo:?HWND;
begin
Memo1.SelectAll;
Memo1.CopyToClipboard;//把Memo中選中的語句拷貝到剪貼板中
try
//找對話模式中窗口
hParent?:=?FindWindow(nil,?'對話模式');
//找到對話模式中的回話編輯框
hMemo?:=?ChildWindowFromPointEx(hParent,?Point(50,?300),?CWP_ALL);
hButton?:=?FindWindowEx(hParent,0,nil,'送訊息(&S)');
//如果有任何一個句柄沒有找到都不能完成發送,并給出提示?
if?(hParent?=?0)?or?(hMemo?=?0)?or?(hButton?=?0)?then
MessageBox(Handle,'沒有找到發送窗口,請重試!','錯誤',MB_ICONWARNING)
else
begin
//向對話模式中的回話編輯框發送粘貼消息
SendMessage(hMemo,WM_PASTE,0,0);
//向“送訊息”按鈕送單擊消息以模仿按鍵發送回話
SendMessage(hButton,BM_CLICK,0,0);
end;
except
//如果發生意外錯誤給出提示
MessageBox(Handle,'發送消息出錯,請重試!','錯誤',MB_ICONWARNING);
end;
end;
end.
轉載于:https://www.cnblogs.com/bsoom/archive/2009/11/14/1603063.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
- 上一篇: rhce考试试题以及答案_RedHat红
- 下一篇: 怎样用css设置图片下的投影,css –