Jump to content

Embedding Internet Explorer in a GUI


Recommended Posts

I want to know if there is a way to prevent Internet Explorer, when embedded in a GUI, to catch "Backspace" when the GUI don't have the focus. If I try to press "Backspace" in an Input control and I have previously clicked on any link on the web page, it will perform a "BACK" action.

I don't know if I am really clear but there is a simple exemple.

#include <GUIConstants.au3>

; Gui 1
$oIE = ObjCreate("Shell.Explorer.2")
$Form1 = GUICreate("Exemple", 896, 257, -1, -1)
$GUIActiveX = GUICtrlCreateObj($oIE, 8, 8, 820, 241)
$Button1 = GUICtrlCreateButton("Ok", 840, 8, 49, 241)
$oIE.navigate("http://www.autoitscript.com")
GUISetState(@SW_SHOW, $Form1)

; Gui 2
$Form2 = GUICreate("Test", 244, 37, -1, -1)
$Input1 = GUICtrlCreateInput("Try to Use BackSpace", 8, 8, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Button2 = GUICtrlCreateButton("Ok", 135, 8, 81, 21)
GUISetState(@SW_HIDE, $Form2)

While 1
    $msg = GuiGetMsg()
    If WinActive($Form1) Then
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Button1
                GUISetState(@SW_SHOW, $Form2)
        EndSelect
    ElseIf WinActive($Form2) Then
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUISetState(@SW_HIDE, $Form2)
            Case $msg = $Button2
                GUISetState(@SW_HIDE, $Form2)
        EndSelect
    EndIf
WEnd
Exit
Link to comment
Share on other sites

Im just taking a stab at this and havent tested it but,

in the while loop try

If Not WinActive($Form1) And Not WinActive($Form2) Then
     HotKeySet("{BACKSPACE}", "Nothing")
     Do
          Sleep(500)
     Until WinActive($Form1) or WinActive($Form2)
     HotKeySet("{BACKSPACE}", "") ;Not sure if thats the right way to make it not a set key any more
EndIf

Func Nothing()
     Sleep(500)
EndFunc
Edited by narayanjr
Link to comment
Share on other sites

Im just taking a stab at this and havent tested it but,

in the while loop try

If Not WinActive($Form1) And Not WinActive($Form2) Then
     HotKeySet("{BACKSPACE}", "Nothing")
     Do
          Sleep(500)
     Until WinActive($Form1) or WinActive($Form2)
     HotKeySet("{BACKSPACE}", "") ;Not sure if thats the right way to make it not a set key any more
EndIf

Func Nothing()
     Sleep(500)
EndFunc
OK I will give it a try a answer on this topic, thanks

for now it's a little bit late to test so I'll come back as soon as possible

Link to comment
Share on other sites

  • 2 months later...

I'm having a similar problem, illustrated below.

I tried interrupting the BACKSPACE but to no avail.

I would be grateful for any other ideas.

CODE
#include <GUIConstants.au3>

$GUI1 = GUICreate("launcher", 200, 200, 600, 50)

GUISetBkColor (0x33FF66)

$oIE = ObjCreate("Shell.Explorer.2")

$GUIBrowser=GUICtrlCreateObj($oIE,0,0,200,200) ;

$oIE.Navigate ("about:blank");

Sleep(1000)

$oIE.document.writeln("<span style=font-family:arial;font-size:11px>This is a page in an embedded Internet Explorer</span>")

$oIE.document.body.style.backgroundColor='#33FF66'

GUISetState()

$GUI2 = GUICreate("business", 200, 200, 400, 50)

$searchBox = GUICtrlCreateInput("Backspace focus and embedded IE", 10, 10, 190, 20 )

$description=GUICtrlCreateLabel ( "1: click in the input box above at the end and press the BACKSPACE key. It works. "&@CR&@CR&"2: Now click in the green window."&@CR&@CR&"3: Now repeat action 1. It fails. "&@CR&@CR&"Can anyone help me prevent this?", 10,40, 180,140)

GUISetState()

Func Nothing()

Sleep(500)

EndFunc

While 1

If Not WinActive($GUI1) And Not WinActive($GUI2) Then

HotKeySet("{BACKSPACE}", "Nothing")

Do

Sleep(500)

Until WinActive($GUI1) or WinActive($GUI2)

HotKeySet("{BACKSPACE}")

EndIf

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...