Skybound Software is looking to hire experienced C# developers to work on Stylizer and other forthcoming Skybound products. Click here for details.
GeckoFX is an open-source component which makes it easy to embed Mozilla Gecko (Firefox) into any .NET Windows Forms application. Written in clean, fully commented C#, GeckoFX is the perfect replacement for the default Internet Explorer-based WebBrowser control. Download GeckoFX @ Google Code >
GeckoFX is made by Skybound Software, authors of Stylizer—the professional CSS editor with a strong focus on visual control, error-free workflow, and productivity. Learn About Stylizer >
Discuss GeckoFX, the Open-Source Gecko Control for .NET
You are not logged in.
Pages: 1
The key is in this post:
http://geckofx.org/viewtopic.php?id=578
You have to add the contents of the rar commented to the source code of GeckoFX.
From that moment on you can start using the DOMSelector to get objects of various types that will allow you to do things like clicks.
Offline
Why not using the navigate function?
If it has javascript you might be also able to emulate it.
Offline
Yes this is the variant, but in this case we have too much cases:
1) yes it can be javascript (not a problem)
2) but this can also be a link in a frame, and i should navigate the exact frame to the href of link, how can i do it? Is there any way to navigate the exact frame (not the whole browser)?
Offline
Use for example:
browser.Navigate("javascript:void( window.frames[2].document.getElementById( 'buttonID' ).click() ) ");Offline
This is because of the security risks of allowing Cross Site Scripting
Offline
Hi everyone,
I've been struggling and making research about this for a while now.
I want to simulate a link click in Firefox using Javascript. Directly navigating to the address is not enough in my case.
I try a specific code in a Javascript console and it works, but when I use the same code with GeckoFX the link is not clicked.
I looked at the mentioned post about the DOMSelector (DOM.rar in http://geckofx.org/viewtopic.php?id=578) but I don't know how to use it.
I guess I need to get Gecko FX Source, add those files in some place and rebuild it?
Here goes the code I'm trying on a Visual Studio 2008 C# Windows Form:
string js = @"javascript:
l = document.getElementById('link');
alert('link = ' + l);
function fireEvent(obj,evt){
alert('fireEvent');
var fireOnThis = obj;
if( document.createEvent ) {
alert('createEvent');
var evObj = document.createEvent('MouseEvents');
evObj.initEvent( evt, true, false );
fireOnThis.dispatchEvent(evObj);
} else if( document.createEventObject ) {
fireOnThis.fireEvent('on'+evt);
}
}
fireEvent(l, 'click');
";
geckoWebBrowser1.Navigate(js);The link element is obtained correctly but the alert('fireEvent') never gets triggered.
Is my approach correct or should I try other way?
Does Firefox somehow prevents clicking a link programatically?
Any help on this would be appreciated.
Thanks in advance.
Regards,
Fede
Offline
Anyone managed to do that ?
I am making scraper and for now it is navigating to javascript:blabla links but for some site that is not working (no href attributes in links at all)
AFAIK we can get XY cordinates of every node on the page, anyone know how to send winapi click to that location ?
Offline
hex wrote:
Anyone managed to do that ?
I am making scraper and for now it is navigating to javascript:blabla links but for some site that is not working (no href attributes in links at all)
AFAIK we can get XY cordinates of every node on the page, anyone know how to send winapi click to that location ?
Note:
Since links in a web page are not *controls* (in that they do not have a handle) you can't use SendMessage with WM_MOUSEDOWN/WM_MOUSEUP to them. As far as the X, Y values are concerned.. are you sure you can get the correct values? If not I have some VB.Net code laying around somewhere that can get the correct location - using GeckoFx - if you need it.
But, as far as sending a windows message.. you're kinda out of luck with that as the whole page would be considered as a single control - the GeckoFx control that is. The WinApi has no discerning api's that you can use for this purpose. (you' can trust me on this as I've taken the time to disassemble damn near every assembly in the Windows installation for the project I'm working on now ;) )
I know this isn't a whole lotta help but, I hope this helps you out in one way or another.
Best Regards,
Softwerx
Last edited by softwerx (March 31, 2010 9:25 PM)
Offline
For cordinates I tought I saw someware properties that return XY relative to geckoWebBrowser control, now i can find only
GeckoElement.OffsetLeft
GeckoElement.OffsetTop
They as I see are relative to their DOM parent. If we sum all XY values of parents all the way up to BODY element we may get right result.
For sending WM_MOUSEDOWN off course we send it to geckoWebBrowser but we also send coordinates as parameters right ?
Offline
I goggled some code
http://pastebin.com/m41fdaab1
Don't know what is it doing (comments are in German) but it looks it is calculating element position just as I thought so I guess it works...
#
//findet absolute Position des Videocontainers
#
//indem er sich bis zum body element hochhangelt
#
//und von jedem �bergeordneten element top und left aufaddiert
#
int xParameter = 0;
#
int yParameter = 0;
#
#
GeckoElement node = objectCollection[i];
#
#
while (node.TagName != "BODY")
#
{
#
//MessageBox.Show(node.TagName);
#
xParameter += node.OffsetLeft;
#
yParameter += node.OffsetTop;
#
node = node.Parent; //ebene h�her gehen
#
}Offline
I'll pull up my vb code and post it tomorrow. It isn't the same as the German code you had posted but it is definitely accurate as I had used it in my old GeckoFx project to place a drop down under certain web controls.
Now that I think about it a bit more, you may be able to pull off the wm_mousedown/mouseup msg trick using the coordinates but, I haven't tested this myself. I'm not positive but, the DOM files that I had posted (originally by M1Labbe, I believe) may be useful in your endeavor. (You'll have to use the forum search to find them but, I'm sure I posted them as attachments to several of my posts). In any case, good luck on your project.
Best Regards,
Softwerx
EDIT: Unfortunately, I'm unable to find the project in which I have the code. If I run across it some time soon I'll be sure to post it for you.
Last edited by softwerx (April 01, 2010 9:41 PM)
Offline
I think I made it....
Sending message to GWB control doesn't work becouse there is mozilla window inside and click is not routed to it.
I used FindWindowEx to find handle of class MozillaContentWindowClass in GWB and then another FindWindowEx to find MozillaWindowClass inside MozillaContentWindowClass.
When I send WM_LBUTTONDOWN, WM_LBUTTONUP to that MozillaWindowClass it WORKS :)
I will post code later...
Offline
Is there a method to scroll gecko window exactly x pixels ?
I need a way to scroll so I can click on a element that is not visible..
Offline
Pages: 1