1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Timer1Timer(Sender: TObject);
var
hWindow: HWND; { 窗体句柄}
FWindow:HWND;
lpszWindowText:Array[0..254] of char;
begin
//弹窗的窗口标题是客户信息
hWindow := FindWindow(nil,'客户信息');
if hWindow <> 0 then
begin
if IsWindowVisible(hWindow) = True then
begin
ListBox1.Clear; //窗口显示出来清除列表框中的电话号码
GetListBoxText(FindWindowEx(hWindow,0,'ListBox',nil),Listbox1.Items);//获得弹窗中的号码
if Trim(Edit1.Text) <> Trim(ListBox1.Items.Strings[0]) then//判断来电是不是与上次一致,由于用的是TIMER所有加了一个判断,电话号码一致就不写入数据库
begin
Edit1.Text := Trim(ListBox1.Items.Strings[0]);
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text := 'Insert into Inphone(Intel,Intime,Indate) values('''+Trim(Edit1.Text)+''','+
''''+FormatdateTime('c',now)+''','''+FormatdateTime('ddddd',now)+''')';
ADOQuery1.ExecSQL;
end;
end;
end;
end;
end;