Tracking open windows and their titles
I'm writing a small application for Windows 7 that will track focused programs and their titles. I've never worked with the required API.
Example: The app should run as a process and log everything to a db. If I open Firefox and surf to stackoverflow I would in the db have a row:
"App: Mozilla firefox | Title: Question - Stack Overflow - Mozilla Firefox | Time: 18:07:40"
If I then continue and open Steam I would have a row:
"App: Steam Client | Title: Store | Time: 18:08:40"
I just don't know where to begin. I've developed a bunch of stand alone apps with windows forms but I've never interacted with windows like this before. I've also done a share of ASP.NET developme开发者_开发百科nt so I'm not a complete newbie. Since I'd like to install this as a process a UI isn't really necessary.
Any suggestions? Thanks
SetWindowsHookEx
with WH_CBT
will give you the info you need. You can use WM_GETTEXT
to get window titles.
http://msdn.microsoft.com/en-us/library/ms644959(VS.85).aspx#wh_cbthook
精彩评论