Search notes:

user32.dll: SendMessage

Sending message from PowerShell

add-type -name user32 -namespace '' -memberDefinition '
[DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern Int32 SendMessage(
            IntPtr  hWnd,
            UInt32  msg,
            UIntPtr wParam,
            IntPtr  lParam
    );'
After adding the user32 type, its (only) static method SendMessage can be invoked like so:
[user32]::SendMessage(…)
If the fourth parameter is a string, it needs to be declared as such. See for example SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment") after changing a value in the registry in HKEY_CURRENT_USER\Environment.

See also

Calling SendMessage() from VBA
Using SendMessage() in PowerShell to write into notepad.

Index