I'm being slowly driven mad at work having to manually gather data contained within an ActiveX object running in Internet Explorer 8. It's essentially a ticket system containing some key customer details etc. which I must copy and paste a lot more than is healthy.
Where would I start looking for a solution that will allow me to grab the data I want and navigate the ActiveX system programmatically?
Ideally I'd be thinking of writing something in Java or C# but I'm open to any suggestions!
Unless the ActiveX you are interested in exposes information through public interface (in which case you can injected JavaScript on page to read data) you'll have to use some form of screen scraping. If the control has regular input controls it should not be too hard, but if everything rendered directly you may need OCR the images...
Injecting script:
use WebBrowser control and "eval" your script on the page - some communication sample is here http://msdn.microsoft.com/en-us/library/a0746166%28v=VS.85%29.aspx, eventually you'll need InvokeScript - http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.invokescript%28v=VS.85%29.aspx
use normal IE automation http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx.
for one-time use "javascript:" in address bar or just developer tools (F12).
utilize XSS vulnerabilities of the site (half kidding, don't forget to fix whatever you find afterwards if you own the site, as for reporting errors to third party consult your conscience)
Related
I want to be able to use the .NET WebBrowserControl to record and repeat user actions to automate the collection and retrieval of text from web pages for a data extraction tool that I'm building, but am unsure about how to best approach this.
I specifically want to use the .NET WebBrowserControl as it can be embedded in a .NET form and also used within a server side process without a UI. I'm aware that there are other means of recording and repeating user actions such as Selenium, but for now I am interested in a solution around the web browser control (just to keep answers focused).
Actions to be recorded are those such as button clicks, drop down list selection, link clicks etc.
Potential solutions I have looked at so far:
(Please correct me if my notes based on brief evaluations are wrong)
iMacro (doesn't appear to have a component that can be used within a project, to record user actions, rather the GUI has to be used).
WaitN - Good for programmatic play back - but no recording facility that can be hooked up to the web browser control?
I'm presuming this is possible as services like Mozenda appear to make use of the WebBrowserControl, or some IE like version based on mshtml.dll.
Are there any other options I can look at?
Any insight would be appreciated.
yap, as in Mozenda ,when user create any action like goto mainpage>click on images>download image etc... the XPath is recorded with the each page url into XML file. So, use self learning algorithm to implement such kind of XML better way than mozenda.
i have developed one application using JSOUP and Regular Expression Parsing works same as mozenda do. i created the configuration file which contains the XPath of all the items you want . Which works great for me.
Hope this helps,
I'm building a C# desktop app with a simple UI. Due to my familiarity with HTML/CSS, and a previous web-based iteration of a very similar app, it would be ideal if I could re-use some existing HTML/CSS pages I have as the UI for this new desktop app.
Is that do-able with C#? Can anyone show a simple example of using an HTML/CSS page as the UI of a C# desktop application?
Other answers are dated, new good options:
Electron + Electron-Edge - is the way to go for a new Electron app that communicates to a .NET backend (a DLL). Widely used and supported.
Neutronium - best for already-written .NET WPF apps that need a HTML UI. Requires using Vue. Less popular and less supported.
CefSharp (https://github.com/cefsharp/CefSharp) is a good way to embed chromium, but you still need a web server. Take a look at http://www.ultidev.com/products/Cassini/ to alternative for IIS.
You can use WebBrowser control to add Web browser functionality to your application.
You can create your own html(s) and set your WebBrowser control to display those pages. You can navigate by clicking hyperlinks or by using keyboard shortcuts to move backward and forward through navigation history. By default, you can access additional browser functionality through the right-click shortcut menu
You can even manage those pages centrally (for e.g. on LAN) and all clients on LAN can connect to this central location. This way you can modify pages centrally.
Check a walkthrough on MSDN:
How to: Add Web Browser Capabilities to a Windows Forms Application
You can try to use a Chromium-based control - DotNetBrowser. This control provides wide interactivity options, like DOM manipulation and DOM events, which can be useful in your case.
In addition, there is an article that demonstrates how to use a web page as HTML UI in a C# desktop application: https://www.infoq.com/articles/html-desktop-net
Affiliation disclosure: I work with the team, which created DotNetBrowser.
You could try adding a Web Browser control to a forms application to show your page. But this will need to be remotely hosted as the code will not be able to execute locally, except if you listen for the specific links in c# and then perform the actions.
You could also try your hand at WPF which is a new technology to create good looking gui's with mark-up much like html, which you'll pick up pretty quickly with your html experience.
Unfortunately neither WinForms or WPF is sufficiently like HTML/CSS to be of that kind of use. You'll be able to reuse the layout-concepts and art of course. And, with WPF being the closest thing to it, you might even keep a lot of the code-behind code.
But the short answer is: No
Is it possible to build a silverlight desktop web browser?
(just for fun, to see if it works etc) :)
I don't see why not.
With Silverlight 4 you can build a full trust application utilising a Web Browser Control (Source).
There's more details on the WebBrowser Class on the MSDN.
Hosts HTML content within the Silverlight plug-in.
Yes you can. Using WebBrowser control is not fun and defeats the purpose of writing a browser. Basically you would have to load raw html and parse it into DOM-like data structure. Next you'd have to use Silverlight visual elements and layouts to render html page as close as possible to the way real browsers do it.
You're likely to run into Silverlight limitations in process and creating browser compatible with CSS3 would require huge amount of work, so while in theory it should be possible I'd just stick to that knowledge and not try to actually do it.
I want to create with Asp.net a browser inside a web page, so that I can process the click events of the user (for statistics analysis).
I kwnow how to do it with Winforms but I need a full online solution, so that:
The user open an standard browser and types in a start url.
In this url the menus and bars of the standard browser are hidden and
the user can see a "simulated browser", with standard buttons
(back, reload, ...).
From the Asp (c#) code behind this page I can start collecting click
data.
Thanks in advance, and keep the good work.
What you want to collect (a heat map of clicks essentially) is doable, but I don't think the way you want to go about it is very feasible.
Try this out.
I think that using this kind of solution with frames, etc. is much more feasible than embedding a browser (this amounts to writing a browser that can be served up by some kind of java/silverlight technology, not trivial).
Another idea would be that since, I assume, you have the permission of your users to track their clicks, write a greasemonkey (firefox plugin) based on the javascript in the link I provided above. You could then have all users use this plugin script combination to give you their clicks.
Web browsers are normally designed to prevent this kind of cross-site scripting vulnerability. This would only be feasible if you had the complete cooperation of all sites involved.
I don't think browsers will allow you to do this, for the simple reason that it opens up a whole bunch of security holes. If you think about it, an attack site designed like this would be able to follow people around the net tracking their actions, stealing passwords, etc. without them even knowing it was there.
This is not so simple for a web app.
Your options are:
Create a plugin (or Greasemonkey script) for your favorite browser to collect click data.
JavaScript that tracks the user's cursor position. Keep in mind that this won't be reliable if your users go to other sites from within your site thanks to the fact that JavaScript doesn't work well if scripts come from different origins.
You won't be able to make a "browser" control like you can on a desktop app because browsers intentionally don't allow web sites to be that powerful.
For the "browser in a browser" effect, you can use the tag. Remember, you'll only be able to track user actions in this iframe if the source is from the the same domain as the page it's included on.
Cross domain scripting is impossible by client-side. For obvios security reasons, you can't even read from a frame or iframe pointing to somewhere not from your own site.
Maybe the solution here is to to build something similar to the famous PHPProxy, or PHPBrowser, in this case a "ASP.NET Proxy". Its not that hard to build, you can Google for many exemples of those little codes.
While I doubt you can hide the original browsers toolbars etc, you could set up a single page that does this (it certainly wouldn't handle everything though).
This page would contain a the buttons and textbox required (to make up the inner browser UI) and a placeholder that would contain the page that the user requested. Of course the page contained in the placeholder will need to have all the links replaced so that they can be tracked (I would use linkbuttons). I'm not sure how well form submits would work.
Personally I'd use a proxy if I had control of the computer.
What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.
It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
While I haven't used a flash object inside a windows form application myself, I do know that it's possible.
In Visual studio on your toolbox, choose to add a new component.
Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object"
Once added to the toolbox, simply use the control as you would use any other "standard" control from visual studio.
three simple commands are available to interact with the control:
AxShockwaveFlash1.Stop()
AxShockwaveFlash1.Movie = FilePath &
"\FileName.swf"
AxShockwaveFlash1.Play()
which, I think, are all self explanatory.
It would be great to be able to load
the flash content from a stream of
sorts rather than a file on disk.
I just saw you are also looking for a means to load the content from a stream,
and because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).
the first is the one I would advise you to use only when necessary, as it uses the full blown "webbrowser component" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka.
of course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.
the second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).
Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!
Shooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)
There was a link on Adobe's site that talked about "Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications" but they seem to have removed it :(