Scripts Interacting With Browser Elements

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Scripts Interacting With Browser Elements

Post by Nonsanity » Tue Apr 01, 2008 10:47 pm

I'd like to do some automation work using Revolution's browser, but it looks like the click command falls through the browser to the stack objects behind it, and fails to click the link or scripted object at that location on the page.

Is there some way to simulate the user actually clicking in the browser through Revolution scripts?

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Fri Apr 04, 2008 4:40 pm

What platform are you using?

On windows, I believe the 'browserClick' message will report what was clicked on when the user clicks on an element in a browser window.

On macs, it doesn't. I've dealt with this by intercepting the browserBeforeNavigate message which gives you the url of the link that's been clicked, then issuing a revBrowserStop command to cancel the navigation, and done what I needed with the url.

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Fri Apr 04, 2008 5:56 pm

Yes, I noticed that platform discrepancy in the docs, but that wouldn't have helped me anyway, since it's the reverse of what I need.

What I want the stack to do is open a particular page, and automatically click something on it, without the user having to do anything. If it was just a link I could scrape the URL from the page source and just point the browser to it, but that won't help if the clickable spot on the page executes local javascript code instead.

Beyond automation, this ability to force clicks and keypresses into the browser would allow for tutorials that can guide a user through a complex web interface and help them with oft-repeated tasks.

I'm beginning to think that there is no support for this in Revolution at this time. :(

And I primarily use OS X, but this project is for both Macs and Windows.

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Fri Apr 04, 2008 9:18 pm

I see what you mean. No, I don't think you can do this.

Probably no help, but I have managed (once) to get rev to execute an applescript to execute javascript in a Safari window, but it's obviously not cross platform...

M

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Fri Apr 04, 2008 9:54 pm

Hmmm... I wonder if anyone's ever made a plugin that can click on any other program. I've not gotten into Revolution add-ons yet, but this wouldn't have been too hard to put into an XCMD back in the Hypercard days of yore.
~ Nonsanity
~ Chris Innanen

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Sat Apr 05, 2008 11:42 am

If you were able to write XCMD for HC, you can probably do it for Rev - there's some documentation and demos available on the RunRev site - Mark Waddingham wrote a series of articles in the newsletter about it.

If you're on Macintosh only, you might look into the whole applescript/automator stuff.

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed Apr 09, 2008 10:15 pm

Pew... Back then XCMDs were written in Pascal. Talk about old school!

For now I'm just shelving the project, and/or moving it to some other platform. Maybe someday it will be able to drive simulated clicks into the browser objects, at which point I'll try again.
~ Nonsanity
~ Chris Innanen

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Apr 10, 2008 9:25 am

Hi Nonsanity,

Simulating clicks is a bad idea anyway. As soon as the website changes, or the way of rendering by the web kit changes, your programme would stop working. If a user has different default fonts set or doesn't have installed necessary fonts, the website would display but your scripts won't work.

A better way would be to get the htmlText from the browser object and change this as if it had been clicked on. If necessary, Rev can contact the server, posting a form.

What exactly did you want that click in the browser object to do? If "something" (in your earlier post) is a click on a link, you can simply load the page the link links to. If you want the user to be able to see what you are doing, you can set the screenMouseLoc to move the mouse around, but this will probably be a big hassle, because of different ways of rendering.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed May 07, 2008 8:54 pm

Many web pages these days are interactive within themselves using javascript, for example. So clicking on something doesn't necessarily submit a form or open a link. For those cases, yes, I can parse the HTML and spoof a click. But in a javascript-driven calculator page - for an over-simplified example - clicking on buttons makes changes to the contents of the page. That's not something that can be spoofed.

In my case, the environment is tightly controlled, and the page in question is loaded with javascript actions. Differences in page rendering is moot, therefore, and spoofing isn't possible. Hence the desire to just do like the user does and click on stuff. :)
~ Nonsanity
~ Chris Innanen

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed May 07, 2008 9:06 pm

Hi Chris,

If the page is not yours, the owner of the website may not want you to automate "user" interaction, but if this isn't a problem to the owner of the website, why don't you see if you can work something out together?

If it is your own website, it should be relatively easy to make this work.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Post by alex298 » Fri May 09, 2008 3:36 am

Hi Mark,
If it is your own website, it should be relatively easy to make this work.
I am quite interested. Could you please provide some guidlines?

Thanks and best regards
Alex
Nice to meet all of you.

marco.deepak
Posts: 11
Joined: Fri Oct 02, 2020 10:24 am

Re: Scripts Interacting With Browser Elements

Post by marco.deepak » Fri Oct 02, 2020 10:26 am

Hi all,

Has the situation above been improved since 2008?.

Is it now possible to interact with browser elements in newer LC releases?.
Things like clicking on a browser element, or clicking on the element and writing something, drag and drop, ecc.

Thanks

M.

Post Reply

Return to “Internet”