public void SendKeyPress(KeyStates state, Key key)
{
if (state != KeyStates.Toggled)
{
if (PostMessage(
hWnd: _ffxivHWnd,
Msg: state == KeyStates.Down ? 0x100u : 0x101u,
wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key),
lParam: state == KeyStates.Down ? (UIntPtr)0x00500001 : (UIntPtr)0xC0500001)) return;
Console.WriteLine(ErrorCode);
return;
}
if (!PostMessage(
hWnd: _ffxivHWnd,
Msg: 0x100u,
wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key),
lParam: (UIntPtr)0x00500001))
{
Console.WriteLine(ErrorCode);
return;
}
Thread.Sleep(1);
if (!PostMessage(
hWnd: _ffxivHWnd,
Msg: 0x101u,
wParam: (IntPtr)KeyInterop.VirtualKeyFromKey(key),
lParam: (UIntPtr)0xC0500001))
Console.WriteLine(ErrorCode);
}