1

I've written some interop code that utilizes user32.dll to enumerate the windows and add them to a List. WindowData is a local INotifyPropertyChanged class that stores window hWnd, title, Position, Size, executable path, app icon, etc.

Is there a way that I could effectively "bind" to changes of the window title, position, size, etc? I wouldn't want to have to use a DispatcherTimer to update the information every second. I'd prefer it if I could use a simple event handler or callback or something.

Anyone have any ideas?

4

1 回答 1

0

要有效地跟踪所有窗口的窗口数据而不进行轮询,您必须注册窗口创建或删除通知,然后挂钩所有消息队列并处理影响您尝试跟踪的窗口数据的消息。不幸的是,这是一项相当艰巨的任务。如果你想抢先一步,你可以看看 Spy++ 是如何实现的,等等类似的东西。这是一篇文章:

看完之后,您可能会重新考虑每隔一段时间进行一次轮询,并仔细更新ObservableCollection.

于 2011-01-09T00:28:00.910 回答