I need to send the contents of the test.txt file to the QM Editor window via powershell and then run the macro.
I think this is achievable. I won't set the relevant parameters. I hope someone can provide some suggestions. Thanks in advance.
I found a powershell sample file that can send text content to the Notepad window.
Out-Notepad.ps1:
I think this is achievable. I won't set the relevant parameters. I hope someone can provide some suggestions. Thanks in advance.
I found a powershell sample file that can send text content to the Notepad window.
Out-Notepad.ps1:
function Out-Notepad
{
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 notepad -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, "Edit", $null)
$null = $type::SendMessage($child, 0x000C, 0, $text)
}
}
Get-Content -Path c:\test.txt | Out-String | Out-Notepad