rdellis Posted September 8, 2011 Posted September 8, 2011 I have a IE browser embedded in a windows application. I can't get the following IEAttach script to work, it returns an error code 7. $handle = WinActivate("MyAppTitle") $oIE = _IEAttach("MyAppTitle", "embedded", 1) This also fails: $handle= ControlGetHandle("MyAppTitle", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") If I manually place in the Control handle id, the following works great, but the handle is always changing. $oIE = __IEControlGetObjFromHWND("0x000805C6") Surprisingly if I place a msgbox in the code and remove the IEAttach title, IEAttach will work most of the time. Leaving the title in the IEAttach will return an error code of 7. $handle = WinActivate("MyAppTitle") MsgBox(0,"Handle",$handle) $oIE = _IEAttach("", "embedded", 1) I need to be able to attach to the embedded IE browser consistantly without using a msgbox.
PsaltyDS Posted September 11, 2011 Posted September 11, 2011 Since you have the handle of the parent window, use it: $hWin = WinActivate("MyAppTitle") If $hWin Then $oIE = _IEAttach($hWin, "embedded", 1) Else MsgBox(16, "Error", "Window not found.") Exit EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
rdellis Posted September 12, 2011 Author Posted September 12, 2011 $hWin = WinActivate("MyAppTitle")If $hWin Then $oIE = _IEAttach($hWin, "embedded", 1)Else MsgBox(16, "Error", "Window not found.") ExitEndIf In your example I get back a good handle from WinActivate, but _IEAttach throws an error code of 7 ("No Match"). $oIE = _IEAttach($hWin, "embedded", 1) ;does not work - error code of 7 ("No Match"). $oIE = _IEAttach("MyAppTitle", "embedded", 1) ;does not work - error code of 7 ("No Match"). MsgBox(0,"Error","test")$oIE = _IEAttach("", "embedded", 1) ;this works, but left with msgbox
DaleHohm Posted October 17, 2011 Posted October 17, 2011 (edited) I don't understand why your MsgBox call would have any bearing... do you? Does the AutoIt Window Info tool shed any light? Dale Edited October 17, 2011 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
Vishal85 Posted October 17, 2011 Posted October 17, 2011 Check if there is a frame on top of it. if yes then use _IEFrameGetObjByName before attaching the embedded window.
rdellis Posted October 18, 2011 Author Posted October 18, 2011 Dale, I don't understand why the msgbox would allow the IEAttach function to work most of the time. But without it I can not attach to the embedded IE page unless I use the IE page handle. I have used the AutoIT window info tool to get the handle and everything works great when I reference the IE page by handle. But I have not figured out how to get the handle of the embedded IE page programmatically. I used the AutoIT window info tool to get the IE page CLASS to try: $handle= ControlGetHandle("MyAppTitle", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") No success here. I have explored the AutoIT window info tool looking for anything I could use and tried several option, but came up with nothing. Anything else I should try with the AutoIT window info tool?
DaleHohm Posted October 19, 2011 Posted October 19, 2011 The only thing that makes sense to me as t wy the MsgBox would affect anything is that yu have timing issue. Try puting your attach logic in a retry loop with a delay and see if ieventually works. Ifi does, you can look at more surgical methods of sensing when the object is available. 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
rdellis Posted October 19, 2011 Author Posted October 19, 2011 Dale, placing the code in a timing loop did not help. Except for another bizzare occurrence. I noticed if I minimized the AutoIT Info Window while in the timing loop, the IEAttach would work. I tried the same thing with task manager and got the same positive results. It now appears the IEAttach embedded will only work if the window is active. This should active the window:WinActivate("MyAppTitle") and this should confirm the window is active:WinActive("MyAppTitle") Although both come back successful, the window is not active. Clicking on the application window during the timing loop will also bring back a successful IEAttach. This explains the msgbox working. After clicking OK on the message box, the application window gets focus. Why the application is not getting focus after the WinActivate("MyAppTitle") command is confusing me and why WinActive reports that the application has focus when it doesn't. Here is my code: AutoItSetOption("WinTitleMatchMode",1)$hwnd=WinActivate($MyAppTitle)If $hwnd=0 Then MsgBox(16,"Error","Error activating window") ExitEndIfIf WinActive($MyAppTitle)=0 Then MsgBox(16, "Error", "Window not active") ExitEndIfOpt("SendKeyDelay",250)Send("{F10}")For $i = 1 to 30 Sleep(250) $oIE=_IEAttach("","embedded",1) If @error=0 Then ExitLoop EndIfNextIf @error>0 Then MsgBox(16,"Error","Error ("&@error&") connecting to embedded IE window.") ExitEndIf
rdellis Posted October 19, 2011 Author Posted October 19, 2011 AutoItSetOption("WinTitleMatchMode",3) appears to fix my window focus problem. Match mode 1 & 2 would not leave the window active. Still seems strange the following statement does not work: $oIE=_IEAttach($MyAppTitle,"embedded",1) I have to use: $oIE=_IEAttach("","embedded",1) Dale, thanks for your help.
DaleHohm Posted October 19, 2011 Posted October 19, 2011 Does the window title change when it has focus? 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
rdellis Posted October 20, 2011 Author Posted October 20, 2011 No. Apparently there is a component within the application with the title $MyAppTitle & " Message Window". WinActivate, WinActive, and IEAttach were apparently all attaching to this internal app component and not the main application. Whenever a msgbox was dispatched, the main application window got focus and not the component within the application and things would work. AutoItSetOption("WinTitleMatchMode",3) allows an exact match on $MyAppTitle, thus solving the problem of connecting to $MyAppTitle & " Message Window". $oIE=_IEAttach("","embedded",1) is now working, but if for whatever reason my application is not the active window this command will fail. $oIE=_IEAttach($MyAppTitle,"embedded",1) would certainly be better.
DaleHohm Posted October 20, 2011 Posted October 20, 2011 I'm afraid I'd need a reproducer to help further. 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now