I am trying to do something like the question asked in this post in win10 with C# SendInput to minimized window while you're working on other windows.
I followed the best answer to do and I find it didn't work as "GetProcessIdOfThread" always return 0.
Here is the code:
public MainWindow()
{
InitializeComponent();
IntPtr NotepadHandle = FindWindow("Notepad", "Untitled - Notepad");
if (NotepadHandle == IntPtr.Zero)
{
MessageBox.Show("Notepad is not running.");
return;
}
uint noteid = GetProcessIdOfThread(NotepadHandle);
uint selfid = GetCurrentThreadId();
bool attach = AttachThreadInput(selfid, noteid, true);
if (attach == false)
{
MessageBox.Show("attach fail");
return;
}
}
Did I misunderstood anything? Thank you!