I've got a need to navigate java-applet programmatically and I am not that keen on Java platform. So lets assume I've got IE process stated with appropriate java applet loaded. Next I need to have some actions taken to this particular applet, like, lets say, sending WM_COMMAND to dialog along with BN_CLICKED code like I do with Windows in C. Assuming it's not a regular window I can refer to using HWND, I would like to ask someone for recommendations on how to do this.
As I understand you want to navigate (sending keystrokes and mouse clicks) a java-applet on the client side. It depends if you own the applet (say: you have the code and can change it) or if the applet is closed source and you just want to remote it.
In the first case use javascript to automate it. Change the containing HTML page to include some Javascript and pass parameters to the applet as described in the Java Tutorials.
If the applet accepts parameters, but you cannot change the HTML page, use a GreaseMonkey alternative for IE.
Your other approach (sending Windows Messages from an extern application to IE) should also work. Start Spy++ (use the 64bit version if you are using a 64bit Windows), choose "Search - Find window..." and drag the "Finder Tool" icon over the applet and release it. You will see then the HWND and if you press search you will see the window inside IE window hierarchy. So, yes you can send keystrokes and mouse clicks to a browser.
If I would automate the browser I would use Geb. You code a "web site test" in Groovy, just look at the Geb index page.
You could try to record a navigation through the applet with FireFox + "Selenium IDE" then export it and try run it in a Java Application with the Selenium IE WebDriver.
Information about Selenium can be found here : http://docs.seleniumhq.org/
Maybe this question will also help you : How to automate Java applet?
Related
I want to send a command to my browser, let's say chrome.
For example, I use a website which has a really neat audio player, i know this audioplayer has a javascript function called prevTrack() and nextTrack() etc etc etc.... what i wan't to do is to create a program (in java/c#) that would go into the browser console and send that command, if for example, I hit some kind of hotkey "ctrl + n" for example.
Is there any way to manipulate chrome like that?
Thanks
You could write an application which incorporates the browser into Java using something like http://djproject.sourceforge.net/main/index.html - it can open a browser window, navigate to a location, and then execute arbitrary Javascript.
is JavaFX capable of loading and embedding OCX Controls? I would like to use the Internet explorer in my Application, because the WebKit browser lacks support for ActiveX. And since I have to rely on third party ActiveX Controls (I know they are evil), I am bound to the IE.
This question is not purely related to "Can I use OCX in Java" because I would like to have some kind of component for JavaFX I would like to use.
Or do I have to rely on libraries posted here:
Use a .OCX Control in Java
Thanks in advance,
Sven
You have to rely on the libraries posted in the link you supplied in your question.
Or you need to write your own JNI interface.
If you do access OCX components, you may need to place them in their own window rather than sharing a window created by a JavaFX stage as you may run into issues with the JavaFX renderer conflicting writes on the window portions in which the OCX components are displayed - you would have to try it and see what happens to confirm.
The easier way to do this may be to request that users of your application set their default browser to IE, and then call the JavaFX hostservices.showDocument(uri) api to launch an IE page which embeds the OCX components you need.
Another alternative is to:
Embed your JavaFX application as an applet in a web page.
Also embed your activex controls in the web page.
On display of the web page, check the browser and, if it isn't IE, tell they user that the must be using Internet Explorer.
Have the user accept any miscellaneous security warnings the Browser displays.
Have the user (or perhaps JavaScript) resize the browser window to fullscreen (see IE9 Full Screen Mode or Full Screen Browsers with JavaScript).
Communicate between your active X controls and java app using javascript invoked via calls from the javafx/javascript bridge and control your active X controls via VBScript embedded in the page.
It would probably work, but it is such an ugly Frankenstein solution . . .
If you can convert your media to a format which JavaFX supports and just play it back direct through JavaFX, that would be much preferable, or it may also turn out that due to a deep ActiveX integration requirement that JavaFX is not the best solution to your problem and you could be better off with something like Silverlight.
I have a simple java applet that retrieves an image from a server and prints it out. The only problem is that I get the following java security warning:
Researching on this site and all over the web, some people suggest that I sign the applet (I tried that to no avail) and others suggest that I Modify a local java security setting but that isn't feasible for my clients.
Not only do I get this warning at the start of my applet, but seemingly any time the code attempts to interact with the printer, the dialog re-appears. Also, note that there is no checkbox next to 'Always allow this applet to access the printer'. These symptoms show on any browser.
How do I get java to respect the users choice to allow it to send jobs to the printer?
You might use the JNLP API services in a sand-boxed applet in a plug-in 2 JRE. They will still prompt the user each first time they go to print, but should also put an 'always allow' check-box on the dialog (though it really only applies for that run). See a demo. of the PrintService.
See also the applet info. page that includes a link on the Next Generation in Applet Java Plug-in Technology which "..brings new abilities to applets: such as .. allowing embedded applets to gain full access to the services of Java Web Start."
I have a Java program that runs from command prompt / blueJ's terminal window fine.
Is there a way that I can run this from a browser?
I guess my question is, is there anything that simulates the terminal window in a browser?
If not, do you have a suggestion as to how to put this online? It uses scanner / system.out.println a lot.
Thank you
There are two main technologies for helping publish a Java application via a browser:
Applets (displays inside a browser, kind of like Flash)
Java Web Start (launches via browser, but then runs and displays in a separate window.)
It most most common to use Swing to develop the user interface of an Applet or Java Web Start application. So it might be interesting to read about how to emulate a console window in Swing.
I'm not sure if this helps, but when you access a website that uses Java, with your browser, you can decide to see the Java console, if you have it enabled in your Java settings. But only people with that option turned on will get to see it.
Otherwise you could use javascript to incorporate results into the html of the page, or maybe make an applet with a "console" included.
You can embed in an applet, not only GUI you can use applets to invoke any method. And you can view console view ,[ Java Icon pops up on system tray bar in windows,on right clicking on the java icon, you can view console ]
hii every one
good morning
I have created one project on JApplet
it runs successfully on Applet window
but i want to run it on web browsers(Internet explorer , Mozilla firefox, Safari, etc.)
I m using Mac os x and i want to run it on Safari.
You have to create an html which refers to the applet. Open the html in browser.
Take a look here for the applet tag http://www.w3schools.com/TAGS/tag_applet.asp
Using Mac OS X, in /Applications/Utilities you'll find Java Preferences.app. In the Advanced tab, you can enable the Java Console, which may tell you more about what's wrong when you open your HTML page in a browser.
Also, you can edit your question to add code, etc.
Addendum: You might want to start with a known working example.