Autor Beitrag
ShadowKnight
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Fr 11.12.09 18:24 
Hallo.

Ich verwende folgende Global-Key-Hook Dll: www.codeproject.com/KB/cs/globalhook.aspx

Diese funktioniert soweit auch, doch wenn ich tastenkombinationen wie ctrl+A abfragen will funktioniert es nichtmehr!

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
if (e.Control)
{
   if (e.KeyCode == Keys.A)
      MessageBox.Show("CTRL + A pressed");
}


Bei nem normalen form_Keydown funzt das, jedoch nicht mit diesem Globalhook. Habs auch schon mit e.Modifiers.ToString().Contains("Alt"), usw. probiert. Weiss jemand eine andere Lösung?

Danke

ShadowKnight
Greenberet
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 339
Erhaltene Danke: 20

Win 10
C# (VS 2012), C++ (VS 2012/GCC), PAWN(Notepad++), Java(NetBeans)
BeitragVerfasst: Fr 11.12.09 19:26 
Lies doch mal den Beitrag den du verlinkst...

Zitat:
Question

How do I catch key combinations like Ctrl+Shift+A?
Answer

You'll have to track which keys have gone down but not up. Only the most recently pressed key keeps sending KeyDown messages, but the others will still send a KeyUp when released. So if you make three flags IsCtrlDown, IsShiftDown, and IsADown, and set them to true at KeyDown and false at KeyUp, the expression (IsCtrlDown && IsShiftDown && IsADown) will give you the required result.
ShadowKnight Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Sa 12.12.09 15:54 
Edit2: Geht doch nicht, KeyEventArgs erkennt ALT/SHIFT/STRG einfach nicht. Woran liegt das?
Edit3: Okay geht mit e.KeyCode.ToString()... muss man erst bei allen nichtfunktionierenden keys aufschreiben.