The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use powershell to send a message to the QM window
#1
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.
Heart

I found a powershell sample file that can send text content to the Notepad window.


Out-Notepad.ps1​​​​​​​:
Code:
Copy      Help
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


Attached Files
.txt   test.txt (Size: 18 bytes / Downloads: 224)


Messages In This Thread
Use powershell to send a message to the QM window - by win - 05-10-2019, 11:20 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)