bladeSk / StayFocused

Prevents focus stealing on Windows
https://blade.sk/stay-focused/
MIT License
75 stars 8 forks source link

Not working with simple steal focus hack #11

Open Mudr0x opened 2 years ago

Mudr0x commented 2 years ago

Hello, Thanks first for this interesting and useful project. I tested it on Win10 with a test tool I made with the simple well-known steal focus hack working with such thread injection:

DWORD windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), LPDWORD(0)); DWORD currentThreadId = GetCurrentThreadId(); AttachThreadInput(windowThreadProcessId, currentThreadId, true); BringWindowToTop(bhWnd); ShowWindow(bhWnd, SW_SHOWNORMAL); AttachThreadInput(windowThreadProcessId, currentThreadId, false);

I also tested with SetForegroundWindow instead of BringWindowToTop, and it isn't able to keep focus. :(

Here's my tool you can test with: BlinkingWindow.zip

bladeSk commented 2 years ago

Thanks for making a proper working test case with a tool. Not sure if I understand what it's doing - does it temporarily take input processing and call BringWindowToTop from its own thread? In which case, wouldn't hooking the tool prevent focus stealing?

Regardless, I've since moved to KDE on Linux, which has focus stealing prevention built-in (and many other nifty features I had to hack into windows), so unfortunately I'm not actively developing Stay Focused at the moment.

Mudr0x commented 2 years ago

The tool simulates an app polluting system with its popup windows, e.g. even when it is not the activated app its own test window is bring back and front periodically (blinking) and stealing focus from other apps or processes having focus. When I test StayFocused (SF) with my test tool, my tool succeeds to steal focus to SF when SF is the activated app.

From: Matúš @.> Sent: Monday, October 10, 2022 4:49 PM To: @.> Cc: @.>; @.> Subject: Re: [bladeSk/StayFocused] Not working with simple steal focus hack (Issue #11)

Thanks for making a proper working test case with a tool. Not sure if I understand what it's doing - does it temporarily take input processing and call BringWindowToTop from its own thread? In which case, wouldn't hooking the tool prevent focus stealing?

Regardless, I've since moved to KDE on Linux, which has focus stealing prevention built-in (and many other nifty features I had to hack into windows), so unfortunately I'm not actively developing Stay Focused at the moment.

— Reply to this email directly, view it on GitHubhttps://github.com/bladeSk/StayFocused/issues/11#issuecomment-1273433180, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AS2RSZ2ZG3QMCGQKG4RNZDDWCQUHXANCNFSM6AAAAAARBMT5KY. You are receiving this because you authored the thread.Message ID: @.***>