如何用Delphi捕获JavaScript中Alert提示的内容? |
答題得分者是:chris_shieh
|
zyt
一般會員 發表:5 回覆:1 積分:1 註冊:2004-12-16 發送簡訊給我 |
各位老大,我能够捕获JavaScript中Alert的提示并且关闭该提示窗口。但是要读取Alert提示中的内容,如何实现? procedure TfileProcess.BitBtn4Click(Sender: TObject);
var
HWnd1 : HWnd;
begin
// close the alert message
HWnd1 := Winprocs.FindWindow(nil, 'Microsoft Internet Explorer');
if HWnd1 <> 0 then
begin
//waiting for your answer...
//读取Alert提示中的内容。
SendMessage(HWnd1, WM_CLOSE, 0, 0);
end
else showmessage('not run');
end; 附图的提示内容为‘代号不能为空’,如何才能得到该值。等待您的答案,不胜感谢!
|
zyt
一般會員 發表:5 回覆:1 積分:1 註冊:2004-12-16 發送簡訊給我 |
|
chris_shieh
高階會員 發表:46 回覆:308 積分:240 註冊:2004-04-26 發送簡訊給我 |
GetHWndByClassName function請參考
[Program Name、PID、Window Handle、hProcess 的轉換函式]http://delphi.ktop.com.tw/topic.php?TOPIC_ID=61654
function GetDlgItemHwndById(hDlg: THandle; Identifier: integer): THandle; var hControl: THandle; begin hControl := 0; if hDlg > 0 then hControl := GetDlgItem(hDlg, Identifier); Result := hControl; end; ... Function GetDialogText:String; var iStartTick: cardinal; hDialog, hText: THandle; szCaption: array[0..254] of Char; begin Result:=''; iStartTick := GetTickCount; repeat //hDialog:=FindWindow(nil, 'Microsoft Internet Explorer'); hDialog := GetHWndByClassName('#32770'); Application.ProcessMessages; until (hDialog > 0) or ((GetTickCount - iStartTick) > 3000); if (hDialog > 0) then begin hText:= GetDlgItemHwndById(hDialog, 65536); if (hText> 0) then begin Result:=GetWindowTextW(hText, szCaption, 255); end; end; end;@瞭解越多.懂得越少@ 發表人 - chris_shieh 於 2005/09/07 12:59:59 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |