Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the legitimate uses of global keyboard hooks?

Other than for app launch shortcuts, which should only be provided by the O/S, what are the legitimate uses of things like Windows keyboard hooks? It seems to me that we only have problems with things like key loggers because operating systems provide hooks to do things that should not be permitted by anyone under any condition except the O/S kernel itself.

EDIT: OK, so given some legitimate places where they may be required, should not the O/S provide a high level ability to globally turn them off, and only allow exceptions on a program-by-program basis?

like image 215
Lawrence Dol Avatar asked Nov 22 '08 02:11

Lawrence Dol


4 Answers

I'm currently working on a mobile application platform / hardware abstraction layer for an enterprise client, and one requirement was that a screensaver would be brought up after a certain period of inactivity. Since mobile devices don't have mice to move, "activity" consists of key presses or screen taps. One of our devices doesn't have a touchscreen, and, to make a long story longer, the mobile hardware vendor didn't properly implement the Win32 API calls that would allow me to get the time since the last user input.

Since the hardware vendor was unwilling to implement the Win32 API properly, the next best way I knew of to ensure that my console application could trap key presses in any application on the system was to install a global keyboard hook.

That said, I agree that the average consumer scenario is very different from mine, and the OS should allow the user to whitelist activities like this.

like image 138
RJ Cantrell Avatar answered Nov 17 '22 02:11

RJ Cantrell


Not true, there are environments where the owner of the computer may want to stop things such as Ctrl+Alt+Delete... example, a Kiosk, or... .... Best Buy?

like image 44
Timothy Khouri Avatar answered Nov 17 '22 01:11

Timothy Khouri


For example I have installed two applications;

  • One maps Windows-V as paste unformatted text
  • Another one modifies how caps lock works

I think both of them require a hook.

like image 1
2 revs Avatar answered Nov 17 '22 01:11

2 revs


I wrote an app that let me place virtual sticky notes on my monitor. I used an OS keyboard hook to bind a hotkey to it.

I had an option in settings to disable the hook.

like image 1
FlySwat Avatar answered Nov 17 '22 01:11

FlySwat