I've got to access text inside a flash object. The preferred method is via C#, but anything that works will do. The only requirement is that I'll need the resulting information to be transferred back to c# code.
Let's take, for example, this page.
With fireflashbug, you can easily access individual elements inside flash object and read/change html texts inside each of them.
To work, it requires Flash Debugger.
How can I do the same from my own code?
You can use AS3 ExternalInterface with or without JS. Check this thread too:
C# and Flash communication
To communicate with a flash object you use Javascript.
Here are some tutorial and examples:
http://www.adobe.com/devnet/flash/articles/external_interface.html
http://csl.sublevel3.org/howto/javascript_flash_callbacks/
http://www.permadi.com/tutorial/flashjscommand/
Now, once you have your data using javascript you can pass them to an input element and pass it to code behind if you wish for.
and many more on google
Related
I'm in the very early stages of attempting to automate data entry and collection from a website. I have a 16,000 line CSV file. For each line, I'd like to enter data from that line into a textarea on a webpage. The webpage can then perform some calculations with that data and spit out an answer that I'd collect. Specifically, on the webpage http://www.mirbase.org/search.shtml, I'd like to enter a sequence in the sequence text box at the bottom, press the "Search miRNAs" button and then collect results on the next page.
My plan as of right now is to use a C# WebBrowser. My understanding is that I can access the individual elements in the HtmlDocument either by id, name or coordinate. The last option is not ideal, because if I distribute this program to other people I can't be sure they'd be using at the same coordinates. As for the other 2 options, the textarea has a name, but it's the same as the form name, so I don't know how to access it. The button I'd like to click has neither a name nor an id.
Does anyone have any ideas as to how to access the elements I need? I am by no means set on this method, so if there's an easier/better way I'm certainly open to suggestions.
The WebBrowser class is not designed for this, hence why you are coming up with your problems.
You need to look into a tool that is designed for web automation.
Since you are using C#, Selenium has a wonderful set of C# bindings, and it can solve your problems because you'll be to use different locators (locating an element by a CSS selector or XPath specifically).
http://docs.seleniumhq.org/
Check mshtml - Mshtml on msdn
You can use it with the WebBrowser object.
Add Microsoft.mshtml reference to your project and the using mshtml declaration in your class.
Using mshtml you can easily set and get elements properties.
i was just playing around with javascript/jquery within mvc 3 and was just curious as to whether there was a way to pass in a C# variable to javascript and then modify from within the script. Though playing around with it, i noticed that it was not possible, as the variable passed in was just the value, and not the address.
Essentially, what i wanted to do was change a bool value from false to true when a html button is clicked. I figured i could do it through javascript but ran into the aforementioned problem. Is there anyway of doing this? Better yet, i'm sure there is a way, but is my design pattern flawed?
This is how ASP.Net/MVC is setup... No you can't modify server side C# variables in JavaScript. JavaScript is run in browser while C# page's code run on server. All C# classes are created and destroyed for each request and JavaScript code does runs at the different time (again destroyed after each page navigation via GET/POST).
There are multiple ways to pass data to/from JavaScript and easiest is render on GET and do submit (POST) to return changed fields to server.
I am trying to make an application that will fill in the info i type into the actual web page so I can register at websites very very easy whenever I need them. However I'm not sure how I would go about this. I know I would either have to use a WebBrowser or an Html request, but I am not sure what the basic syntax for it is. I could really use the help!
EDIT: I am trying to use Document.GetElementByID in order to do this. I don't want to use plugins to do this. I want to go a program.
Look into Browser Helper Objects and how to implement them in .NET. BHO-s can interact with the page loaded into an IE browser.
I have a new design requirement that uses the facebook fan box unorthodoxically. Instead of 'hacking' the fan box, I'd rather scrape the fan box iframe (hidden) and retrieve the contents of the grid-item class in the .fan_box class (i.e. .fan_box .connections_grid .grid_item). I basically need the URLs to the face images and their links.
I'd prefer .NET methodology or JS/Jquery and something to get me started and pointed in the right direction. Please don't just provide a basic method to pull in a webpage to scrape, that's not the point. It's the iframe and accessing the data within it, is the challenge here.
I've not seen anyone try this and have searched thoroughly. I am not a expert so please give me more direction than you would give a brain-dead monkey. Thanks.
Why not just access the page's /feed connection via the API and display it in your own style?
Start here: https://developers.facebook.com/docs/reference/api/page/ (bear in mind you'll need an access token to access the feed)
A sample of the return type is here:
https://developers.facebook.com/tools/explorer/?method=GET&path=19292868552%2Ffeed
I would like to use a java applet which is on an html file as ..
This java applet contains a textbox, and i want to access it as whenever I click a button in my c# app a certain txt appears there...
I have already embedded it with the use of webBrowser..
Any sample code, or suggestion?!..
Note: development under visual studio 2008 and I have the java applet source code..
The WebBrowser control isn't going to give you direct access to methods on a Java applet, AFAIK (you might be able to fudge your way through because I can't imagine that there isn't ActiveX involved, but I don't think that's the best answer).
Rather, what I would do is have a function in JavaScript that accesses the value of the textbox from the applet (assuming that the control in the applet exposes it publicly). It would assign the value to a property on the extern object exposed by the window object in JavaScript.
Then, you would create your own class which you would assign to the ObjectForScripting property on the WebBrowser control which exposes that property.
Finally, when you click your button, you would call the script (you can assign the function to your same object, if you want) which will assign the value, then get the value from the instance that you set to the ObjectForScripting property on the WebBrowser control.
There are other ways you can do this as well, you could have the JavaScript method write the text to a hidden element, then browse the DOM model to get the value, etc. etc.
In the end, whatever solution you have will more than likely involve a combination of DOM traversal and setting the ObjectForScripting property, as well as JavaScript in the HTML hosting the applet.
Another approach you can take is to create a UserControl or WebPart, which writes the HTML you need in the Render method. Here is a good link on the Render method (http://msdn.microsoft.com/en-us/library/system.web.ui.control.render.aspx).
We took this approach at one project I was on, where the <object> and <param> tags were created using custom configuration (Web.config and configuration sections) to render the proper HTML for a 3rd-party Applet.