Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some times windows have \u200b in title make it not searchable #54

Open
cornradio opened this issue Dec 10, 2023 · 2 comments
Open

some times windows have \u200b in title make it not searchable #54

cornradio opened this issue Dec 10, 2023 · 2 comments

Comments

@cornradio
Copy link

can we have a filter version of _getAllTitles ,that remove all \u200b?
some time when i search about "Microsoft Edge"

there is an edge but have a wired \u200b in it , thus can't get the window!
like this :
"xxx - Microsoft\u200b Edge"

some related functions 👇

def _getAllTitles():
    # This code taken from https://sjohannes.wordpress.com/2012/03/23/win32-python-getting-all-window-titles/
    # A correction to this code (for enumWindowsProc) is here: http://makble.com/the-story-of-lpclong
    titles = []
    def foreach_window(hWnd, lParam):
        if isWindowVisible(hWnd):
            length = getWindowTextLength(hWnd)
            buff = ctypes.create_unicode_buffer(length + 1)
            getWindowText(hWnd, buff, length + 1)
            titles.append((hWnd, buff.value))
        return True
    enumWindows(enumWindowsProc(foreach_window), 0)

    return titles
def getWindowsWithTitle(title):
    """Returns a list of Window objects that substring match ``title`` in their title text."""
    hWndsAndTitles = _getAllTitles()
    windowObjs = []
    for hWnd, winTitle in hWndsAndTitles:
        if title.upper() in winTitle.upper(): # do a case-insensitive match
            windowObjs.append(Win32Window(hWnd))
    return windowObjs
@cornradio
Copy link
Author

i got a work around but not so sure >.. wil it work?

def getWindowsWithTitleFiltered(title,filtstr):
    """Returns a list of Window objects that substring match ``title`` in their title text.
    filtstr = \u200b etc.
    """
    hWndsAndTitles = _getAllTitles()
    windowObjs = []
    for hWnd, winTitle in hWndsAndTitles:
        winTitle = winTitle.replace(filtstr,'')
        if title.upper() in winTitle.upper(): # do a case-insensitive match
            windowObjs.append(Win32Window(hWnd))
    return windowObjs

@Jelte2357
Copy link

This is a problem with edge putting this in their title, not a problem of the program, and should therefore be handled by the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants