On Sat Sep 28 20:51:02 2024 +0000, Paul Gofman wrote:
Maybe I could use that TID from server only when hwnd for set_active_window() is NULL, to leave the logic intact when set_active_window() is used SetFocus or SetActiveWindow.
I see. What about getting the tid from the window in set_foreground_window, and passing it to set_active_window instead? I think it could otherwise happen that the tid of the foreground window you later get does not match anymore the foreground window at the time of the original call. It might, or might not be an issue and I don't know what behavior Windows has here, but it seems like the correct thing to do if we consider SetForegroundWindow operation as a whole.