Jump to content

Hide IE windows instead of close.


Recommended Posts

This script could be less complex if I could catch the IEEvent_Quit event and just have it hide the window, but I dont think thats possible so I am doing it this way:

PS: the username and passwords were replaced with "usernamehere" and "passhere" for security. So the script wont work entirely. Also the objects are going to be hidden when created, but for testing I have them visible.

#include <IE.au3>

HotKeySet("{F9}", "INC")
HotKeySet("{F10}", "E")
HotKeySet("{F11}", "FDT")
HotKeySet("{F12}", "SNAP")

ProcessClose ( "iexplore.exe")
Global $oIE, $oINC, $oFDT, $oSNAP, $oETicket
Global $eIE, $eINC, $eFDT, $eSNAP, $eETicket
$oIE = _IECreate ("https://indirect.nextel.com/login.jsp",0,0)
$oForm = _IEFormGetObjByName ($oIE, "Login")
$oUser = _IEFormElementGetObjByName ($oForm, "USER")
$oPassword = _IEFormElementGetObjByName ($oForm, "PASSWORD")
_IEFormElementSetValue ($oUser, "usernamehere")
_IEFormElementSetValue ($oPassword, "passhere")
_IEFormSubmit ($oForm)


CreateObjects()
While 1
    
WEnd



Func CreateObjects()
    sleep(1000)
    If Not ObjName ($oINC) Then
        $eINC = 0
        $oINC = _IECreate ("http://indirect.nextel.com/secured_site/i_main_page.jsp",0,1,0)
        $eINC = ObjEvent($oINC, "IEEvent_", "DWebBrowserEvents")
    EndIf
    If Not ObjName ($oFDT) Then
        $eFDT = 0
        $oFDT = _IECreate ("https://fdtvs.nextel.com/",0,1,1)
        $oForm = _IEFormGetObjByName ($oFDT, "login")
        $oUser = _IEFormElementGetObjByName ($oForm, "username")
        $oPassword = _IEFormElementGetObjByName ($oForm, "password")
        _IEFormElementSetValue ($oUser, "usernamehere")
        _IEFormElementSetValue ($oPassword, "passhere")
        _IEFormSubmit ($oForm, 0)
        $eFDT = ObjEvent($oFDT, "IEEvent_", "DWebBrowserEvents")
    EndIf
EndFunc

Func IEEvent_Quit()
    CreateObjects()
EndFunc


Func INC()
    If _IEPropertyGet($oINC, "readystate") Then
        _IEAction($oINC, "visible")
        WinActivate(_IEPropertyGet($oINC, "hwnd"))
        If _IEPropertyGet($oINC, "locationurl") <> "http://indirect.nextel.com/secured_site/i_main_page.jsp" Then
            _IENavigate($oINC, "http://indirect.nextel.com/secured_site/i_main_page.jsp")
        EndIf
    EndIf
EndFunc



Func FDT()
    If _IEPropertyGet($oFDT, "readystate") Then
        _IEAction($oFDT, "visible")
        WinActivate(_IEPropertyGet($oFDT, "hwnd"))
        If StringInStr(_IEDocReadHTML ($oFDT), "What would you like to do?") == 0 Then
            _IENavigate($oFDT, "java script:doMenuBarNavigation('53')")
        EndIf
    EndIf
EndFunc

Func E()

EndFunc

Func SNAP()
    
EndFunc

My trouble is that when I close out the FDT site and it recreates the object, when it gets done loading it says:

C:\Program Files\AutoIt3\Include\IE.au3 (4233) : ==> Variable must be of type "Object".:

$IEComErrorScriptline = $oIEErrorHandler.scriptline

$IEComErrorScriptline = $oIEErrorHandler^ ERROR

Edited by ParoXsitiC
Link to comment
Share on other sites

Please post step by step instructions on how to reproduce the problem.

Thanks.

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Run the script with F5.

Let the browsers load

Close the browser with the title "Nextel Direct"

Wait for it to recreate the browser

Error shows up after recreating.

PS: Ignore the form errors, because the username/passwords don't work, they dont correctly pick up the right inputs. The only error I am concerned with is:

C:\Program Files\AutoIt3\Include\IE.au3 (4233) : ==> Variable must be of type "Object".:

$IEComErrorScriptline = $oIEErrorHandler.scriptline

$IEComErrorScriptline = $oIEErrorHandler^ ERROR

Link to comment
Share on other sites

OK, this is ugly. It has to do with internal COM error handler logistics. lod3dn gave me some ideas about this some time ago, but they will take some redesign and I was hoping to avoid it.

For now, you can get around the fatal piece of this simply by adding the line _IEErrorHandlerRegister() to your code. You can also prevent a useless COM error message being sent to the console with _IEErrorNotify(False).

I narrowed down your code to the following reproducer (btw, you could have saved me a bit of time if you had simplified your example and gotten rid of the substantial amount of unused code):

#include <IE.au3>

_IEErrorHandlerRegister()
_IEErrorNotify(False)

Global $oFDT, $eFDT

CreateObjects()

While 1
    Sleep(100)
WEnd

Func CreateObjects()
    $eFDT = 0
    $oFDT = 0
    ConsoleWrite("Create Browser" & @CR)
    $oFDT = _IECreate ("www.autoitscript.com")
    $eFDT = ObjEvent($oFDT, "IEEvent_")
EndFunc

Func IEEvent_Quit()
    ConsoleWrite("Processing Quit Event" & @CR)
    CreateObjects()
EndFunc

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...