Hello,
I am trying to convert this example to a library for B4J: http://ochafik.com/blog/?p=98
When I compile the library using the simple library compiler, I get no error, but when I load the library in B4J I get this error message in the IDE:
This is the java file:
(Note: I couldn't include in the zip file the jna-3.4.0.jar. You will have to download from here : http://mvnrepository.com/artifact/net.java.dev.jna/jna)
I am trying to convert this example to a library for B4J: http://ochafik.com/blog/?p=98
When I compile the library using the simple library compiler, I get no error, but when I load the library in B4J I get this error message in the IDE:
This is the java file:
B4X:
package anywheresoftware.jmon.jWin32IdleTime;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.sun.jna.*;
import com.sun.jna.win32.*;
/**
* Utility method to retrieve the idle time on Windows and sample code to test it.
* JNA shall be present in your classpath for this to work (and compile).
* @author ochafik
*/
@Version(1.0f)
@ShortName("jWin32IdleTime")
@DependsOn(values={"jna-3.4.0"})
public class Win32IdleTime {
public interface Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = (Kernel32)Native.loadLibrary("kernel32", Kernel32.class);
/**
* Retrieves the number of milliseconds that have elapsed since the system was started.
* @see http://msdn2.microsoft.com/en-us/library/ms724408.aspx
* @return number of milliseconds that have elapsed since the system was started.
*/
public int GetTickCount();
};
public interface User32 extends StdCallLibrary {
User32 INSTANCE = (User32)Native.loadLibrary("user32", User32.class);
/**
* Contains the time of the last input.
* @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputstructures/lastinputinfo.asp
*/
public static class LASTINPUTINFO extends Structure {
public int cbSize = 8;
/// Tick count of when the last input event was received.
public int dwTime;
}
/**
* Retrieves the time of the last input event.
* @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getlastinputinfo.asp
* @return time of the last input event, in milliseconds
*/
public boolean GetLastInputInfo(LASTINPUTINFO result);
};
/**
* Get the amount of milliseconds that have elapsed since the last input event
* (mouse or keyboard)
* @return idle time in milliseconds
*/
public static int getIdleTimeMillisWin32() {
User32.LASTINPUTINFO lastInputInfo = new User32.LASTINPUTINFO();
User32.INSTANCE.GetLastInputInfo(lastInputInfo);
return Kernel32.INSTANCE.GetTickCount() - lastInputInfo.dwTime;
}
}
(Note: I couldn't include in the zip file the jna-3.4.0.jar. You will have to download from here : http://mvnrepository.com/artifact/net.java.dev.jna/jna)
Attachments
Last edited: