B4J Question Get user IDLE TIME? (Solved)

jmon

Well-Known Member
Licensed User
Longtime User
Hi,

I am trying to get if the user is idle or not. I have tried many ways, but nothing has worked so far...
What I am really trying to get is if if the user is away from computer, so no keyboard or mouse input for a while. If that's not possible, then I could be satisfied with a no mouse input only.

I have tried this, to check if the user moves the mouse (http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/MouseInfo.html) but just calling this:
B4X:
Private MouseInfo As JavaObject
MouseInfo.InitializeNewInstance("java.awt.MouseInfo", Null)
causes an exception:
B4X:
Program started.
jidletime._initialize (java line: 64)
java.lang.IllegalAccessException: Class anywheresoftware.b4j.object.JavaObject can not access a member of class java.awt.MouseInfo with modifiers "private"
    at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
    at java.lang.Class.newInstance(Class.java:368)
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:49)
    at b4j.example.jidletime._initialize(jidletime.java:64)
    at b4j.example.main._appstart(main.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.start(main.java:33)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:216)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    at java.lang.Thread.run(Thread.java:744)

I have tried to write a java class using jdic, but it seems that the project has been discontinued, so I couldn't find a jdic file containing SystemInfo.:
B4X:
package anywheresoftware.jmon.GetIdleTime;

import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

import org.jdesktop.jdic.systeminfo.SystemInfo;


/**
*/
@Version(1.0f)
@ShortName("jIdleTime")
@DependsOn(values={"jdic-0.9.2"})
public class jIdleTime {
    // 1.0    initial release
    private static final double version = 1.0;
    /**
    Returns the version number of the library.
    */
    public double getVersion() {
        return version;
    }

    /**
    Initialize an instance of AutoitX.
    */
    public void Initialize() {

    }

    public long getIdleTime() {
        return SystemInfo.getSessionIdleTime();
    }


}

I'm a little desperate, I have spent all day on that and still no clue. If anyone has any idea, I'd be SUPER happy :)

Thanks.
 

alienhunter

Active Member
Licensed User
Longtime User
i got the same problem :) , to see if the user works or not , but the computer might work for him so you want to see if he is using a certain app and his cpu load of this app, i did that in vb 6 once
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top