Pergunta

I want my program to pop up when I hit the control key + left click (like babylon does). I know how to register global hotkeys, but I dont klnow how to combine a mouse click.

Thanks!

Foi útil?

Solução

There's a great article on global keyhooks and global mouse hooks on CodeProject

This class allows you to tap keyboard and mouse and/or to detect their activity even when an application runs in the background or does not have any user interface at all. This class raises common .NET events with KeyEventArgs and MouseEventArgs, so you can easily retrieve any information you need.

http://www.codeproject.com/Articles/7294/Processing-Global-Mouse-and-Keyboard-Hooks-in-C

Using that implementation, or the ideas in it, your program can know when a left click happens in any application, and what the state of the Control key is at the time.

Keep in mind that some other apps define behavior for Ctrl-Left-Click. Overriding that behavior could create a confusing experience for the user.

Outras dicas

You can use windows hooks which can be used to hook to the keyboard and mouse events outside your form. This website explains how you can set a windows hook: http://support.microsoft.com/kb/318804

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top