0
我創建CMD.EXE一個隱藏的窗口過程,如下所示:如何發送按鍵到隱藏窗口?
// Create the process start window.
var processStartInfo = new ProcessStartInfo("cmd.exe", null);
// Set the options.
processStartInfo.UseShellExecute = false;
processStartInfo.ErrorDialog = false;
processStartInfo.CreateNoWindow = true;
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// Specify redirection.
processStartInfo.RedirectStandardError = true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
// Create the process.
currentProcess = new Process();
然後我處理所有的輸入/輸出自己通過重定向數據流。不過,我希望「標籤」顯示自動完成數據。我曾嘗試向輸入流發送'\ t' - 沒有喜悅。如果窗口變得可見,我在進程結構中有窗口句柄,並且可以將它設置爲前臺並使用'SendKeys'。儘管這是不可接受的,因爲我需要窗戶隱身。
那麼有誰知道如何發送鍵盤進程ID?
在此先感謝!
不幸的是,有一個活動窗口在這種情況下是不可能的 - 我可以忍受一個隱藏的窗口,但進程啓動信息似乎不尊重WindowStyle.Hidden枚舉,除非'使用shell執行' ,我必須擁有! 我確實可以直接啓動ipconfig.exe,但是我有同樣的問題 - 我仍然希望能夠向進程發送特殊字符,不管它是什麼:S – 2012-02-29 11:32:07