Skip to content

windows: capture the window of current process#192

Open
flisky wants to merge 3 commits into
nashaofu:masterfrom
flisky:master
Open

windows: capture the window of current process#192
flisky wants to merge 3 commits into
nashaofu:masterfrom
flisky:master

Conversation

@flisky

@flisky flisky commented Feb 13, 2025

Copy link
Copy Markdown

According to webrtc, GetWindowTextW is not always safe to call. However, we call it unconditionally now, but exclude the current process window.

I'm trying to use SendMessageTimeoutW as suggested by https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowtexta#remarks, and 500ms is an arbitrary choosed number (50ms doesn't work sometimes). I can revert it if you prefer the old GetWindowTextW since it works just now.

@nashaofu

Copy link
Copy Markdown
Owner

Will the execution time of this function become longer?

@flisky

flisky commented Feb 21, 2025

Copy link
Copy Markdown
Author

Well, it depends whether the target window handles message in time, and thus it may be much longer than GetWindowText in theory. (We don't concern about performance too much, because it's very occasional called in our system, and it's drivered by human beings.)

I think we can drop the third commit which changes get_window_title implementation, and merge the first two ones. Any suggestions?

@NicolasArnouts

Copy link
Copy Markdown

@nashaofu ping

madcodelife added a commit to madcodelife/xcap that referenced this pull request Mar 24, 2026
- Remove exclusion of current process windows
- Call `get_window_title` lazily to avoid unnecessary work
- Use `SendMessageTimeoutW` (500ms timeout) instead of `GetWindowTextW`
  to prevent potential deadlocks when capturing cross-process windows

Co-Authored-By: Yin Jifeng <jifeng.yin@gmail.com>
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

Successfully merging this pull request may close these issues.

3 participants