Post message works just fine if the window is in the foreground/background for
key presses, which is what I use to move in game (wasd) and use spells/items/macro (addon to auto bind all those).
For
mouse input you can also use post message to send input as long as the game is in the foreground. You can also get it working while it's in the background, but I'd rather not get into that.
A simple workaround for mouse clicks, and one I had previously implemented was store the handle of whatever window is topmost, and then set the wow window to topmost, send click, then restore other window back to topmost.
If you're using it just for yourself, can use interception driver if you really want, but that will render PC essentially useless (or could just run in a vm)
Have been using this for years with minimal issues (might need to add some waits on mouse clicks)
Code:
internal static void KeyDown(int key) => u32.PostMessage(Game._WindowHandle, 0x100, key, 0);
internal static void KeyUp(int key)
=> u32.PostMessage(Game._WindowHandle, 0x101, key, 0);
internal static void LeftClick(int X, int Y)
{
var oldWindow = u32.GetForegroundWindow();
if (!u32.SetForegroundWindow(Game._WindowHandle)) return;
u32.PostMessage(Game._WindowHandle, 0x200,
0x0001, ((Y << 16) | (X & 0xFFFF)));
Task.Factory.StartNew(WaitTask(25)).Wait();
u32.PostMessage(Game._WindowHandle, 0x201,
0x0001, ((Y << 16) | (X & 0xFFFF)));
u32.PostMessage(Game._WindowHandle, 0x202,
0x0000, ((Y << 16) | (X & 0xFFFF)));
u32.SetForegroundWindow(oldWindow);
}