Jump to content

Problems with IE emdebbded


Recommended Posts

Hello, (sorry form my English, its not my native language)

I made an interface to access a web-based database with some enhancements using an embedded IE. I have some problems with the message boxes from IE like when he asks a confirmation to send data trough network or when he asks to activate auto-complete function. These message boxes are hidden and if you dont answer the question, you cant go further.

Can you help me to make these message boxes visible? I think its something to do with _IEAttach, but I dont understand how to use this function.

Thanks.

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.1.1.0

Author: Sébastien Adam DTSC-KWS

Script Function:

Interface Intranet.

#ce ----------------------------------------------------------------------------

#include <File.au3>

#include <GUIConstants.au3>

#include <IE.au3>

#Include <process.au3>

TraySetState(2)

_IEErrorHandlerRegister ()

;Variables

If $CmdLine[0] = 1 Then

$file_ini = $CmdLine[1]

Else

$file_ini = @ScriptDir & "\config.ini"

EndIf

$url_home = IniRead($file_ini, "Main", "url", "http://10.5.55.9/index.php?p=home")

$url_login = IniRead($file_ini, "Main", "login", "http://10.5.55.9/auth_admin.php?a=login&ulogin=_user_&password=_passwd_")

$url_logout = IniRead($file_ini, "Main", "logout", "http://10.5.55.9/auth_admin.php?a=logout")

$app_title = "Intranet KWS - © Sébastien Adam - Version 1.2.2 20061212 Experimental"

$MWwidth = @DesktopWidth*0.8

$MWheight = @DesktopHeight*0.8

; Identification

GUICreate("Login", 205,70, -1,-1,-1)

GUICtrlCreateLabel("Username:",5,5)

$uname = GUICtrlCreateInput ( "", 80, 2,120,20)

GUICtrlCreateLabel("Password:",5,25)

$passwd = GUICtrlCreateInput ( "", 80, 22,120,20,$ES_PASSWORD)

$btn_ok = GUICtrlCreateButton("Ok", 40,45,60,20,$BS_DEFPUSHBUTTON)

$btn_cancel = GUICtrlCreateButton("Cancel", 105,45,60,20)

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $btn_ok

$url_login = StringReplace($url_login, "_user_", GUICtrlRead($uname))

$url_login = StringReplace($url_login, "_passwd_", GUICtrlRead($passwd))

ExitLoop

Case $msg = $btn_cancel Or $msg = $GUI_EVENT_CLOSE

GUIDelete()

Exit

EndSelect

WEnd

GUIDelete()

$msg = 0

;Configuration IE

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 0)

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", "REG_DWORD", 0)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "DisablePasswordCaching", "REG_DWORD", 1)

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "DisablePasswordCaching", "REG_DWORD", 1)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache", "Persistent", "REG_DWORD", 0)

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache", "Persistent", "REG_DWORD", 0)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete", "Append Completion", "REG_SZ", "no")

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoComplete", "Append Completion", "REG_SZ", "no")

; Création interface

$oIE = _IECreateEmbedded()

GUICreate($app_title, $MWwidth, $MWheight, -1, -1, $WS_CAPTION)

GUISetBkColor(0xFFFFFF)

$GUIActiveX = GUICtrlCreateObj($oIE, 10, 45, $MWwidth-20, $MWheight-55)

$i = 10

$GUI_Button_Back = GUICtrlCreateButton("Back", $i, 5, 80, 30)

$i += 85

$GUI_Button_Forward = GUICtrlCreateButton("Forward", $i, 5, 80, 30)

$i += 85

$GUI_Button_Refresh = GUICtrlCreateButton("Refresh", $i, 5, 80, 30)

$i += 85

$GUI_Button_Home = GUICtrlCreateButton("Home", $i, 5, 80, 30)

$i += 85

$GUI_Button_Stop = GUICtrlCreateButton("Stop", $i, 5, 80, 30)

$i += 85

$GUI_Button_Print = GUICtrlCreateButton("Print", $i, 5, 80, 30)

$i += 85

$GUI_Button_Invent = GUICtrlCreateButton("Invent", $i, 5, 80, 30)

$i += 85

$GUI_Button_Exit = GUICtrlCreateButton("Exit", $i, 5, 80, 30)

GUISetState() ;Show GUI

_IEAttach("","Embedded")

_IENavigate ($oIE, $url_login)

; Waiting for user to close the window

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_Button_Exit

ExitLoop

Case $msg = $GUI_Button_Invent

; some statments

Case $msg = $GUI_Button_Print

_IELinkClickByText($oIE, "Print Friendly")

_IEAction ($oIE, "print")

Case $msg = $GUI_Button_Portal

If FileExists($path_portal) Then

Run($path_portal, _BaseDir($path_portal))

EndIf

Case $msg = $GUI_Button_Home

_IENavigate ($oIE, $url_home)

Case $msg = $GUI_Button_Refresh

_IEAction ($oIE, "refresh")

Case $msg = $GUI_Button_Back

_IEAction ($oIE, "back")

Case $msg = $GUI_Button_Forward

_IEAction ($oIE, "forward")

Case $msg = $GUI_Button_Stop

_IEAction ($oIE, "stop")

EndSelect

WEnd

_IENavigate($oIE, $url_logout)

GUIDelete()

Exit

;- Fonctions -----------------------------------------------------------------;

Func _BaseDir($path)

$idx = StringInStr($path, "\", 0, -1)

If $idx <= 0 Then

Return "Error"

Else

Return StringLeft($path, $idx)

EndIf

EndFunc

Link to comment
Share on other sites

Have you tried WinSetState?

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Can you describe more about these windows? Try using the AutoIt WinInfo tool to see whether they are HTML windows or win32 windows (they are HTML is there is a single control insire called "Internet Explorer_Server1"). The HTML popups can be attached to with _IEAttach(..., "popup") and the win32 with standard AutoIt Win* functions.

Dale

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

Can you describe more about these windows? Try using the AutoIt WinInfo tool to see whether they are HTML windows or win32 windows (they are HTML is there is a single control insire called "Internet Explorer_Server1"). The HTML popups can be attached to with _IEAttach(..., "popup") and the win32 with standard AutoIt Win* functions.

Dale

I'd like to catch this kind of message boxes (especially the 2 firsts):

Posted Image Posted Image

Posted Image Posted Image

and with I don't understand how I can do that.

I've tried with WinSetState, but without success...

Link to comment
Share on other sites

Can you post the information from the AutoIt WinInfo tool, as well as the code you have tried?

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Can you post the information from the AutoIt WinInfo tool, as well as the code you have tried?

I made some screen capture of message boxes from IE with the corresponding informations from AutoIt window.

I seen that the class or the windows is the same for all message boxes. So I tried to catch these boxes, but without success. I can catch boxes from other instance of IE but not these from the embedded IE.

Here is the code of my test script:

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.1.1.0

Author: Sébastien Adam - sebastien.adam@advalvas.be

Script Function:

Interface Intranet.

#ce ----------------------------------------------------------------------------

#include <GUIConstants.au3>

#include <IE.au3>

_IEErrorHandlerRegister ()

;Variables

$url_home = "http://www.sebastienadam.be"

$url_autoit = "http://www.autoitscript.com"

$url_google = "http://www.google.com"

$app_title = "IE Embedded test"

$MWwidth = @DesktopWidth*0.8

$MWheight = @DesktopHeight*0.8

; Création interface

$oIE = _IECreateEmbedded()

GUICreate($app_title, $MWwidth, $MWheight, -1, -1, $WS_CAPTION)

GUISetBkColor(0xFFFFFF)

$GUIActiveX = GUICtrlCreateObj($oIE, 10, 45, $MWwidth-20, $MWheight-55)

$i = 10

$GUI_Button_Back = GUICtrlCreateButton("Back", $i, 5, 80, 30)

$i += 85

$GUI_Button_Forward = GUICtrlCreateButton("Forward", $i, 5, 80, 30)

$i += 85

$GUI_Button_Refresh = GUICtrlCreateButton("Refresh", $i, 5, 80, 30)

$i += 85

$GUI_Button_Home = GUICtrlCreateButton("Home", $i, 5, 80, 30)

$i += 85

$GUI_Button_Stop = GUICtrlCreateButton("Stop", $i, 5, 80, 30)

$i += 85

$GUI_Button_Print = GUICtrlCreateButton("Print", $i, 5, 80, 30)

$i += 85

$GUI_Button_Autoit = GUICtrlCreateButton("Autoit", $i, 5, 80, 30)

$i += 85

$GUI_Button_Google = GUICtrlCreateButton("Google", $i, 5, 80, 30)

$i += 85

$GUI_Button_Exit = GUICtrlCreateButton("Exit", $i, 5, 80, 30)

GUISetState() ;Show GUI

_IEAttach("","Embedded")

_IENavigate ($oIE, $url_home)

; Traitement des boutons

$msg = 0

;Opt("WinSearchChildren", 1)

Opt("WinTitleMatchMode", 4)

While 1

$var = WinList("classname=#32770")

For $i = 1 to $var[0][0]

MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])

Next

$msg = GUIGetMsg()

Select

Case $msg = $GUI_Button_Exit

ExitLoop

Case $msg = $GUI_Button_Print

_IEAction ($oIE, "print")

Case $msg = $GUI_Button_Home

_IENavigate ($oIE, $url_home)

Case $msg = $GUI_Button_Autoit

_IENavigate ($oIE, $url_autoit)

Case $msg = $GUI_Button_Google

_IENavigate ($oIE, $url_google)

Case $msg = $GUI_Button_Refresh

_IEAction ($oIE, "refresh")

Case $msg = $GUI_Button_Back

_IEAction ($oIE, "back")

Case $msg = $GUI_Button_Forward

_IEAction ($oIE, "forward")

Case $msg = $GUI_Button_Stop

_IEAction ($oIE, "stop")

EndSelect

WEnd

GUIDelete()

Exit

Here is the capture of the message box you receive when you send data on the network (like when you do a search in google) with the corresponding informations from AutoIt Window:

http://www.sebastienadam.be/download/send_data.pdf

Here is the capture of the message box you receive when you send password on the network (like when you log you into AutoIt forum) with the corresponding informations from AutoIt Window:

http://www.sebastienadam.be/download/send_passwd.pdf

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