Author Topic: [BUG] SetWinEventHook and different desktops  (Read 1212 times)


  • Administrator
  • Hero Member
  • *****
  • Posts: 1526
[BUG] SetWinEventHook and different desktops
« on: September 16, 2017, 12:42:49 pm »
SetWinEventHook looks great for many purposes, it notifies you about lots of windows events, doesn't need any DLL like hooks and looks nice and simple... until you try to use it with several desktops (I don't mean ReHIPS isolated desktops here, any desktops, e.g. Desktops program from former Sysinternals creates several desktops). With several desktops and switching between them, this function starts acting weird, it reports window is shown and later that window is created, though MSDN says
events are guaranteed to be in sequential order
Foreground window reporting is also wrong, maybe some messages linger when another desktop is switched to and they're delivered later, I don't know as I haven't dug into this issue deeply. If someone can clarify it, I'd really appreciate it. EVENT_OBJECT_HIDE event also seems to notify about windows, while MSDN says
The system sends this event for the following user interface elements: caret and cursor

So maybe this function works great with a single desktop, but for multi-desktops program I'd keep away from it or at least made some workarounds to counter these issues.

It was found just a couple of weeks ago, but I suspect this bug to be there for quite a long time. So I don't think it'll be fixed soon.