How to intercept keyboard and mouse events on Windows
Posted: 02 May 2010 20:05
I am using java1.6 on Windows XP SP3.
Thanks to sherington and the excellent vlcj project, I have a basic video player application. However, I need to intercept keyboard and mouse events to trigger actions (custom menu, log to database, etc.).
The vlcj implementation passes a pointer to a heavyweight Canvas object to vlc. From what I know (and tried), it isn't possible to subscribe to key/mouse events to the Canvas object.
According to the comments, both libvlc_video_set_mouse_input and libvlc_video_set_key_input are only implemented for X11. (I'm not sure how they would be usable in a Win32 context). I've tried setting libvlc_video_set_mouse_input to 0 for curiosity's sake, and it swallows up the mouse cursor when it moves into the frame.
The only other approach is to create a transparent JDialog with the AWTUtilitiesWrapper and have it cover the entire video surface. Unfortunately, this has at least two issues:
- overlays need to be turned off (--no-overlays)
- JDialog still shows up in the Alt-Tab menu cycle
I'm wondering if anyone has come up with better approaches. If possible, I'd like it to be cross-platform (i.e: it needs to intercept key/mouse events on Linux/MacOS).
Also, if any libVLC developers are reading, are there any plans to expose keyboard/mouse input as events for libvlc_event_attach? Is it even possible?
Thanks in advance.
Thanks to sherington and the excellent vlcj project, I have a basic video player application. However, I need to intercept keyboard and mouse events to trigger actions (custom menu, log to database, etc.).
The vlcj implementation passes a pointer to a heavyweight Canvas object to vlc. From what I know (and tried), it isn't possible to subscribe to key/mouse events to the Canvas object.
According to the comments, both libvlc_video_set_mouse_input and libvlc_video_set_key_input are only implemented for X11. (I'm not sure how they would be usable in a Win32 context). I've tried setting libvlc_video_set_mouse_input to 0 for curiosity's sake, and it swallows up the mouse cursor when it moves into the frame.
The only other approach is to create a transparent JDialog with the AWTUtilitiesWrapper and have it cover the entire video surface. Unfortunately, this has at least two issues:
- overlays need to be turned off (--no-overlays)
- JDialog still shows up in the Alt-Tab menu cycle
I'm wondering if anyone has come up with better approaches. If possible, I'd like it to be cross-platform (i.e: it needs to intercept key/mouse events on Linux/MacOS).
Also, if any libVLC developers are reading, are there any plans to expose keyboard/mouse input as events for libvlc_event_attach? Is it even possible?
Thanks in advance.