Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 03-29-2008, 07:39 AM   #1 (permalink)
Newbie
 
Scriptiz's Avatar
 
Join Date: Oct 2006
Location: Belgium
Posts: 34
Rep Power: 0 Scriptiz is a jewel in the roughScriptiz is a jewel in the roughScriptiz is a jewel in the rough
Send a message via MSN to Scriptiz
Default Control Firefox with C#

Hello,

I'm trying to "control" firefox via a C# program. Is it possible?

Actually I can just start the Process firefox.exe but then I don't know how to change the Url of this process, how to get the Url, get the html source code of the actually visited page in this firefox process, ...

Can you help me? Is it a way to do that? I hope


ps: I'm french so excuse my poor English.
ps2: I went for 5days so I'll read your answers in only 5days
Scriptiz is offline   Reply With Quote
Old 03-30-2008, 12:44 PM   #2 (permalink)
RunUO Forum Moderator
 
daat99's Avatar
 
Join Date: Dec 2004
Location: Israel
Age: 26
Posts: 8,163
Rep Power: 78 daat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond reputedaat99 has a reputation beyond repute
Send a message via ICQ to daat99 Send a message via AIM to daat99
Default

Quote:
Originally Posted by Scriptiz View Post
Hello,

I'm trying to "control" firefox via a C# program. Is it possible?

Actually I can just start the Process firefox.exe but then I don't know how to change the Url of this process, how to get the Url, get the html source code of the actually visited page in this firefox process, ...

Can you help me? Is it a way to do that? I hope


ps: I'm french so excuse my poor English.
ps2: I went for 5days so I'll read your answers in only 5days
1. To open Firefox in a specific URL you can just pass the url as a parameter to Firefox (run this in Start->Run: "firefox.exe http://www.runuo.com/forums/c/89428-control-firefox-c.html#post747059")

2. It's very likely that there is a lot better and easier way then this! but...
To get the source code you can "create" your own c# web explorer.
There should be a c# library that can "open" a url and "download" the source code so it can be displayed on the screen (look at ConnectUO or many other c# applications that integrate a small web browser into them).
__________________
I always try to help
Sometimes, I don't know how....

My Web Page
Forum Rules
-------------------------------------------------------------
Extensive OWLTR System | Token System | World Teleporters
-------------------------------------------------------------
daat99 is online now   Reply With Quote
Old 04-02-2008, 12:20 PM   #3 (permalink)
Newbie
 
Scriptiz's Avatar
 
Join Date: Oct 2006
Location: Belgium
Posts: 34
Rep Power: 0 Scriptiz is a jewel in the roughScriptiz is a jewel in the roughScriptiz is a jewel in the rough
Send a message via MSN to Scriptiz
Default

I knew those solutions, but the problem is that I ave to invoke a javascript in my page, and to find the parameters of this javascript function.

Actually with the webBrowser control available, I can navigate to the page I want, get the parameters of the javascript function by some functions wich analyse the html-code. But then when i change the Url of my webBrowser in : "javascript: the_function_searched("param1", "other_param");" the browser don't execute the javascript function.

In firefox, if I look manually in the code for this function, I can change the url in this way to invoke the javascript function. But in IE, or my webBrowser control wich is based on IE, the manually way doesn't work neither...

I find a way to solve this problem by the webBrowser wich got à Document instance wich permit to call the InvokeScript([script], [array of params]) but it doesn't work too...

Another way I think, is to user the firefox.exe to open new url, but then how can I get the source code of my page, because in this page, I'm identified by a cookie, session variables, and a get variable wich contain a hash code. Thus at each identification on the website by a different navigator, the hash is changed, and I can't get farther. So the only way is to stay in the same navigator, but my webBrowser don't permit me to invoke scripts... so I really have to find a way to totally control the "moves" of firefox or to invoke the javascripts functions in this webBrowser controle.

I'm searching for a solution many hours, an I got headaches now

Thanks for your help.
Scriptiz is offline   Reply With Quote
Old 04-02-2008, 01:17 PM   #4 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,590
Rep Power: 50 Jeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond reputeJeff has a reputation beyond repute
Default

Unless firefox's API is open(which i believe it is not) you cant really do this with C#, and if it is even remotely possible, i can guarentee its not a simple solution.
__________________
Jeff Boulanger
ConnectUO - Core Developer
jeff@runuo.com

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted scripting/coding competitions

Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 05-02-2008, 08:40 PM   #5 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hiding in your room.
Age: 21
Posts: 1,262
Rep Power: 54 arul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond reputearul has a reputation beyond repute
Send a message via MSN to arul
Default

Mozilla uses its own window class implementation, though I believe that classic get-handle-send-message approach should work.

In C# this of course requires P/Invoke of a few user32.dll functions.
__________________
arul is offline   Reply With Quote
Old 05-06-2008, 06:15 AM   #6 (permalink)
Newbie
 
Scriptiz's Avatar
 
Join Date: Oct 2006
Location: Belgium
Posts: 34
Rep Power: 0 Scriptiz is a jewel in the roughScriptiz is a jewel in the roughScriptiz is a jewel in the rough
Send a message via MSN to Scriptiz
Default

Thanks arul for this answer, but how do I do that?

Do you have a sample or a piece of code wich will be more easy to understand

Thanks a lot.
Scriptiz is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5