jna

JNA: how to deal with unkown structs?

人走茶凉 提交于 2019-12-23 04:10:52
问题 If I'm not mistaken, a JNA Structure builds the struct by relying on the public fields of its corresponding Java class, which should extend Structure . My problem is that I need to pass a struct whose declaration is not known beforehand (let's say it's known at runtime). I just have a list of Object s, which the C library expects as a (reference to a) struct. Can I still use the Structure class or must I build a Memory object by hand, dealing with sizes, alignments/packing myself? For example

get mouse type in java using jna

梦想与她 提交于 2019-12-23 03:17:09
问题 SOVED thanks to @deFreitas I am trying to create remote control program in java . my problem is that I get image from remote computer using screenshot from the robot class and therefore I can not see the remote cursor. I know I can draw image of cursor on the screenshot but how can I get the global cursor type. I have searched a lot for that and the closest I got was this code: public interface User32 extends com.sun.jna.Library { public static User32 INSTANCE = (User32) com.sun.jna.Native

Get selected file item in Windows Explorer using JNA

此生再无相见时 提交于 2019-12-23 02:45:32
问题 I am writing an OSX Quick-look alternative for Windows using Java and was having trouble on how to get the active selections of file in a n active Explorer window, below is my attempt: @Override public void nativeKeyReleased(NativeKeyEvent e) { System.out.println("key up:" + NativeKeyEvent.getKeyText(e.getKeyCode())); if (e.getKeyCode() == NativeKeyEvent.VK_SPACE) { System.out.println("Space detected! intercept active window"); char[] buffer = new char[MSWindowConstants.MAX_TITLE_LENGTH * 2];

Query all Windows Services with JNA

耗尽温柔 提交于 2019-12-22 19:14:09
问题 Currently I'm trying to query all installed Windows Services from (remote) machine. I had a look at win32.Advapi32 . But here I can only "get" a defined (I have to give a "ServiceName") Windows Services. (Advapi32.INSTANCE.OpenSCManager, Advapi32.INSTANCE.OpenService, Advapi32.INSTANCE.QueryServiceStatusEx) Do you know any API which allows to query all Windows Services from (remote) machine? EDIT:// I tried it allready with the following code. But it aborts hardly with no error message!

Java error failed to create temporary file for jnidispatch library

我的未来我决定 提交于 2019-12-22 18:26:50
问题 While trying to install a third part java application I got this error Failed to create temporary file for jnidispatch library: java.io.IOException: Read-only file system. java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java

Android - JNA library

拥有回忆 提交于 2019-12-22 10:47:04
问题 Hello i'm using JNA to be able to use an external .dll(i don't have the header file but i have documentation thus the exposed function signatures). I have managed to use my dll in a java project following the instructions here and now i'm trying to use the same thing on an android app. I imporetd the jna jar in my libs and also added the jar in my buildpath and i'm getting an error The library 'jna-3.5.1.jar' contains native libraries that will not run on the device. The following libraries

How to handle WM_QUERYENDSESSION messages with JNA

随声附和 提交于 2019-12-22 10:23:20
问题 I want to catch WM_QUERYENDSESSION messages in Java with JNA so that I can execute a shutdown method because Runtime#addShutdownHook(Thread) doesn't work on Windows [1]. I know this can be done since I've seen it implemented with JNIWrapper but I would like to have a JNA-based solution. JNIWrapper solution import java.io.File; import java.io.RandomAccessFile; import javax.swing.JFrame; import com.jniwrapper.win32.Msg; import com.jniwrapper.win32.ui.WindowMessage; import com.jniwrapper.win32

Pass InputStream through JNA to C code as a File Pointer

送分小仙女□ 提交于 2019-12-22 08:32:21
问题 I've got a DLL written in C (that I can't edit) that has some function prototype that looks like #include <stdio.h> void foo(FILE *bar); I'd like to create a JNA interface to the DLL and it's unclear what I need to pass for the FILE *bar argument. I assume I need to pass an InputStream (which is my preference), but the JNA literature seems sparse on the subject. What would the Java interface look like? and what do I really need to pass to foo? Edit: foo assumes bar is the result of an fopen

Using jna to keyhook and consume

感情迁移 提交于 2019-12-21 21:27:39
问题 I'm making an auto clicker that uses jna to hook global input from the keyboard and mouse. For the keyboard hook im using http://code.google.com/p/goldriver/source/browse/trunk/king/src/jnacontrib/w32keyhook/KeyHook.java?r=36. I was wondering if there was any possible way to consume the key event so other applications don't process it? Fixed with return new LRESULT (1); Now I'm having a problem with it not continuing with the rest of the code, here is the source. My program keeps listening

Virtual Joystick in Java

﹥>﹥吖頭↗ 提交于 2019-12-21 04:30:15
问题 Have you heard of a virtual joystick for Windows that has Java wrappings? I've trying PPJOY, and it works great, but then I'll need to use JNI to get it working from Java and that doesn't seem easy for the time being. Thanks! 回答1: There you are. I've made a Java wrapper for PPJoy. And it's really easy to use. See: try { /* * Try to create a new joystick. */ Joystick joystick = new Joystick(); try { /* * Set joystick values */ /* * Set analog values for Axis X/Y/Z, * Rotation X/Y/Z, Slider,