newbie to hooking needs to build a monitoring app

Sep 22, 2014 at 2:45 AM
Edited Sep 25, 2014 at 3:09 AM
Hi,
I'm a programmer newbie to hooking, and I was wondering if with EasyHook I can make a "task monitoring app". At first I was thinking about doing a simple desktop app with some buttons associated to different tasks I would click whenever I switch from one task to another, and maybe somehow record iddle time. Then I "remembered" about hooking windows messages and stumbled upon EasyHook. So I'd like to know if I can do the following with EasyHook (ideally from a Windows Service):
  1. Start the Task Monitor when Windows OS starts
  2. Detect whenever I switch focus from an app to another (e.g., from Visual Studio to Chrome)
  3. Get info from the active (just focused) app, like title bar caption and/or app name, exe path, etc, and if I'm in a web browser (Chrome, IE, FF, etc), which URL I'm browsing or at least the tab title, so I know if I'm spending time looking on job related pages (e.g., stackoverflow.com) or just wasting too much of my day watching blooppers in youtube :)
  4. Detect idle/active time... say... detect all keyboard (don't care about which keys) and mouse activity so I can later determine active/iddle time (I could say I was iddle if I didn't type anything or move the mouse after N seconds).
This Task Monitor app should work on Windows 7 32 and 64 bit, and should detect active app switch (and mouse and keyboard activity) no matter if the apps are 32 or 64 bit.

Thanks in advance
Sep 25, 2014 at 3:05 AM
Anybody?
Sep 25, 2014 at 10:28 AM
You can do most of what you want to do without using hooks, in the sense of EasyHook, at all.

Probably reading the URL could be one you might use EasyHook for, but this can probably also be done with Win32 APIs (i.e. from window handle etc).

For detecting typing and mouse movement you can use a system wide keyboard/mouse hook (there is a Win32 API for this so no need to use EasyHook here either).
Sep 26, 2014 at 7:50 PM
Edited Sep 26, 2014 at 8:02 PM
Thanks Spazzarama for your answer :-)

Being newbie to hooking and having read (maybe too quickly) that it implied DLL injection into the hooked process, and that you had to take into account whether the target app was either 32 or 64 bit (requiring you to inject the corresponding version of the injected dll)...

Since EasyHook apparently takes care of all of that burden (or an important part of it), well I thought I NEEDED to either deal with it on my own or use EasyHook :-)

So you say that I don't need EasyHook at all, and neither need to care about the target apps architecture (32/64 bit) in my case (global hooks for mouse and keyboard, plus change active app detection)? BTW, I don't know squat about c++ and was planning to do this Task Monitor app in C#

Thanks in advance :-)
Sep 30, 2014 at 8:29 PM
So you say that I don't need EasyHook at all, and neither need to care about the target apps architecture (32/64 bit) in my case (global hooks for mouse and keyboard, plus change active app detection)? BTW, I don't know squat about c++ and was planning to do this Task Monitor app in C#