This should be simple, maybe not, but I have a program with a web browser control that displays a flash website. I am trying to incorporate keypress events which work btw, but as soon as I click inside the flash site the keypress events don't work anymore. I know why they stop working I just cannot figure out how to fix it. I almost had a work around which involved setting this.focus() on every event. Stupid, I know.
Let's say for instance this web browser control was just a portion of the program, and all it did was display the page. I have other functions I need to implement, and would like to use keyboard shortcuts.
Any ideas?
thanks,
craig
Loading
theLizardPosted Aug 5, 2010, 11:38 PM
It seems to me that what is happening as you describe is quite legitimate, you click on the flash site and all key events are consumed by the flash site, this is no different to an MDI application with child forms, when you click on any one of those forms, the form clicked on becomes the focus, this is normal behavior for all windows and the flash site is basically a window.
Q. Do you want interaction with the browser control, if not, place the browser control on a panel and set the panels Enabled property to false, this should show the browser control normally but not be able to interact with the browser control (i think) if this works then you will get all the key events
theLizardPosted Aug 7, 2010, 2:47 AM
Now there is a possibility that you can intercept the keyboard messages when you are trapped in the flash site with something like SetWindowsHookEx I am reasonably sure that by using the windows API's you should be able to re direct the messages back to your application and stop the flash site getting the focus with anything other the mouse clicks after all it is a window in itself and is running in your computers memory space.
You will need to look at hooks and how they work, there is a lot to learn bout these so good luck, if I can help further just post the question.
craig godfreyPosted Aug 6, 2010, 9:13 PM
Here is what I did:
I put the web browser control in a panel like you said and set the panel's enable property to false. So far, so good. Only downfall which I knew would happen, now I cannot click inside of the flash site. I didn't say I needed to do that until my second post. Work around for this was to set the panel's enable property to true whenever a keyboard shortcut was pressed. But, I could obviously only click once because now the flash site has once again stole focus.
What to do?
Here is where it gets sloppy. I created a timer that starts whenever a keyboard shortcut is pressed and after 100 ms the panel's enable property gets set back to false allowing me to execute another keyboard shortcut. This timer ensures that the panel property is set to false except for when I need to click inside of the web browser.
If anyone knows a better way I would like to hear it because this method will probably only work on faster computers. But, all my computers are fast so I probably have no worries. :)
thanks again.
craig godfreyPosted Aug 5, 2010, 11:59 PM
I never thought of using a panel. That could work. I'll test it out and get back to you.
Just to give you more info, I am trying to use keyboard events so I can set them to an IR remote control through girder or event ghost. I am having to map the controls on the web page, then position the mouse on top of the control, and then click the mouse. It is really weird how I have to do it because of the site. Everything works if I use buttons, but not with keyboard events.
I'll try the panel and see if that works.
thanks,
craig