wbSendSMS: TWebBrowser;
procedure TfrmSend.btnSendClick(Sender: TObject);
var
ovTargetFrameName:OleVariant;
ovPostData :OleVariant;
ovFlags :OleVariant;
ovHeads :OleVariant;
begin
if(cmbRecCode.ItemIndex=-1) then
begin
MessageBox(Handle,'选择接收的号码!','提示信息',MB_OK);
Exit;
end;
if(CheckCode(PRecCodeInfo(cmbRecCode.Items.Objects[cmbRecCode.ItemIndex])^.sRecCode)=false) then
begin
MessageBox(Handle,'接收号码不正确!','提示信息',MB_OK);
Exit;
end;
if(cmbSendCode.ItemIndex=-1) then
begin
MessageBox(Handle,'选择发送的号码!','提示信息',MB_OK);
Exit;
end;
if(CheckCode(PSendCodeInfo(cmbSendCode.Items.Objects[cmbSendCode.ItemIndex])^.sSendCode)=false) then
begin
MessageBox(Handle,'发送号码不正确!','提示信息',MB_OK);
Exit;
end;
if(Trim(memSendContent.Text)='') then
begin
MessageBox(Handle,'输入发送的内容!','提示信息',MB_OK);
memSendContent.SetFocus;
Exit;
end;
iSendSMS:=0;
ovTargetFrameName:=0;
ovPostData:=0;
ovHeads:=0;
ovFlags:=0;
wbSendSMS.Navigate('http://sms.sina.com.cn/docs/send.html',
ovFlags,ovTargetFrameName,ovPostData,ovHeads);
sbSendSMS.Panels.Items[0].Text:='正在发送...';
end;
procedure TfrmSend.btnCancelClick(Sender: TObject);
begin
wbSendSMS.Stop;
//Close;
end;
procedure TfrmSend.wbSendSMSDocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
i :integer; //循环使用
iInputCount:integer; //计算<Input> 的次数
ovDoc :OleVariant; //取得网页的内容
sSendCode :AnsiString; //发送手机号码
sPassword :AnsiString; //发送短消息的密码
sRecCode :AnsiString; //接收代码
begin
case iSendSMS of
0:
begin
Inc(iSendSMS);
ovDoc:=(Sender as TWebBrowser).Document;
iInputCount:=0;
for i:=0 To ovDoc.All.Length-1 do
begin
if (ovDoc.All.Item(i).tagName = 'TEXTAREA')and //一定大写
(ovDoc.All.Item(i).name='msg')then //大小写与原文一致
begin
ovDoc.All.Item(i).Value:=DeleteCR(memSendContent.Lines.Text);
Inc(iInputCount);
end;
if (ovDoc.All.Item(i).tagName = 'INPUT')and //一定大写
(ovDoc.All.Item(i).type='text')and //大小写与原文一致
(ovDoc.All.Item(i).Name='mob1')then
begin
sRecCode:=PRecCodeInfo(cmbRecCode.Items.Objects[cmbRecCode.ItemIndex])^.sRecCode;
ovDoc.All.Item(i).Value:=Trim(sRecCode);
Inc(iInputCount);
end;
if (ovDoc.All.Item(i).tagName = 'INPUT')and //一定大写
(ovDoc.All.Item(i).type='text')and //大小写与原文一致
(ovdoc.All.Item(i).Name='user')then
begin
sSendCode:=PSendCodeInfo(cmbSendCode.Items.Objects[cmbSendCode.ItemIndex])^.sSendCode;
ovDoc.All.Item(i).Value:=Trim(sSendCode);
Inc(iInputCount);
end;
if (ovDoc.All.Item(i).tagName = 'INPUT')and //一定大写
(ovDoc.All.Item(i).type='password')and //大小写与原文一致
(ovDoc.All.Item(i).Name='passwd')then
begin
sPassword:=PSendCodeInfo(cmbSendCode.Items.Objects[cmbSendCode.ItemIndex])^.sPassword;
ovDoc.All.Item(i).Value:=Trim(sPassword);
Inc(iInputCount);
end;
if (ovDoc.All.Item(i).tagName = 'INPUT')and //一定大写
(ovDoc.All.Item(i).type='submit')and //大小写与原文一致
(ovDoc.All.Item(i).value=' 发送 ')then
begin
if iInputCount=4 then
ovDoc.All.Item(i).Click;
Inc(iInputCount);
end;
end;
end;
1:
begin
ovDoc:=(Sender as TWebBrowser).Document;
Inc(iSendSMS);
if(Pos('发送成功',ovDoc.All.item.innerhtml)<>0) then
sbSendSMS.Panels.Items[0].Text:='发送成功'
else
sbSendSMS.Panels.Items[0].Text:='发送失败';
end;
end;
end;