Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/pygetwindow/_pygetwindow_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,24 @@ def getWindowsAt(x, y):
return windowsAtXY


def getWindowsWithTitle(title):
"""Returns a list of Window objects that substring match ``title`` in their title text."""
def getWindowsWithTitle(title, equal_or_in='in'):
"""Returns a list of Window objects that substring match ``title`` in their title text.

* ``title`` (str, required): The title of the window(s).
* ``equal_or_in`` (str, optional): Exactly match or in the window(s) 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))
if equal_or_in == 'in':
if title.upper() in winTitle.upper(): # do a case-insensitive match
windowObjs.append(Win32Window(hWnd))
elif equal_or_in == '=':
if title.upper() == winTitle.upper(): # do a case-insensitive match
windowObjs.append(Win32Window(hWnd))
else:
raise PyGetWindowException(("Error code: getWindowsWithTitle(title, equal_or_in='in')"
" equal_or_in shuould in ['in', '=']"))
return windowObjs


Expand Down