I need to find the coordinates of windows open even when they are not launched by my application, and after some searching I came across quartz window services. However, the reference document I linked to does not mention where this is located, and it was the only document I could find about it. I have looked through other frameworks reference documents, but none of them so much as mention it.
The problem obviously arrises solely out of my own ignorance, and I did not really want to ask. But, I have searched all over the internet, and have been able to find absolutely no reference to the location of quartz windows service.
Where is it? Is it part of a framework, and if so what class is it in? All I know is what functions it contains, and that they look like exactly what I need!
Thank you in advance for any help. Also, if you know how I could figure this out for myself in the future, I would appreciate that as well.
Note: I don't know if it matters, but I am planning to use JNA to call it from Java as opposed to using it from C.
Yeah, that's a little less than obvious. By searching for "Quartz Window Services" I was able to find the link to the overview, such as it is: https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CGWindow_Reference/Reference/Introduction.html
That shows that it's in the ApplicationServices framework.
Well first off, I'm not 100% certain how you're going to access C methods from Java (I've never done it myself), but if it's possible to do the bridging, you can use the Accessibility API in order to get the windows for all of the running applications (see the answer to this related question). Once you have that list of windows, you can get the frame (coordinates) of where each of those windows lives on-screen.
Another thing about using the Accessibility API, the user has to "OPT IN" to allowing it. It's not normally turned on by default.
Here's another question that closely matches yours, but the accepted answer only provides a solution to retrieve the windows for your own (currently running) application.
Related
Before answering, please read all of this so you don't miss any details.
I have been looking on the internet for days, and trying to look through the javadocs, but I cannot find the answer anywhere.
How can I get connected devices through USB by using the java API. I do not want to use any libraries as they aren't reliable enough for the purpose I am using it for.
How do USB java libraries do it, what Java API does it use to connect to USB devices?
I know it may be complicated to actually work with it, but it will still be very useful.
I did seen the use of File.getRoots(), but it just gives storage, like C:/, H:/, etc. I want to be able to communicate with any USB device, like mouses, keyboards, custom hardware, etc.
Also include examples of code as well. It helps a lot in understanding it better. Make sure to also get to the point, it helps by saving time.
Update: I still have no clue on how to start.
Update 2: I found something with javax.usb, is it part of the java api, when I do say java api, I mean stuff that is already with java and where you don't need to download anything but the JRE. I am not sure as if it was, I would think someone would of mentioned something about it here. Going to try to find more into it. I can't find anything on the official java-14 docs, so guessing not.
Update 3: Haven't found an answer yet. Everything is redirecting to usb4java, which has not been updated in a couple years, 3 years in fact. Which is actually one of the main reasons I don't want to use any external library as it might get abandoned and will cause some issues with my code in the future. Hopefully someone can help soon, I desperately need an answer and the internet is no help and everything seems to redirect to libraries, which again, I don't want.
Update 4: Still on the hunt for an answer, still haven't found anything useful.
Update 5: I am seeing that I have tons of uses to do this, but don't know how to do it from scratch.
Update 6: Still on the hunt for an answer. I have been looking hard but found nothing. Looking through the USB4JAVA library code has been proven to not help much. But, I am going to keep looking, hopefully I find something soon. Found something though, it's libusb, a C program that USB4JAVA uses. Even though I won't use Java libraries, I might just use C libraries for Java, if that makes sense.
I have a java program which need to create, update and read counters in the Windows performance Monitor.
I have searched stackoverflow for previous posts about this issue and found two main articles proposed:
First is this one. It relies on unbearable Win32 API and doesn't give a complete step by step tutorial. Also, I do not know this Win32 API and do not wish to study it now.
The second is this one. It seemed to me like a better option, but it relies on nsclient component which I couldn't find anywhere on the web. However, there is nsclient++, but I am not sure it supports java (I posted there a question about it) and anyways, the tutorial is not based on it.
Maybe some has a better solution?
Many thanks, Tal.
I would like to invoke a paste operation with my java application. Is this possible without using Robot?
For example, the application would invoke a paste operation every so often, so when I am writing in notepad, I would see the contents of my clipboard.
JAVA APP Notepad
clipboard.paste() --------> clipboardContents
It sounds as if you're trying to use Java to interact or partially drive another application (such as Windows NotePad) and paste to that application, and if so there are several possible solutions, one being use of Robot, another having Java make operating system calls, though this can't be done directly with just core Java and would require use of either JNI, JNA or other platform-specific non-core utility programs such as AutoIt (if this is for Windows).
Why are you dead set on not using Robot? Can you explain your needs in greater detail?
Edit
regarding your comment:
I want to explore alternatives to Robot, as my client irrationally rejects Robot.
Since this appears to be for a Windows platform, you might consider exploring the Windows API and the API for whatever non-Java program you're trying to drive (if one exists), and then using JNA to interact with it. The Windows User32.dll would allow you to get the Window handle (hWnd) of the application that you're trying to drive, which may be necessary for this to work.
It's hard to give more specific advice without more specific information from you about your problem though.
Edit 2
regarding your comments:
I would like the app to be platform independent.
Well, Robot comes to mind then. You might want to have a sit-down with your client to find out what they dislike so much about Robot, and then gently explain that it might offer the best path towards a platform-independent solution.
Are there examples for JNA and/or JNI? I'm not familiar with either.
Yes there are lots of examples on this and other sites, and Google will help you find out more. JNA is a bit easier to work with as it doesn't require you to create a C bridge program, but it can be a little slower than JNI, and doesn't work directly with C++ code (as far as I know).
Edit 3
regarding your comments:
I have a serial port listener (java app). I need to provide its contents onto a web browser. Clipboard seemed to be a way to do it.
And this is why it's so important for you to provide the context of your problem rather than what you think your code solution should be.
Communicating between applications is not an easy thing to do, and often Java is not the best tool for this since as it is designed to be as platform agnostic as possible, it does not provide tools that allow for easy integration with low-level OS functions. I don't know the best way to solve your problem, but my intuition tells me that using clipboard may not be the way to go. Much may depend on which web browser you're talking about, whether it has some sort of API that allows for interface with other programs, things I know little about. Also where is your program sitting? On the user's computer? Have you considered using a Java web browser library of some type, creating your own specialized web browser program, and obtaining the data directly from your serial port listener (again, I have not done this myself, but have seen it described on SO)?
I don't understand how bridging to a C program will help me.
I'm not suggesting this. This would only be needed if you used JNI, something I avoid since JNA is much easier (at least for me).
I have been using the automation feature of whatismyip.com to provide a WAN to my program. However, I recently was banned for overuse (I didn't realizing I was accessing the site every time I started the program to test it). That was my mistake... it wasn't intentional. I've contacted them about it, but in the mean time I need another method.
Are there any other ways to do it and/or does anyone know of another site that provides an automation function?
http://whatismyipaddress.com, but they may well share the same ban list. Both sites have obvious notes embedded in their page source about scripting against their service. I suggest you follow the directions and contact them before you screen scrape them.
I know that http://speedtest.net/ shows your IP, but I am not sure if that is what you need.
Ever since I started playing around with Scala, I have had one big question concerning the Java API: why does Oracle keep the same old HTML page with "frameset" tags and no search function at all? It looks like they haven't made it to the Web 2.0...
The Scala API documentation on the other hand, while not the best website in the web history, is several orders of magnitude more usable.
Anyways, if anybody knows why that is and, more importantly, if there exists a Java API documentation with a better interface, please let me know!
Recently, for Java 7, JavaDoc was improved so it could use custom CSS. Here are the first results: http://download.java.net/jdk7/docs/api/. The work continues and I think we'll see more when new updates come out. I do agree that ScalaDoc is superior, but they didn't have to deal with 15 years of legacy.
Javadocs provides the output in that format and its published at that address, I guess no one really saw the need for improvement, but now that you mention it, it makes for an interesting side-project. I googled around to find if there was any "better" interface but no luck.
You could run javadoc -h to see what extra options are available if you want to re-generate the javadocs. Some interesting ones are to provide custom header/footer and linking to the source, but nothing to the effect that you are asking.
Those HTML pages were made using the Javadoc tools, a standard way to build documentation in Java.
I don't know if there are other webpages with a better formatting of the API, but if it helps you with anything, and you are using an IDE and the SDK, you can see the source code for most of the files there.
JavaDoc was designed to be the lowest common denominator. Virtually any web browser can display it, even without JavaScript support.
If you are looking for quicker access and search capabilities, you can access JavaDoc from within an IDE such as Eclipse.