From ad721940909ba5aa56dbc06af3859bcbb3ec0e87 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Fri, 23 Dec 2016 02:15:59 -0800 Subject: [PATCH] win-capture: Do not add certain windows to window lists Due to using FindWindowEx to search for certain windows, certain windows will show up that aren't usable/capturable. Prevent these windows from showing up in the window lists. --- plugins/win-capture/window-helpers.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugins/win-capture/window-helpers.c b/plugins/win-capture/window-helpers.c index 09d6554c4..c5bf3657c 100644 --- a/plugins/win-capture/window-helpers.c +++ b/plugins/win-capture/window-helpers.c @@ -128,6 +128,33 @@ void get_window_class(struct dstr *class, HWND hwnd) dstr_from_wcs(class, temp); } +/* not capturable or internal windows */ +static const char *internal_microsoft_exes[] = { + "applicationframehost", + "shellexperiencehost", + "winstore.app", + "searchui", + NULL +}; + +static bool is_microsoft_internal_window_exe(const char *exe) +{ + char cur_exe[MAX_PATH]; + + if (!exe) + return false; + + for (const char **vals = internal_microsoft_exes; *vals; vals++) { + strcpy(cur_exe, *vals); + strcat(cur_exe, ".exe"); + + if (strcmpi(cur_exe, exe) == 0) + return true; + } + + return false; +} + static void add_window(obs_property_t *p, HWND hwnd, add_window_cb callback) { struct dstr class = {0}; @@ -138,6 +165,10 @@ static void add_window(obs_property_t *p, HWND hwnd, add_window_cb callback) if (!get_window_exe(&exe, hwnd)) return; + if (is_microsoft_internal_window_exe(exe.array)) { + dstr_free(&exe); + return; + } get_window_title(&title, hwnd); get_window_class(&class, hwnd);