karlkar Posted November 26, 2013 Posted November 26, 2013 Hello. I have a user that has Windows 7 x64 and uses IE9. I have a code where I open one website using _IECreate() then I click there one link. It opens n new window, so I call _IEAttach() on it using part of it's url. On my PC it works fine. On PC of my user script cannot attach to the window. Take a look at this sample code: $oIE1 = _IECreate("www.address.com") Local $links = $oIE1.document.getElementsByTagName("a") For $link In $links BlockInput(1) Send("{CTRLDOWN}") Sleep(200) $link.click() Send("{CTRLUP}") BlockInput(0) $downloaderIE = _IEAttach("openDownloadManager.do", "url") $tries = 0 While $downloaderIE = 0 And $tries < 10 writeLog("Waiting for downloader to appear.") Sleep(500) $downloaderIE = _IEAttach("openDownloadManager.do", "url") $tries += 1 WEnd If $downloaderIE <> 0 Then MsgBox(8192, "Status", "Success! " & $tries) Else MsgBox(8192, "Status", "FAILED!") Exit EndIf Next This code works on my PC, doesn't work at users PC. However if I will change _IEAttach("openDownloadManager.do", "url") to WinGetHandle ( "[Class:IEFrame]", "openDownloadManager.do" ) Handle is obtained. Do you know why? I've used au3Info to get information about window that I am interested about. It's what it returned: expandcollapse popup>>>> Window <<<< Title: PLM - Windows Internet Explorer Class: IEFrame Position: 358, 383 Size: 526, 375 Style: 0x16CA0000 ExStyle: 0x00000100 Handle: 0x00010CD0 >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 589, 402 Cursor ID: 0 Color: 0xF1F9F9 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< PLM - Windows Internet Explorer >>>> Hidden Text <<<< Navigation Bar http://www.address.com/wl/doc/workspace/openDownloadManager.do Address Combo Control Page Control Do you know what can be wrong? And maybe you know a better way to open a link in new window than BlockInput(1) Send("{CTRLDOWN}") Sleep(200) $link.click() Send("{CTRLUP}") BlockInput(0) ? It's a javascript link, so I cannot use _IECreate to do it.
JohnOne Posted November 26, 2013 Posted November 26, 2013 You answered your first question yourself, get its handle and attach using HWND instead of URL. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
karlkar Posted November 26, 2013 Author Posted November 26, 2013 Yes, I know how to walkaround this problem. But maybe you know what is wrong with ieattach? For comparison this works: _IECreate("google.com") $oIE = _IEAttach("google", "url") If $oIE <> 0 Then MsgBox(0, "", "Success") Endif
BrewManNH Posted November 26, 2013 Posted November 26, 2013 I tried that snippet you posted in #3 and it worked for me, I'm on Win7 IE9. I got the MsgBox after running it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
JohnOne Posted November 26, 2013 Posted November 26, 2013 Yes, I know how to walkaround this problem. But maybe you know what is wrong with ieattach? For comparison this works: One generally finds what is wrong by checking the value of @error after a function call. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
karlkar Posted November 27, 2013 Author Posted November 27, 2013 @error is set to 7 (No Match) When I executed script on PC of user this script (but modified to log urls): #include <IE.au3> Local $aIE[1] $aIE[0] = 0 Local $i = 1 While 1 $oIE = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIE $aIE[0] = $i $i += 1 WEnd MsgBox(0, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) It turned out that the window I am interested in was not attached. So it is not detected as IE instance. Strange, isn't it?
karlkar Posted December 8, 2013 Author Posted December 8, 2013 Now problem changed - I still cannot attach to this one IEFrame using _IEAttach, but since few days, also $hwnd = WinGetHandle ( "[Class:IEFrame]", "openDownloadManager.do" ) returns correct handle that I cannot attach to using _IEAttach($hwnd, "HWND"). I've even tried to wait for 30 seconds after finding a proper handle, in case IE doesn't load the page, but it also fails. I'm not using autoit beta. Tomorrow I'll check if beta will work there, but maybe you have some other ideas?
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