写一个.vbs文件: Set oIE = GetObject("", "InternetExplorer.Application") oIE.Visible = True Set oShell = GetObject("", "WScript.Shell") oShell.AppActivate "Internet Explorer" oShell.SendKeys "%d" WSH.Sleep 100 oShell.SendKeys "http://www.sina.com.cn"Set oShell = Nothing Set oIE = Nothing
这个是我说的效果,很佩服,但是我想是在delphi中实现,能有会的吗?
uses ComObj;procedure TForm1.Button1Click(Sender: TObject); var V: Variant; begin V := CreateOleObject('InternetExplorer.Application'); V.Visible := True; V := Unassigned; V := CreateOleObject('WScript.Shell'); V.AppActivate('Internet Explorer'); V.SendKeys('%d'); Sleep(100); V.SendKeys('http://www.sina.com.cn'); V := Unassigned; end;
procedure OpenInIE(aURL: string);
var IE: Variant;
begin
IE := CreateOleObject('InternetExplorer.Application');
IE.Visible := true;
IE.Navigate(aURL);
end;
aURL 是网址,记得uses里一定加上ShellAPI,ComObj
ShellExecute(0, 'open', 'www.xxoo.com', nil, nil, sw_shownormal);
指定浏览器:
ShellExecute(0, 'open', 'iexplore.exe','www.xxoo.com', nil, sw_shownormal);
1、打开ie浏览器
2、浏览器地址栏,自动输入http://www.sina.com.cn
而不是直接“用ie打开某网址”。那样是简单了不老少,我会。
Set oIE = GetObject("", "InternetExplorer.Application")
oIE.Visible = True
Set oShell = GetObject("", "WScript.Shell")
oShell.AppActivate "Internet Explorer"
oShell.SendKeys "%d"
WSH.Sleep 100
oShell.SendKeys "http://www.sina.com.cn"Set oShell = Nothing
Set oIE = Nothing
这个是我说的效果,很佩服,但是我想是在delphi中实现,能有会的吗?
uses ComObj;procedure TForm1.Button1Click(Sender: TObject);
var
V: Variant;
begin
V := CreateOleObject('InternetExplorer.Application');
V.Visible := True;
V := Unassigned;
V := CreateOleObject('WScript.Shell');
V.AppActivate('Internet Explorer');
V.SendKeys('%d');
Sleep(100);
V.SendKeys('http://www.sina.com.cn');
V := Unassigned;
end;