Top Description Inners Fields Constructors Methods
com.sun.jna.platform.win32

public final Class User32Util

extends Object
Class Inheritance
Imports
com.sun.jna.Memory, .Native, .Pointer, java.util.Arrays, .List, .ArrayList, .Collections, .EnumSet, com.sun.jna.platform.win32.WinDef.HINSTANCE, .WinDef.HMENU, .WinDef.HMODULE, .WinDef.HWND, .WinDef.LPVOID, .WinUser.MSG, .WinUser.RAWINPUTDEVICELIST, com.sun.jna.ptr.IntByReference, com.sun.jna.win32.W32APITypeMapper, java.io.UnsupportedEncodingException, java.lang.reflect.InvocationHandler, .InvocationTargetException, .Method, java.util.concurrent.Callable, .ExecutionException, .Future, .FutureTask, java.util.logging.Level, .Logger

Provides convenient usage of functions defined by User32.dll.
Authors
Ralf HAMBERGER, Markus KARG (markus[at]headcrashing[dot]eu)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
User32Util.MessageLoopThread

Helper class, that runs a windows message loop as a seperate thread.

Field Summary

Modifier and TypeField and Description
public static final EnumSet<Win32VK>
WIN32VK_MAPPABLE

Set of Win32VK members that can be mapped to a UniCode code point via a keyboard layout.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static final WinDef.HWND
createWindow(final String className, final String windowName, final int style, final int x, final int y, final int width, final int height, final WinDef.HWND parent, final WinDef.HMENU menu, final WinDef.HINSTANCE instance, final WinDef.LPVOID param)

public static final WinDef.HWND
createWindowEx(final int exStyle, final String className, final String windowName, final int style, final int x, final int y, final int width, final int height, final WinDef.HWND parent, final WinDef.HMENU menu, final WinDef.HINSTANCE instance, final WinDef.LPVOID param)

public static final void
public static final List<WinUser.RAWINPUTDEVICELIST>
public static String

Returns:

the string located at the designated location
loadString
(String
the location, eg. %SystemRoot%\system32\input.dll,-5011
location
)

Load a string value from the string table of an executable.

public static final int
registerWindowMessage(final String lpString)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

WIN32VK_MAPPABLEback to summary
public static final EnumSet<Win32VK> WIN32VK_MAPPABLE

Set of Win32VK members that can be mapped to a UniCode code point via a keyboard layout.

Constructor Detail

User32Utilback to summary
public User32Util()

Method Detail

createWindowback to summary
public static final WinDef.HWND createWindow(final String className, final String windowName, final int style, final int x, final int y, final int width, final int height, final WinDef.HWND parent, final WinDef.HMENU menu, final WinDef.HINSTANCE instance, final WinDef.LPVOID param)
createWindowExback to summary
public static final WinDef.HWND createWindowEx(final int exStyle, final String className, final String windowName, final int style, final int x, final int y, final int width, final int height, final WinDef.HWND parent, final WinDef.HMENU menu, final WinDef.HINSTANCE instance, final WinDef.LPVOID param)
destroyWindowback to summary
public static final void destroyWindow(final WinDef.HWND hWnd)
GetRawInputDeviceListback to summary
public static final List<WinUser.RAWINPUTDEVICELIST> GetRawInputDeviceList()
loadStringback to summary
public static String loadString(String location) throws UnsupportedEncodingException

Load a string value from the string table of an executable.

Parameters
location:String

the location, eg. %SystemRoot%\system32\input.dll,-5011

Returns:String

the string located at the designated location

registerWindowMessageback to summary
public static final int registerWindowMessage(final String lpString)
com.sun.jna.platform.win32 back to summary

public Class User32Util.MessageLoopThread

extends Thread
Class Inheritance

Helper class, that runs a windows message loop as a seperate thread. This is intended to be used in conjunction with APIs, that need a spinning message loop. One example for this are the DDE functions, that can only be used if a message loop is present. To enable interaction with the mainloop the MessageLoopThread allows to dispatch callables into the mainloop and let these Callables be invoked on the message thread. This implies, that the Callables should block the loop as short as possible.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
private volatile long
private static long
private volatile int
private final List<FutureTask<V>>
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
exit()

Hides java.lang.Thread.exit.

This method is called by the VM to give a Thread a chance to clean up before it actually exits.
protected boolean

Returns:

true if MainLoop should exit, false it it should resume
getMessageFailed
()

The method is called from the thread, that run the message dispatcher, when the call to com.sun.jna.platform.win32.User32#GetMessage fails (returns -1).

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.
public <V> Future<V>
runAsync(Callable<V> command)

public <V> V
runOnThread(Callable<V> callable)

Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

javaThreadIdback to summary
private volatile long javaThreadId
messageLoopIdback to summary
private static long messageLoopId
nativeThreadIdback to summary
private volatile int nativeThreadId
workQueueback to summary
private final List<FutureTask<V>> workQueue

Constructor Detail

MessageLoopThreadback to summary
public MessageLoopThread()

Method Detail

exitback to summary
public void exit()

Hides java.lang.Thread.exit.

Doc from java.lang.Thread.exit.

This method is called by the VM to give a Thread a chance to clean up before it actually exits.

getMessageFailedback to summary
protected boolean getMessageFailed()

The method is called from the thread, that run the message dispatcher, when the call to com.sun.jna.platform.win32.User32#GetMessage fails (returns -1).

If the method returns true, the MainLoop is exitted, if it returns false the mainloop is resumed.

Default behavior: The error code is logged to the com.sun.jna.platform.win32.User32Util.MessageLoopThread logger and the main loop exists.

Returns:boolean

true if MainLoop should exit, false it it should resume

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
runAsyncback to summary
public <V> Future<V> runAsync(Callable<V> command)
runOnThreadback to summary
public <V> V runOnThread(Callable<V> callable) throws Exception
com.sun.jna.platform.win32 back to summary

public Class User32Util.MessageLoopThread.Handler

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • com.sun.jna.platform.win32.User32Util.MessageLoopThread.Handler
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Field Summary

Modifier and TypeField and Description
private final Object

Constructor Summary

AccessConstructor and Description
public
Handler(Object delegate)

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(final Object
the proxy instance that the method was invoked on
proxy
,
final Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
final Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final Object delegate

Constructor Detail

Handlerback to summary
public Handler(Object delegate)

Method Detail

invokeback to summary
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.