2020-07-07 07:15:45 +12:00
|
|
|
|
// <copyright file="RegisterHotKey.cs" company="PlaceholderCompany">
|
|
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
|
|
// </copyright>
|
2020-03-28 08:43:16 +13:00
|
|
|
|
|
2020-03-30 06:26:45 +13:00
|
|
|
|
namespace SystemTrayMenu.DllImports
|
2020-03-28 08:43:16 +13:00
|
|
|
|
{
|
2020-07-07 07:15:45 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// wraps the methodcalls to native windows dll's.
|
|
|
|
|
/// </summary>
|
2020-03-28 08:43:16 +13:00
|
|
|
|
public static partial class NativeMethods
|
|
|
|
|
{
|
|
|
|
|
public static bool User32RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk)
|
|
|
|
|
{
|
|
|
|
|
return RegisterHotKey(hWnd, id, fsModifiers, vk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool User32UnregisterHotKey(IntPtr hWnd, int id)
|
|
|
|
|
{
|
|
|
|
|
return UnregisterHotKey(hWnd, id);
|
|
|
|
|
}
|
2020-07-07 02:46:47 +12:00
|
|
|
|
|
|
|
|
|
public static uint User32MapVirtualKey(uint uCode, uint uMapType)
|
|
|
|
|
{
|
|
|
|
|
return MapVirtualKey(uCode, uMapType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int User32GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize)
|
|
|
|
|
{
|
|
|
|
|
return GetKeyNameText(lParam, lpString, nSize);
|
|
|
|
|
}
|
2020-07-08 03:05:19 +12:00
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint virtualKeyCode);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
|
|
|
|
|
private static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
|
|
|
private static extern int GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize);
|
2020-03-28 08:43:16 +13:00
|
|
|
|
}
|
|
|
|
|
}
|