Servant Posted August 1, 2013 Share Posted August 1, 2013 In this script below, I'm trying to: Create an Internet Explorer, and to navigate it to a blank page. Create a new tab with a blank page. Create another tab again. (Please don't ask me why 'cause it's just a test.) Get all the 3 object variables pointing to those 3 InternetExplorer Objects. And to test to select the tab two, then to select the tab one which is fail! #include <IE.au3> $oIE = _IECreate("about:blank", 0, 1, 1, 1) __IENavigate($oIE, "about:blank", 0, 0x800) __IENavigate($oIE, "about:blank", 0, 0x800) Local $oTabs[1] Local $i = 1 While 1 $oTabs[$i - 1] = _IEAttach($oIE, "instance", $i) If @Error = $_IEStatus_NoMatch Then ReDim $oTabs[$i - 1] ExitLoop EndIf ReDim $oTabs[$i + 1] $i += 1 WEnd Sleep(3000) _IEAction($oTabs[1], "focus") Sleep(3000) _IEAction($oTabs[0], "focus") Could you please tell me how to fix that AU3 code to select and not to WinActivate() the tab because as far as I know, activating tab will make this tab at the front of the your Windows screen which I do not want because I want to automate the IE even I'm working on a different application. Now, this is my second question! How can I get the current selected tab on a web browser, specially in Internet Explorer, even I'm in another application to read that tab's text using the _IEBodyReadText() libfunction? Thanks for any help! http://developingsites.blogspot.com Link to comment Share on other sites More sharing options...
Danp2 Posted August 1, 2013 Share Posted August 1, 2013 This is how I get the IE object for the currently active tab: ;=============================================================================== ; ; Function Name: _IEGetActiveTab() ; Description: Retrieve the IE Window Object of the currently active tab ; Parameter(s): None ; Requirement(s): AutoIt3 V3.2 or higher ; On Success - Returns an object variable pointing to the IE Window Object ; On Failure - Returns 0 and sets @ERROR ; @ERROR - 0 ($_IEStatus_Success) = No Error ; - 7 ($_IEStatus_NoMatch) = No Match ; Author(s): Dan Pollak ;=============================================================================== ; Func _IEGetActiveTab() Local $hwnd, $i, $title, $oIE ; get first IE instance $oIE = _IEAttach ("", "instance", 1) If @error = $_IEStatus_Success Then ; get window title $hwnd = _IEPropertyGet($oIE, "hwnd") $title = WinGetTitle($hwnd) $oIE = _IEAttach($title, "windowtitle") EndIf Return $oIE EndFunc Servant and Ebola57 2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted August 1, 2013 Share Posted August 1, 2013 On your initial question, I believe the issue is that "focus" is meant to be used with an element, not the actual IE object. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
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