在按键盘上的ALT + 8(任意数字)键时将文本复制到剪贴板时遇到问题。 虽然它与CTRL + 8(任何数字)
工作正常尝试以下代码:
Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
ModifierKeys modifier = (ModifierKeys)((int)m.LParam & 0xFFFF);
// Keys key1 = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
// ModifierKeys modifier1 = (ModifierKeys)((int)m.LParam & 0xFFFF);
if (m.Msg == WM_HOTKEY)
{
//System.UInt32 Modif = (((int)m.LParam >> 16) & 0xFFFF);
// System.UInt32 Key = ShiftRight(((int)(m.LParam)), 16);
// if ((((int)Key1 == VK_b)
// && ((int)modifier1 == MOD_CONTROL)))
{
// Check foregroundwindow has a valid handle
if (((System.IntPtr)GetForegroundWindow() != IntPtr.Zero))
{
// Send the Ctrl+C command to the active window
SendKeys.SendWait("^c");
}
}