<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>Someone asked about this quite a while back and I promised to
      provide it and forgot.</p>
    <p>Bind this to whatever key you want. If you're unlucky enough to
      have to use the nuget package manager, here's how you can easily
      get to that console to review output. YMMV with this thing, I'm by
      no means a script expert and I'm sure plenty of people could write
      it more cleanly and better. This was a quick hour fix when I
      needed it.<br>
    </p>
    <p>import "uia.jsb"<br>
      import "touch.jsb"<br>
      include "uia.jsh"<br>
      include "hjconst.jsh"<br>
      include "hjglobal.jsh"<br>
      <br>
      Script VirtualizeNearestConsoleWindow ()<br>
      var handle appWindow = GetAppMainWindow (GetCurrentWindow())<br>
      var object UIAObject = FSUIAGetElementFromHandle(appWindow)<br>
      if (!UIAObject) then<br>
      SayString("Could not create UIA object.")<br>
      return<br>
      EndIf<br>
      var object controlCondition =
      FSUIACreateIntPropertyCondition(UIA_ControlTypePropertyId,
      UIA_PaneControlTypeId)<br>
      var object nameCondition =
      FSUIACreateStringPropertyCondition(UIA_NamePropertyId, "Package
      Manager Console")<br>
      if (!controlCondition || !nameCondition) then<br>
      SayString("Could not create conditions.");<br>
      return<br>
      EndIF<br>
      var object finalCondition =
      FSUIACreateAndCondition(controlCondition, nameCondition)<br>
      if (!finalCondition)<br>
      SayString("Could not create conditions.");<br>
      return<br>
      EndIf<br>
      var object pane = uiaObject.findFirst(TreeScope_Subtree,
      finalCondition)<br>
      if (!pane)<br>
      SayString("Could not find pane.")<br>
      return<br>
      EndIf<br>
      var object textboxCondition =
      FSUIACreateStringPropertyCondition(UIA_NamePropertyId, "Text
      Editor")<br>
      if (!textboxCondition)<br>
      SayString("Could not create textbox condition.")<br>
      return<br>
      EndIf<br>
      var object textbox = pane.findFirst(TreeScope_Subtree,
      textboxCondition)<br>
      SayString(textbox.name)<br>
      var object textPattern = textbox.GetTextPattern()<br>
      if (!textPattern) then<br>
      SayString("Could not get text pattern.")<br>
      return<br>
      EndIf<br>
      var object range = textPattern.documentRange<br>
          if !range then<br>
          SayString("could not get range.")<br>
          return<br>
          EndIf<br>
          range.ExpandToEnclosingUnit(TextUnit_Page)<br>
      var string value = range.getText(TextRange_NoMaxLength)<br>
          UserBufferClear()<br>
      UserBufferAddText(value)<br>
      UserBufferActivate()<br>
      EndScript<br>
      <br>
    </p>
    <div class="moz-signature">-- <br>
      <div>
        <p><strong>Ty Littlefield</strong><br>
          <small>Software Developer | Blogger | Audio Engineer</small></p>
        <p>Cell: (720) 314-8194<br>
          Blog: <a href="https://tysdomain.com" target="_blank">From
            Bytes to Bites</a></p>
      </div>
    </div>
  </body>
</html>