I am having an issue where the SendMessage() function is causing a script to hang and thus never exiting though it is running the SendMessage like it should (Its task comple
Please add
Add-Type -Assembly UIAutomationClient
and use
public static extern IntPtr PostMessage(int hWnd, UInt32 hMsg, Int32 wParam, Int32 lParam);
or
public static extern IntPtr SendMessage(int hWnd, UInt32 hMsg, Int32 wParam, Int32 lParam);
And the script will no longer crash