Sign in to follow this  
Followers 0
rmk08c

WinExists and _IEAttach but cant _IEGetObjByName

2 posts in this topic

#1 ·  Posted

Hi all, this is my second post.

I am writing a script to query an IE website's search box automatically. I have one window with 7 tabs, using the same code, opened the same way, and it works. However, the window with only 1 tab gives me an error when trying to attach.

There are only two differences. First, I use WinMatchMode 3 because I have two similarly titled windows open (FlyingMachine - theflyonthewall.com - Internet Explorer, and theflyonthewall.com - Internet Explorer). Second, I use _IEGetObjByName instead of ID because of the pages HTML. I dont know HTML, so just doing my best there.

I have MsgBox in code for debug only. In the SCiTE output window, I get a warning when trying to attach that $_IESTATUS_NoMatch. Then I get an error when trying to _IEGetObjByName that $_IESTATUS_InvalidDataType. Any help is greatly appreciated. Windows 7, IE11.

Code giving me issues:

Func FlyOTW ()
   ClipPut("")
   ClipPut(ControlGetText("Montage - ", "", $MontageSymbolEdit))

   Opt("WinTitleMatchMode", 3)

   If WinExists("theflyonthewall.com - Internet Explorer") Then
msgbox(0, "Fly Search Exists", "")
      $FlyBrowser = _IEAttach("theflyonthewall.com - Internet Explorer", "title")
msgbox(0, "Attached", "")
      $searchField = _IEGetObjByName($FlyBrowser, "symbol")
      _IEFormElementSetValue($searchField, ClipGet())
msgbox(0, "Populate search field", "")
      Sleep(50)
      Send("{ENTER}")
msgbox(0, "submit search", "")
   EndIf

   Opt("WinTitleMatchMode", 2)
EndFunc

Code that works:

ClipPut("")
   ClipPut(ControlGetText("Montage - ", "", $MontageSymbolEdit))

   Opt("WinTitleMatchMode", 2)

   If WinExists("CEF Connect") Then
      $CEFBrowser = _IEAttach("CEF Connect")
      $searchField = _IEGetObjByID($CEFBrowser, "quick-search-input-primary")
      _IEFormElementSetValue($searchField, ClipGet())
      Sleep(10)
      Send("{ENTER}")
   EndIf

HTML of object, found using "inspect element" tool on IE:

<input name="symbol" onfocus="if (onLoadDone == true) {this.value=''; } else { onLoadDone = true; }" type="text" size="15" value="veev">

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Most likely this line fails right?

$FlyBrowser = _IEAttach("theflyonthewall.com - Internet Explorer", "title")

You will see warnings at the Scite output. Try to attach using "URL" or using this technique:

Local $i = 1
    While 1
        $oIE = _IEAttach("", "instance", $i)
        If @error = $_IEStatus_NoMatch Then
            $oIE = 0
            ExitLoop
        EndIf
        $i += 1
    WEnd

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0