Hello all :)
A strange feature of the MS WebBrowser Control showed it's head, & I tried figuring it out on my own, but it's stressful enough already without me having to go another week trying to make it work.
My problem is, I made a Win Forms app that loads a site's Flash game into it (many servers, & all live players). Now, when I load it up, it works fine... except it's not playable because the arrow keys are REQUIRED, but not working, & no matter how many times you press them, NOTHING happens in the game.
I have the following to catch the Esc, F11, & F5 keys:
They work as expected, but the Arrow keys are not being received/handled by the WebBrowser control... although it does send them in the PreviewKeyDown event. The WebBrowser control is just ignoring their actions, yet everything else works just fine.
I DO NOT want to mess with the DOM of the page (don't see why we even need to :)), or other things because that WILL get the user banned.
UPDATE:
I figured it out guys.
I changed the above code from:
To:
It did the trick :)
A strange feature of the MS WebBrowser Control showed it's head, & I tried figuring it out on my own, but it's stressful enough already without me having to go another week trying to make it work.
My problem is, I made a Win Forms app that loads a site's Flash game into it (many servers, & all live players). Now, when I load it up, it works fine... except it's not playable because the arrow keys are REQUIRED, but not working, & no matter how many times you press them, NOTHING happens in the game.
I have the following to catch the Esc, F11, & F5 keys:
Code:
Private Sub AxWebBrowser1_PreviewKeyDown(sender As Object, e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles AxWebBrowser1.PreviewKeyDown F11_Pressed = True 'Arrow Keys (Up, Down, Left, & Right) If (e.KeyCode = 37 Or e.KeyCode = 38 Or e.KeyCode = 39 Or e.KeyCode = 40) = True Then Exit Sub Try 'F11, or Esc key (Exit FullScreen) If Me.WindowState = FormWindowState.Maximized And (e.KeyCode = 122 Or e.KeyCode = 27) Then Me.WindowState = FormWindowState.Normal Me.Width = Me_Width Me.Height = Me_Height Me.ControlBox = True StatusStrip1.Visible = True Me.FormBorderStyle = 4 MenuStrip1.Visible = True Me.CenterToScreen() 'F11 key (FullScreen) ElseIf Me.WindowState = FormWindowState.Normal And e.KeyCode = 122 Then Me_Width = Me.Width Me_Height = Me.Height Me.WindowState = FormWindowState.Maximized Me.ControlBox = False StatusStrip1.Visible = False Me.FormBorderStyle = 0 MenuStrip1.Visible = False 'F5 key (Refresh) ElseIf e.KeyCode = 116 Then Application.DoEvents() AxWebBrowser1.Refresh() Else End If Catch ex As Exception End Try End Sub
I DO NOT want to mess with the DOM of the page (don't see why we even need to :)), or other things because that WILL get the user banned.
UPDATE:
I figured it out guys.
I changed the above code from:
Code:
'Arrow Keys (Up, Down, Left, & Right) If (e.KeyCode = 37 Or e.KeyCode = 38 Or e.KeyCode = 39 Or e.KeyCode = 40) = True Then Exit Sub
Code:
'Arrow Keys (Up, Down, Left, & Right) If (e.KeyCode = 37 Or e.KeyCode = 38 Or e.KeyCode = 39 Or e.KeyCode = 40) = True Then e.IsInputKey = True Exit Sub End If
Comment