KeyDown event handler isn't triggered

Hi all!

I wrote a little program that continuously shows a video loop. When a key is pressed a new window opens and shows a message. The window stays on top for 5 seconds and then hides itself again. I use the KeyDown event handlers in the window that play the video and it works fine. If I accidentally click in the screen though the program becomes unresponsive. It seems like the videoplayer has the focus so the KeyDown event handler isn’t triggered anymore. I can’t get the focus back to the ‘main’ window to listen to key presses.

Any ideas?

Many thanks!

Maurits

If the video control is consuming the key stroke and not passing it to the form (where I assume you have the KeyDown event handler) you can remove focus from the movie control by putting a timer on the form, set it to 1000ms (or however fast you want focus removed) and put this code in the Action

If Not System.MouseDown Then Self.SetFocus End If

The System.MouseDown check is in there so you can interact with the video if you want and it wont remove the focus while the mouse button is down so you can slide the volume slider etc. If you dont want that feature, just have the Self.SetFocus in there.

Or you could test your key state using Keyboard.AsyncKeyDown inside a timer rather than using a KeyDown event.

The video player does tend to eat events in Windows (not tried it on the Mac or Linux). In a current project I have a fullscreen window with a fullscreen video playing (think kiosk). I had an issue where mouse click events got eaten by the video player. What I ended up doing was using the Overlay plugin from MBS to create an invisible window on top of the full size video player to get the events I needed. Kind of a pain but it works well and I didn’t need to pursue anything else.