Jump to content
Sign in to follow this  

Match title based on substring

Recommended Posts

I can't get _IEAttach to match a title based on a substring. It only works if the substring is at the beginning of the window title.

I tried the solution in a thread by MiMac but I still can't get it to work.

Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

#include <IE.au3>
$oIE=_IEAttach("Internet", "WindowTitle")

I want the code to be able to find any instance of IE open. Since IE has the word Internet in the Title, I thought it would attach but I get an

$_IEStatus_NoMatch error. I'm using AutoIt v3.2.8.1

Share this post

Link to post
Share on other sites

User defined functions don't work the same as internal AutoIt functions. Here is a better way to do it that worked fine for me:

#include <IE.au3>;includes go at the top of scripts
Opt("WinTitleMatchMode",2);1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Dim $hIEWin = WinGetHandle("Internet Explorer");Use Internet Explorer.  A program could have internet in its title and not be internet explorer.
If @error Then
    Msgbox(0,"Error","Window not found.")
Dim $oIE =_IEAttach($hIEWin, "HWND");Specify handle.  You are giving it a handle to attach to.
If @error Then
    Msgbox(0,"Error","Error code number " & @error & ".")
    Msgbox(0,"No Error","It worked fine.")

That works fine for me. That should do it.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...