I decided that it is better to use RegisterHotKey() function from winApi. It saves a lot of time in my case. Still, I feel unsatisfied for some reason Thank you for your advices. They helped a lot.