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)
docstr: Use the raw Win32 handle of sys.stdin to do non-blocking reads
docstr_tok: ["Use","the","raw","Win32","handle","of","sys.stdin","to","do","non-blocking","reads"]
code: def _stdin_raw_nonblock(self):
      """Use the raw Win32 handle of sys.stdin to do non-blocking reads"""
      # WARNING: This is experimental, and produces inconsistent results.
      #          It's possible for the handle not to be appropriate for use
      #          with WaitForSingleObject, among other things.
      handle = msvcrt.get_osfhandle(sys.stdin.fileno())
      result = WaitForSingleObject(handle, 100)
      if result == WAIT_FAILED:
          raise ctypes.WinError()
      elif result == WAIT_TIMEOUT:
          print(".", end="")
          return None
      else:
          data = ctypes.create_string_buffer(256)
          bytesRead = DWORD(0)
          print("?", end="")
  
          if not ReadFile(
              handle, data, 256, ctypes.byref(bytesRead), None
          ):
              raise ctypes.WinError()
          # This ensures the non-blocking works with an actual console
          # Not checking the error, so the processing will still work with
          # other handle types
          FlushConsoleInputBuffer(handle)
  
          data = data.value
          data = data.replace("\r\n", "\n")
          data = data.replace("\r", "\n")
          print(repr(data) + " ", end="")
          return data
  
imports: from __future__ import print_function
  import os, sys, threading
  import ctypes, msvcrt
  from .None import py3compat
  from ctypes import POINTER
  from ctypes.wintypes import HANDLE, HLOCAL, LPVOID, WORD, DWORD, BOOL, ULONG, LPCWSTR
label_desc: Use image node_id 6 for calling the Win32ShellCommandController obj's underlying member method code with example usage: obj._stdin_raw_nonblock() and returns: None, data