Jump to content
Sign in to follow this  
Anne

Make embedded IE blank while loading / operating

Recommended Posts

Anne

Hi smart AutoiIT scripters.

First off, I wasn't sure if I should post this here or in the "ActiveX/COM Help and Support (AutoItX)" forum.

But this is in regards to the GUI so it made the most sense to post it here.

Case:
Alright, so I have been working on a simple script which opens an embedded IE instance in a GUI.

It goes to the URL "http://google.com" and waits for user input.

Now there is the option to enter a search query in the input field ($input1) and hit the GO button.
Once this button is pressed, the browser will search for the query and click the first search result, so that it opens this page.

Let me know if you need to see the script. However, this description should sum up everything.

Question:

Is is possible to make the embedded IE instance temporarily blank, while it performs the search and clicks the link.
The end result should be something like this:

Program goes to http://google.com -> user presses GO -> Embedded IE goes blank -> Embedded IE becomes visible again and the user sees the new website (the first result from Google).

It doesn't matter if it actually goes blank. Maybe it is possible to overlap the IE instance with an image while the browser is working. So that the image shows up while the browser is searching and then disappears afterwards.

I did a little searching around but I couldn't really find anything on this topic.

Any help will be gratefully appreciated as I am very new to Autoit. Also, you don't have to post the final script, any hints towards some useful functions or snippets would be perfect.

Share this post


Link to post
Share on other sites
Anne

I should have thought this over a little longer before posting here.

I solved this using the following:

GUICtrlCreatePic

GUICtrlSetState

Share this post


Link to post
Share on other sites
Anne

Actually it did not really work at all.

The picture shows up and overlaps the embedded IE object.

However, as soon as something happens inside the embedded IE object, the picture disappears again. How can I keep it there?

is there some way to have a GUI object "Always on top"? I tried using GUICtrlSetState($Pic1, $GUI_ONTOP) but it is only on top for a millisecond.

 

EDIT: This means I'm basically back to square #1

Edited by Anne

Share this post


Link to post
Share on other sites
HeJake

Something like this?  :)

#Include <IE.au3>
#include <GUIConstantsEx.au3>

Global $oIE[2], $GUIActiveX[2]
Global $BodyStyle = '<body style="margin-top: auto; border: 0px; overflow: hidden;">'
Global $LoadingImg = '<img src="http://www.shipco.com/include/images/shipco/loading1.gif">' ;Loading gif from google images
Global $ImgCentering = '<table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%"><tr><td align="center" valign="middle">'
Global $ImgCenteringE = '</td></tr></table>'
Global $Site = 'http://www.google.com/', $Search = 'search?q=', $SearchKeys

$GUI = GUICreate('Example', 1024, 780, -1, -1)
$oIE[0] = _IECreateEmbedded() ;Main IE window
$oIE[1] = _IECreateEmbedded() ;Secondary for loading display
$GUIActiveX[0] = GUICtrlCreateObj($oIE[0], 1, 1, 1023, 779)
$GUIActiveX[1] = GUICtrlCreateObj($oIE[1], 1, 1, 1023, 779)
GUICtrlSetState($GUIActiveX[1], $GUI_HIDE) ; Hide secondary window, so user can interact with first one
_IENavigate($oIE[0], $Site)
_IENavigate($oIE[1], 'about:blank')
GUISetState(@SW_SHOW)

$SearchKeys = InputBox('', '', '')

Loading(1) ;Loading "screen" on

If $SearchKeys <> '' Then
    $Chars = Round(StringLen($SearchKeys)/2)
    _IENavigate($oIE[0], $Site & $Search & StringRegExpReplace($SearchKeys, '\s', '+'))
    $oLinks = _IELinkGetCollection($oIE[0])
    $iNumLinks = @extended
    Dim $Links[$iNumLinks]
    $Limk = 0
    For $oLink In $oLinks
        If StringInStr($oLink.outertext, StringLeft($SearchKeys, $Chars)) Then
            $Links[$Limk] = $oLink.href
            $Limk += 1
        EndIf
    Next
    If $Chars <= 1 Then
        _IENavigate($oIE[0], $Links[1])
    Else
        _IENavigate($oIE[0], $Links[0])
    EndIf
EndIf

Loading(0) ;Loading "screen" off

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Loading($State)
    If $State = 1 Then
        GUICtrlSetState($GUIActiveX[0], $GUI_HIDE) ;Hide first window where all stuff is running
        GUICtrlSetState($GUIActiveX[1], $GUI_SHOW) ;Loading "screen" now visible
        _IEDocWriteHTML($oIE[1], $BodyStyle & $ImgCentering & $LoadingImg & $ImgCenteringE) ;Loading animated gif (or any stuff can be there)
        _IELoadWait($oIE[1], 100)
    Else
        _IENavigate($oIE[1], 'about:blank')
        GUICtrlSetState($GUIActiveX[1], $GUI_HIDE)
        GUICtrlSetState($GUIActiveX[0], $GUI_SHOW)
    EndIf
EndFunc
  • Like 1

Share this post


Link to post
Share on other sites
Anne

 

Something like this?  :)

#Include <IE.au3>
#include <GUIConstantsEx.au3>

Global $oIE[2], $GUIActiveX[2]
Global $BodyStyle = '<body style="margin-top: auto; border: 0px; overflow: hidden;">'
Global $LoadingImg = '<img src="http://www.shipco.com/include/images/shipco/loading1.gif">' ;Loading gif from google images
Global $ImgCentering = '<table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%"><tr><td align="center" valign="middle">'
Global $ImgCenteringE = '</td></tr></table>'
Global $Site = 'http://www.google.com/', $Search = 'search?q=', $SearchKeys

$GUI = GUICreate('Example', 1024, 780, -1, -1)
$oIE[0] = _IECreateEmbedded() ;Main IE window
$oIE[1] = _IECreateEmbedded() ;Secondary for loading display
$GUIActiveX[0] = GUICtrlCreateObj($oIE[0], 1, 1, 1023, 779)
$GUIActiveX[1] = GUICtrlCreateObj($oIE[1], 1, 1, 1023, 779)
GUICtrlSetState($GUIActiveX[1], $GUI_HIDE) ; Hide secondary window, so user can interact with first one
_IENavigate($oIE[0], $Site)
_IENavigate($oIE[1], 'about:blank')
GUISetState(@SW_SHOW)

$SearchKeys = InputBox('', '', '')

Loading(1) ;Loading "screen" on

If $SearchKeys <> '' Then
    $Chars = Round(StringLen($SearchKeys)/2)
    _IENavigate($oIE[0], $Site & $Search & StringRegExpReplace($SearchKeys, '\s', '+'))
    $oLinks = _IELinkGetCollection($oIE[0])
    $iNumLinks = @extended
    Dim $Links[$iNumLinks]
    $Limk = 0
    For $oLink In $oLinks
        If StringInStr($oLink.outertext, StringLeft($SearchKeys, $Chars)) Then
            $Links[$Limk] = $oLink.href
            $Limk += 1
        EndIf
    Next
    If $Chars <= 1 Then
        _IENavigate($oIE[0], $Links[1])
    Else
        _IENavigate($oIE[0], $Links[0])
    EndIf
EndIf

Loading(0) ;Loading "screen" off

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Loading($State)
    If $State = 1 Then
        GUICtrlSetState($GUIActiveX[0], $GUI_HIDE) ;Hide first window where all stuff is running
        GUICtrlSetState($GUIActiveX[1], $GUI_SHOW) ;Loading "screen" now visible
        _IEDocWriteHTML($oIE[1], $BodyStyle & $ImgCentering & $LoadingImg & $ImgCenteringE) ;Loading animated gif (or any stuff can be there)
        _IELoadWait($oIE[1], 100)
    Else
        _IENavigate($oIE[1], 'about:blank')
        GUICtrlSetState($GUIActiveX[1], $GUI_HIDE)
        GUICtrlSetState($GUIActiveX[0], $GUI_SHOW)
    EndIf
EndFunc

Thank you very much! This was exactly what I was looking for :)

Share this post


Link to post
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
Sign in to follow this  

×