I'm trying to manipulate an external window on Java, with JNA. I want to find a specific window and then minimize it. Every window that I've tried worked well but one (obviously the one that I need). That one can be found and set to the foreground, but can not be minimized programmatically. I've also tried to move it with User32.INSTANCE.MoveWindow, but that command failed too.
I was wondering if there are applications that do not allow JNA window manipulations. If so, what can I do? My code is shown below.
HWND test = User32.INSTANCE.FindWindow(null,"windowname");
User32.INSTANCE.SetForegroundWindow(test);
User32.INSTANCE.ShowWindow(test, WinUser.SW_MINIMIZE);
From the API for ShowWindow:
nCmdShow
Type: int
Controls how the window is to be shown. This parameter is ignored the first time an application calls ShowWindow, if the program that launched the application provides a STARTUPINFO structure. Otherwise, the first time ShowWindow is called, the value should be the value obtained by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter can be one of the following values.
It would seem to be that your minimize command may work if you call it a second time.
Related
some one suggested this but i am not able to implement it can any one can help me by providing the desired code in kotlin..
Another solution can be to call
UsageStatsManager.queryEvents
with the start of the day as first parameter and the current time as end parameter and then filter the results to check just the
UsageEvents.Event.SCREEN_INTERACTIVE UsageEvents.Event.SCREEN_NON_INTERACTIVE
events
take the timestamp of each of them and sum all the time passed between each
SCREEN_INTERACTIVE -> SCREEN_NON_INTERACTIVE
events, this would easily show how much time the screen was interactive, so screen on and the touch enabled.
There is a possibility that you'll have a SCREEN_INTERACTIVE event that doesn't have any related SCREEN_NON_INTERACTIVE, this is when the
UsageEvents.Event.DEVICE_SHUTDOWN
event happen, luckily this event is in the same list returned by the queryEvents method
remember also to declare and make the user to allow the android.permission.PACKAGE_USAGE_STATS permission as stated here
ps. i haven't used this yet but looking at the documentation it's the right thing to use, probably the one used by the android settings pps. look also to the other events in the same package, they might be helpful to what you want to accomplish
Is there a way in NetBeans that while you are debugging a Java program to modify or check the value that a function or variable returns. The same way you can use the console in Matlab.
I'm not speaking about the usual debugging tools variable windows etc.
Example I want to break at a method in car class and input
>car.getMileage()
and get..
>car.getMileage()
>2500
or
>car.setMileage(100)
>car.getMileage()
>100
In Netbeans there is a tab under your source code window (there by default I think) called Variables. In that window you can edit the Value field of any variable that is in scope while suspended at a breakpoint. This value should update for the java application as you change it in real time. You can invoke methods the same way, by adding a watch. Like say you had a static method getInt(); which returns some value. Just make a watch for getInt(), and the Value column will show you the return value. So for your example, make a watch for car.setMileage(100) after your breakpoint is hit. The value column will likely be 'void'. Then make another watch for car.getMileage(). 100 should be returned.
Use an IDE such as Eclipse. You can set breakpoints, set statements and execute them. This is a feature of most modern IDEs actually.
More info on the display view can be found here : http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/views/debug/ref-debug_view.htm
For a nice overview of the debugging features of Eclipse, check out this post : http://www.cavdar.net/2008/09/13/5-tips-for-debugging-java-code-in-eclipse/
Here (http://www.desktop-macros.com/) is a program which records sequences of mouse clicks and key strokes on a PC and then plays it back to perform some user-defined actions.
Now, what I'd like to achieve is a bit more demanding: I'd like for example to launch a browser with mouse clicks, wait until it's started (i.e. its application screen is visible) and then again perform some mouse&keyboard actions.
Of course it would also be useful to obtain also other information, like position and dimensions of the window.
Is it possible to make such fancy OS-related operations (like checking whether an application is fully-loaded) with Java? Maybe there are some non-standard libraries with useful API?
If not, could you recommend some way/language of solving such an issue?
I use Autohotkey that has the command WinWait that waits for windows having the good title. But I rely on Send {Enter}, not on mouse, to do things.
I've returned to IntelliJ after a long hiatus for Android development so I'm getting used to it again. The problem I have is that for example when you want to see where is a class being used, you'd position the caret in the class declaration and issue cmdaltF7 (on Mac OS X) to Find Usages, which is returning stuff from mapping.txt and seeds.txt as well as the .java results, and even tho I can set up the defaults by doing shiftcmdaltF7 and un-tick the: search for text occurrences and even change the scope from Project Files to a custom scope (for example), these options are not saved when I invoke Find Usages again.
Does anybody know of a way to personalize the Find Usages so it's more close to what Eclipse would do? (I.e., find the real usages instead of a text search for occurrences).
Reporting back from the future: the behaviour described in the question has now been implemented (Intellij issue mentioned in the comments).
To configure cmdaltF7 to run in a default scope, start by running it against some Symbol
Clicking on the wrench icon, one can select one of the pre-defined scopes, or create a new one (using the ... button).
The + creates a new scope. Find the folder in which to look, and click Include recursively. And voila!
Any consequent searches will use that scope until it is changed.
Instead of cmdaltF7, use the shortcut altF7. This will open a pop-up for you to make a selection about Scope, Test occurrences, and types of usage. You will have to make this selection one time. The next time you press altF7 then your choices are remembered.
The result is that altF7 followed by enter gives you what you need.
I am developing an Java swing based application which will 3 distinct main JFrames and each one of these will have to be displayed on one of the three display-monitors present in the system. Moreover application is going to have capability to alertif a particular display-monitor gone disconnected or reconnecetd.
Each main-JFrame must be displayed on a specific display-screen. This is due to the place where these monitors are going to be located. More like a point of sale scenario where one monitor can show things for sale-person and other for client and other for a security person.
Now the main issue is how to know which monitor is which. I solved this issue by getting serial-no of each monitor by calling a VBScript from within Java.
But still another problem is how map serial-no information of the monitor in Java. In Java what I can get corresponding to each monitor is a java.awt.GraphicsDevice instance and I have no idea how I can map serial-no information to this as the only way to have these instances of java.awt.GraphicsDevice is GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices() and this function does not ensure that it will return the devices in a sepecific sequence, each time the function is called.
Thanking in anticipation
Java supports multiple monitors via a GraphicsEnvironment and GraphicsDevice objects. Check the GraphicsDevice javadoc for more info.
Does the GraphicsDevice.getIDString() method give you a stable value that you can compare against the serial numbers? If so, you can write all identified serial numbers to a property file, and do a comparison each time your program starts (if the ID isn't already the serial num). This property file could also store the position of each display (left, center, right or top, middle, bottom, etc)
If you cannot determine the correspondance between the id and the serial number, you could trigger a 'display setup routine' whenever you see an display id that is not in your properties file.
This routine would prompt the user to confirm the display model number and enter the position of each display (consider the display orientation settings in Win,OS X, Linux etc). If you can draw widgets to a specific display, you should be able to collect this information. Also, if the user rearranges the physical position of their displays (perhaps swapping the position of two displays), then they could manually execute this routine.