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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE Automation in VFP may work with an extra parameter

Status
Not open for further replies.

JackTheC

Programmer
Feb 25, 2002
325
NL
Last year I had a question on automation of IE9 (and up) within VFP.

Code:
ieo=createobject("InternetExplorer.Application")
ieo.navigate("[URL unfurl="true"]https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=http%3A%2F%2Fwww.ebay.com%2F")[/URL]
ieo.visible=.t.

do while ieo.readystate<>4
     =inkey(0.1)
enddo

ieo.document.getElementbyId("pass").focus()
ieo.document.getElementbyId("pass").select()

(Ebay.com (and "pass") is just an example so you can test it)

The focus(),select() and submit() commands did not work anymore in IE9 and higher whereas it did in IE8 or in a VBS script. My solution was to do this automation therfore in a VBS script called from within VFP.

Today I was just playing around with this stuff, and suddenly it worked when I put an extra parameter in the focus(), select() or submit() commands in my VFP program. Like select(1) or select(.t.) or even select("hello").
Code:
...
ieo.document.getElementbyId("pass").focus(1)
ieo.document.getElementbyId("pass").select(1)

So I don't need the VBS script anymore.
I have no idea whether the parameter has any meaning because either way, numeric, string, date or boolean/logical works.
And IE8 en VBS script also work perfectly with an extra parameter.

I put my findings here for if someone in the future comes across the same problem.
 
Thank you

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
It works. It's a bit of a bummer there is no explanation, why it works. I see no parameters of focus() or select() documented for the input html element nor specifically for Internet Explorer.

Besides that, it's a matter of trust, if somebody would enter their password here while you are automating the browser and could read the password someone enters.
There is an API for getting a token enabling you to do something on behalf of an ebay user. There most often is an api for any larger sites.

Bye, Olaf.

 
Tested in VBS, VB6, VB.net, VFP6 and VFP9

Only VFP requires a parameter of any kind and of any value to perform commands like: focus(1), select(1), submit(1), click(1) etcetera in automation of IE for any website. But it may work without a parameter in older IE versions prior to IE9.
 
Well, OLE technology means you have references to a foreign process and everything you do on the level of an OLE object reference or below it (in sub objects and properties) is forwarded (marshalled) to the foreign process and executed there. If you'd pass in a parameter into a foxpro function without any parameters defined via (L)PARAMETERS, you'd get an error. Not any language is hard about that, if you call a batch cmd file with parameters and %1 is never used, it simply is never used, which may explain why it doesn't error, but not why it works. We can accept it of course and make use of it.

Bye, Olaf.

 
I discovered the need for passing a parameter to events which earlier didn't need one, after IE was updated a year or two ago. It drove me nuts, but I very soon discovered that changing for instance lo.myobject.click() into lo.myobject.click(.T.) worked all the time. Since this also was true for older browser, meaning that they simply ignored this dummy parameter, I added .T. in all my programs. I also wrote about this change a few times, in other VFP forums. I'm glad you also solved your problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top