Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question concerning FAQ 184-4463 2

Status
Not open for further replies.

kbklaus

Technical User
Mar 30, 2007
9
DE
Would it be possible to modify this nice program from Ramani in that way, that instead of Internet-Explorer the better browser FIREFOX can be used?

Firefox is much faster than IE!

In other words:
Can the code-snippet

cSite = ' .AddProperty("oBrowser", ;
CREATEOBJECT("internetexplorer.application"))
.oBrowser.Navigate(cSite)
.oBrowser.Visible = .T.
ENDWITH
ENDPROC

changed into
.AddProperty("oBrowser", ;
createobject("firefox.application"))
.oBrowser.Navigate(cSite)
.oBrowser.Visible = .T.

I tried it, but got an error.
 
Been A Long time since I used this routine,
You'll have to blow the dust off it and see if it still works.

*/***************************************************************************
*#Run any Executable program from inside fox
*/Program : RunExe
*/System : Project Bidding System
*/Purpose : Start a Windows Exe File without the run command
*/Syntax : Success = runExe(ExeName , [Parameter] , [WindowStatus])
*/Returns : Sucess - logical
*/Parameter : ExeName - String - Drive:\Directory\Filename of program to start
*/ : Parameter - String - ExeFile Parameters
*/ : WindowStatus - integer - Type of window to open
*/Defaults : ExeName - Manditory
*/ : Parameter - Optional
*/Requires : Windows 95/98/NT/2000
*/Changes :
*/Calls :
*/Version : 1.0
*/Dated : 08/31/2000
*/Written By: David W. Grewe
*/************************************************************
*&Program Control
*/************************************************************
lparameters pcExeName, pcParameters, pnWindowStat
* first parameter required, others - optional

if Parameters() < 1.5 .or. type("pcParameters") != "C" .or. empty(pcParameters)
pcParameters = ""
endif
if Parameters() < 2.5 .or. type("pnWindowStat") != "N" .or. empty(pnWindowStat)
pnWindowStat = 1 && see Win32Api function ShowWindow for values of pnWindowStat
endif
local lcRunString
m.lcRunString = '"'+ allt(m.pcExeName) + '"' + iif(parameters() > 1 , + " " + m.pcParameters , "")
declare integer WinExec in kernel32 string lpCmdLine, integer uCmdShow
return WinExec(m.lcRunString, m.pnWindowStat) > 31


David W. Grewe (Dave)
 
Firefox isn't a com server so you cannot automate it.

Best you can do is shell execute it and pass the URL as a parameter...

Brian

Code:
DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, STRING cAction, STRING cFileName, ; 
  STRING cParams, STRING cDir, INTEGER nShowWin

cSite = "[URL unfurl="true"]http://www.opendirviewer.com/?pagecount=21&url=random"[/URL]
 
ShellExecute(0, "open", "C:\Program Files\Mozilla Firefox\firefox.exe", cSite, 1)
 
Sorry, missed a parameter. Try:

ShellExecute(0, "open", "C:\Program Files\Mozilla Firefox\firefox.exe", cSite, "", 1)
 
*WARNING* The sample URL provided isn't family/work friendly!

Brian
 
With ShellExecute it will use the default browser on the user's PC. If it's IE, it would use IE. I'm not sure how to specify explicitly which browser to use for the site.

BTW, there is a question concerning FAQ of saving mht file. It doesn't seem to work 100% reliably for me. See
for discussion.
 
Hi ilyad,

Do you mean tek-tips faq1251-5510?

I wouldn't work with sending keys. The hotkeys for the menu could change with every version, although it's quasi stable. And like Naomi said it's not reliable.

I'd go with Juri Shutenko's solution in the UT thread:
Code:
Clear
Local loIE As InternetExplorer.Application
loIE=Createobject('InternetExplorer.Application')
loIE.Navigate('[URL unfurl="true"]http://news.google.com/nwshp?hl=en&tab=wn&q=')[/URL]
Do While loIE.ReadyState !=4
   DoEvents
Enddo
loDocument=loIE.Document
loContent=loDocument.DocumentElement
lcContent=loContent.outerHtml
=Strtofile(lcContent,'d:\test_for_ut.htm',0)
Release loIE

Just don't write to C:\ directly, as in Juris original version. As a normal user you normally have no right to do that.

And if you want to save in that web archive format you can choose from IE MEnu File->Save As, besides the problem of where the keys are sent (in my case the VFP command window) the hotkeys for saving depend on the localized version of IE, in german you would need %D to activete the File menu, which is named "Datei" in the german version and u to select the menu item "Speichern unter" equal to "Save AS". But changing the Sendkeys does not work for me.

Thomas Ganss gave me a hint on QueryInterface from the Document Object and it's method IPersistStreamInit and Save, haven't tried yet.

Bye, Olaf.
 
Well, I found another solution concerning MHTML:

Code:
loMsg = CreateObject("CDO.Message")
loMsg.CreateMHTMLBody('[URL unfurl="true"]http://news.google.com/nwshp?hl=en&tab=wn&q=',0,'','')[/URL]
loStream = loMsg.GetStream()
loStream.SaveToFile("d:\test3.mhtml")

Bye, Olaf.
 
Thank you, Olaf. I saw your suggestions here and in UT and replied in both places <g> Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top