Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

da ich in C# relativ unerfahren bin und meinen Chef nicht wegen jeder Kleinigkeit fragen muss, bat er mir an dieses ihm bekannte Forum zu benutzen für den Fall.. Wir entwickeln ausschließlich mit C# und ich soll zurzeit ein Tool schreiben welches mir auf Druck einer bestimmten Tastenkombination einen Ton abspielt ( .wav ).

Beispielsweise soll so erzielt werden das auf den genauen Tastendruck von /shutdown der Computer sagt "Computer wird Heruntergefahren" , anstatt das nur die Messagebox erscheint.

Den Ton kann ich schon einbinden meine Frage nun lautet allerdings wie ich auf die Kombination der Tasten abfrage, habe eine Keydown funktion gefunden allerdings hilft mir das nicht wirklich weiter weil sich dies auf einzelne Tasten bezieht.

Bitte um nützliche Vorschläge!

Freundlicher Gruß

  • Autor

Habe mir Global Keyhook.cs heruntergeladen klappt für buchstaben ganz gut, allerdings sind die sonderzeichen nicht deutlich nachvollziehbar.

using System;

using System.Windows.Forms;

using System.Runtime.InteropServices;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

#region " Disable Special Keys"

[DllImport("user32.dll", EntryPoint = "SetWindowsHookExA", CharSet = CharSet.Ansi)]

private static extern int SetWindowsHookEx(

int idHook,

LowLevelKeyboardProcDelegate lpfn,

int hMod,

int dwThreadId);

[DllImport("user32.dll")]

private static extern int UnhookWindowsHookEx(int hHook);

[DllImport("user32.dll", EntryPoint = "CallNextHookEx", CharSet = CharSet.Ansi)]

private static extern int CallNextHookEx(

int hHook, int nCode,

int wParam, ref KBDLLHOOKSTRUCT lParam);

private delegate int LowLevelKeyboardProcDelegate(int nCode, int

wParam, ref KBDLLHOOKSTRUCT lParam);

const int WH_KEYBOARD_LL = 13;

private int intLLKey;

private struct KBDLLHOOKSTRUCT

{

public int vkCode;

int scanCode;

public int flags;

int time;

int dwExtraInfo;

}

private int LowLevelKeyboardProc(

int nCode, int wParam,

ref KBDLLHOOKSTRUCT lParam)

{

bool blnEat = false;

switch (wParam)

{

case 256: //WM_KEYDOWN = 0x0100

case 257: //WM_KEYUP = 0x0101

case 260: //WM_SYSKEYDOWN = 0x0104

case 261: //WM_SYSKEYUP = 0x0105

{

blnEat = false;

textBox1.Text = lParam.vkCode.ToString();

}

break;

}

if (blnEat)

return 1;

else return CallNextHookEx(0, nCode, wParam, ref lParam);

}

private void KeyboardHook(object sender, EventArgs e)

{

intLLKey =

SetWindowsHookEx(

WH_KEYBOARD_LL,

new LowLevelKeyboardProcDelegate(LowLevelKeyboardProc),

System.Runtime.InteropServices.Marshal.GetHINSTANCE(

System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(), 0);

}

private void ReleaseKeyboardHook()

{

intLLKey = UnhookWindowsHookEx(intLLKey);

}

#endregion

private void chk_DisableSpecialKeys_CheckedChanged(object sender, EventArgs e)

{

{

if (chk_DisableSpecialKeys.Checked)

KeyboardHook(this, e);

else

ReleaseKeyboardHook();

}

}

}

}

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.