Pieces
Pieces

Reputation: 2295

Programmatically make clicks on a webpage

There is a onmousedown event on a webpage. I want to be able to have this event called from my app and have the WebBrowser object move to that page. How can I achieve this?

Upvotes: 0

Views: 190

Answers (3)

NinjaCat
NinjaCat

Reputation: 10194

gnucom's right.

Perhaps not the solution you are looking for: http://watir.com/examples/
It's Ruby based and but you could have your app interact with that perhaps...

Upvotes: 0

Dan Tao
Dan Tao

Reputation: 128317

The WebBrowser.Document property gives you an HtmlDocument object, which has an InvokeScript method. I have used this before to execute JavaScript from a WebBrowser control. Frankly, it's an atrociously messy way to get something done, but it has worked for me. Could that be of use to you, maybe?

Upvotes: 0

sholsapp
sholsapp

Reputation: 16070

Long story short, you can't do this. This is because the javascript is a client side technology and to accomplish what javascript does on your client you're going to have to pretend to be a client: you'll need to rebuild the entire document object model and execute the javascript that way.

You can reference this ticket where I tried solving a similar issue (calling javascript from within a PHP script): Can a php proxy script call javascript functions like click?

Maybe if you explain the problem domain a little more, you'll discover that you don't even need the javascript all-together! What are you trying to accomplish and why is the javascript required? Good luck!

Upvotes: 2

Related Questions