how to map callback Function with Java native access (JNA)
How can i set up windows hook with WH_FOREGROUNDIDLE
and the following call back Functions
DWORD CALLBACK ForegroundIdleProc( __in int code, DWORD wParam, LONG lParam );
I am trying to detect when a thread/process goes idle.
开发者_高级运维I have obtained the threadProccessId
by using the following functions:
GetForegroundWindow -> GetWindowThreadProcessId.
public static interface ForegroundIdleProc extends Callback(){
int invoke(int code, int wParam , NativeLong lParam);
}
/*....Usage....*/
ForegroundIdleProc proc = new ForegroundIdleProc(){
int invoke(int code, int wParam , NativeLong lParam){
/* Handle callback */
/*Make sure you define this function first.*/
return NativeLibrary.Instance.CallNextHookEx(NULL , code , wParam , lParam);
}
}
NativeLibrary.Instance.SetWindowsHookEx(WH_FOREGROUNDIDLE , proc , etc etc);
EDIT: Added a return statement.
Extend StdCallCallback instead of Callback in order to get the callback called with the correct calling convention. Under win32 the macro "CALLBACK" usually resolves to _stdcall.
精彩评论