views:

395

answers:

2

Having setup C++ app originally using MS specific keyboard journaling hook (WH_JOURNALRECORD) we find that it does not work on Vista unless run as administrator with uiAccess enabled. MSDN Question - Journaling hooks on Vista?

We want to record a key sequence from the user in a friendly way that will be repeated at some later date. The user presses a record button, a dialog is displayed with a stop button and the recorded keys.

One advantage of using the journaling hook was that you only got keystrokes which did something. Holding down shift didn't report 100 shift keys, but did report usage when you hit a letter. Another advantage was that you could set the focus to an area outside of the application, say another applications window, and record the action as the user interacted.

Asides from making the keyboard capture part of the existing app a separate executable which runs as administrator with uiAccess, I'm seeking other ideas on how to record keystrokes that work on windows for 2K, 2K3, 2K8, XP, Vista.

Edit: I know there is a security concern with just recording anything, obviously if you could do such a thing without the users notice you have your typical keystroke logger for hacking purposes. Soooooo.....

Is there a way to make journaling work, for this user, and their apps, running at the same level (or lower) and capture keystrokes? having it popup the vista security are you sure dialog would be allright, but the process cannot be marked with uiAccess (otherwise it won't interact properly with the rest of the system) and it will in 98% of cases be run by users without rights to elevate to administrator.

+1  A: 

Even if you could, you'd probably would find Microsoft fixing that bug in the next patch. The change in Vista was intentional, and there's a clear way (uiAccess==true) to still do what you want.

MSalters
The problem with the existing suggested fix is that you need to run with both admin and uiAccess, and in the most part this is a user app which will not be able to be run in admin mode. The users just will not have the access to do so.
Greg Domjan
A: 

We have worked around the main issues by using SetWindowsHook instead.

const HMODULE hDLL = ::GetModuleHandle(DLL_NAME);
::SetWindowsHookEx(WH_KEYBOARD_LL, myKeyboardProcCallback, hDLL, 0);

The callback now has to manage the keystroke information and translating it into usable sequences - ie don't record multiple ctrl presses when heeld down to press ctrl+key.

Greg Domjan