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.
Related
This is for an offline application. However, I would like the front end to be run in a web browser. What I want is, a simple gui design in HTML/CSS. I want to be able to execute java commands at a button's press. Furthermore, I would like to be able to display and read information from the browser. Is this feasible?
You could use JxBrowser. The knowledge base contains some pretty good example. Unfortunately, it is not free though.
I need to open a browser with URL and then wait till person clicks a special button. And if it happens, return true. Can I implement it with java tools or should I use javascript?
You should use JavaScript. Java is a Server side language, so all processing of Java code will be completed before the user has the chance to interact with the page. JavaScript (traditionally) works on the client-side and is commonly used to capture user interactions with the browser.
yes, Java Script or any frame work that builds on Java script like Jquery works for you. If understands you correctly,
create Hyper link
Browse the page that you needed
Place HTML button on the page, write onClick logic on that button to return true.
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?
I'm looking to write a relatively simple key macro for my own edification and also for my own use.
I intend for it to be able to run in the background when I run other programs, and at the press of a button will enter certain text into the active window. To be more specific, I want to go in a video game and use it to automatically send messages instead of having to type them.
I Googled around a bit, but apparently I'm not using the right keywords because I'm not really sure where to start. The closest I came was finding the Keystroke class, but that appears to be used for receiving keystrokes, not sending them.
I would appreciate and info regarding, or directing me to a resource for, these issues (how to send keystrokes to windows and anything about targeting which window etc).
To send key strokes you can use java.awt.Robot
To Choose which window to activate you can look around for ws script (windows script) or old VB6 code and use it to make VB script (simple text file of extn .vbs)
Or you can junk all that and use http://www.autohotkey.com/ which has window activation, sending keys, doing things on press of certain keys (like Windows Key + B) or macros.
To get a window to activate I had made an exe long back, but no longer use it, can get it from http://sourceforge.net/projects/win-utils/files/Window-Position/rel%2001/ (but only get this if the others do not work as need to seperately get COMCTL32.ocx and install that
If you do not want to use autohotkey you can use Jini to call platform specific functions, with a wrapper to call correst OSes functions. Never done it my self, when i had to use it i would make a process to call a exe that made the window come the front.
I am not sure if we need our own custom browser for this.
If we do, what is your recommendation for open source browser?
We need application that is able to capture location of user clicks on the web page in the browser on Windows machine (cross-platform would be a huge plus). Store the coordinates in the file.
Later be able to open browser on that webpage and do the click screencapturing and reading the URL of the new page that user will be taken too.
Any idea on how to implement this? What libraries, open source projects could help us?
Can this be done in Java? C?
Thank you
This could work for you: (Taken from this website here)
$('#mouse-click').click(function(e){
$('#mouse-xy').html("X: " + e.pageX + " Y: " + e.pageY);
});
This uses jQuery which I think you may like. After that you could use AJAX to send the mouse click results back to your server and save that information in a file.
jQuery will achieve this for you, if you put this code inside your page,
$('#mouse-click').click(function(e){
var x = e.pageX;
var y = e.pageY;
});
jQuery is a JavaScript framework that you'll find will run in most browsers, certainly all the mainstream ones.
From there, you'll need to tell us what platform your developing on for us to give you any guidance on how you can make use of any of this.