class_docstr: Runs a shell command in a 'with' context.
  
  This implementation is Win32-specific.
  
  Example:
      # Runs the command interactively with default console stdin/stdout
      with ShellCommandController('python -i') as scc:
          scc.run()
  
      # Runs the command using the provided functions for stdin/stdout
      def my_stdout_func(s):
          # print or save the string 's'
          write_to_stdout(s)
      def my_stdin_func():
          # If input is available, return it as a string.
          if input_available():
              return get_input()
          # If no input available, return None after a short delay to
          # keep from blocking.
          else:
              time.sleep(0.01)
              return None
    
      with ShellCommandController('python -i') as scc:
          scc.run(my_stdout_func, my_stdin_func)
class_docstr_tok: ["Runs","a","shell","command","in","a","'with","'","context",".","This","implementation","is","Win32-specific",".","Example",":","#","Runs","the","command","interactively","with","default","console","stdin\/stdout","with","ShellCommandController","(","'python","-i","'",")","as","scc",":","scc.run","(",")","#","Runs","the","command","using","the","provided","functions","for","stdin\/stdout","def","my_stdout_func","(","s",")",":","#","print","or","save","the","string","'s'","write_to_stdout","(","s",")","def","my_stdin_func","(",")",":","#","If","input","is","available",",","return","it","as","a","string",".","if","input_available","(",")",":","return","get_input","(",")","#","If","no","input","available",",","return","None","after","a","short","delay","to","#","keep","from","blocking",".","else",":","time.sleep","(","0.01",")","return","None","with","ShellCommandController","(","'python","-i","'",")","as","scc",":","scc.run","(","my_stdout_func",",","my_stdin_func",")"]
docstr: Initializes the shell command controller.
  
  The cmd is the program to execute, and mergeout is
  whether to blend stdout and stderr into one output
  in stdout. Merging them together in this fashion more
  reliably keeps stdout and stderr in the correct order
  especially for interactive shell usage.
docstr_tok: ["Initializes","the","shell","command","controller",".","The","cmd","is","the","program","to","execute",",","and","mergeout","is","whether","to","blend","stdout","and","stderr","into","one","output","in","stdout",".","Merging","them","together","in","this","fashion","more","reliably","keeps","stdout","and","stderr","in","the","correct","order","especially","for","interactive","shell","usage","."]
code: def __init__(self, cmd, mergeout=True):
      """Initializes the shell command controller.
  
      The cmd is the program to execute, and mergeout is
      whether to blend stdout and stderr into one output
      in stdout. Merging them together in this fashion more
      reliably keeps stdout and stderr in the correct order
      especially for interactive shell usage.
      """
      self.cmd = cmd
      self.mergeout = mergeout
  
imports: import os, sys, threading
  import ctypes, msvcrt
  from ctypes import POINTER
  from ctypes.wintypes import HANDLE, HLOCAL, LPVOID, WORD, DWORD, BOOL, ULONG, LPCWSTR
label_desc: Use image node_id 1 to create a new Win32ShellCommandController object from inherited base classes: object with example: obj = Win32ShellCommandController(cmd, mergeout)