asweigart / asweigart/PyGetWindow

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

Open
#54 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
422
Forks
73
PR merge metrics
No merged PRs in 30d

Description

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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.