@kevin
I am trying to interact between powershell and Qm
Using the code below, I can set the text content to QM's title bar, which I need to set to the QM Editor.
Out-qm.ps1
RegisterNetComComponent Also called user32.dll
I think it's easier to use powershell. I wrote the following code, but there is no result.
I am trying to interact between powershell and Qm

Using the code below, I can set the text content to QM's title bar, which I need to set to the QM Editor.

Out-qm.ps1
function Out-qm
{
param
(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[String]
[AllowEmptyString()]
$Text
)
begin
{
$sb = New-Object System.Text.StringBuilder
}
process
{
$null = $sb.AppendLine($Text)
}
end
{
$text = $sb.ToString()
$process = Start-Process qm -PassThru
$null = $process.WaitForInputIdle()
$sig = '
[DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
'
$type = Add-Type -MemberDefinition $sig -Name APISendMessage -PassThru
$hwnd = $process.MainWindowHandle
[IntPtr]$child = $type::FindWindowEx($hwnd, [IntPtr]::Zero, "QM_Editor", $null)
$null = $type::SendMessage($child, 0x000C, 0, $text)
}
}
Get-Content -Path c:\test.txt | Out-String | Out-qm
RegisterNetComComponent Also called user32.dll
I think it's easier to use powershell. I wrote the following code, but there is no result.

$code = @'
[DllImport("user32.dll", EntryPoint = "SendMessageW", CharSet = CharSet.Unicode)] public static extern IntPtr SendMessageS(IntPtr hWnd, int Msg, uint wParam, string lParam);
[DllImport("user32.dll", EntryPoint = "FindWindowW", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
'@
$myAPI = Add-Type -MemberDefinition $code -Name API -PassThru
$myAPI::SendMessageS($myAPI::FindWindow("QM_Editor", $null), 12, 1, "Q ' M 'func8'");