2

コンピューター上のVNCサーバーにコマンドを送信するC#の簡単な方法はありますか?理想的には、ある種のライブラリか何かがいいでしょうが、本当に最も単純なものは何でも。接続してコマンドを送信するだけで、デスクトップを表示したくありません。

ありがとう

4

2 に答える 2

3

VncSharpがあります。

于 2011-03-08T23:23:47.943 に答える
1

方法1の2つの代替ソリューションを次に示します。

Process pl = new Process();
pl.StartInfo.CreateNoWindow = false;
pl.StartInfo.FileName = "calc.exe";
pl.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
// = ProcessWindowStyle.Hidden; if you want to hide the window
pl.Start();
System.Threading.Thread.Sleep(1000);

SendKeys.SendWait("11111");

方法2:

using System.Runtime.InteropServices;


// Get a handle to an application window.
        [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
        public static extern IntPtr FindWindow(string lpClassName,
            string lpWindowName);

        // Activate an application window.
        [DllImport("USER32.DLL")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        private void test()
        {
            IntPtr calculatorHandle = FindWindow("CalcFrame", "Calculator");

            // Verify that Calculator is a running process.
            if (calculatorHandle == IntPtr.Zero)
            {
                MessageBox.Show("Calculator is not running.");
                return;
            }

            // Make Calculator the foreground application and send it 
            // a set of calculations.
            SetForegroundWindow(calculatorHandle);
            SendKeys.SendWait("111");
            SendKeys.SendWait("*");
            SendKeys.SendWait("11");
            SendKeys.SendWait("=");

        }
于 2011-11-09T10:46:54.273 に答える