Beispiel #1
0
        private void PrintPrompt(string message, T defaultValue)
        {
            var options = Options;

            Console.WriteLine();
            if (options.Any())
            {
                Console.WriteLine(message);
                for (var i = 1; i <= options.Count; i++)
                {
                    Console.WriteLine($" {i}: {OptionString(options[i - 1]),3}");
                }

                Console.WriteLine();
                Console.Write("Selection: ");
            }
            else
            {
                Console.Write($"{message}: ");
            }

            if (defaultValue != null)
            {
                var defaultString = OptionString(defaultValue);
                if (!string.IsNullOrWhiteSpace(defaultString))
                {
                    Thread.Sleep(50);
                    _keyboardSimulator.TextEntry(defaultString.Trim());
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Types text at the current cursor location
 /// </summary>
 /// <param name="text">the text to type</param>
 public void Type(string text)
 {
     keyboard.Sleep(500);
     keyboard.TextEntry(text);
 }
        static void Main(string[] args)
        {
            //getting pointer to the window
            IntPtr handle = GetConsoleWindow();

            //starting GE
            try
            {
                Process.Start("C:\\Program Files\\NVIDIA Corporation\\NVIDIA GeForce Experience\\NVIDIA GeForce Experience.exe");
            }
            catch (System.IO.FileNotFoundException e)
            {
                Console.WriteLine(e.ToString());
            }
            catch (System.ComponentModel.Win32Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            //Hide
            //ShowWindow(handle, SW_HIDE);
            //visibility = false;

            //running socket objects
            listener = new UdpClient(port, AddressFamily.InterNetwork);
            sender   = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            groupEP  = new IPEndPoint(IPAddress.Any, port);

            //getting pickler objects
            pickler   = new Pickler();
            unpickler = new Unpickler();

            //Input simulation
            InputSimulator     sim   = new InputSimulator();
            IKeyboardSimulator keybd = sim.Keyboard;

            //received data
            Dictionary <string, object> rec;

            object[] sending_data;
            Package  sen_pack;

            ArrayList data;
            string    from = "";
            int       personality;
            int       choose;

            //flags
            bool running = true;


            while (running)
            {
                sending_data = null;

                //receiving data
                rec = Receive_data();
                if ((int)rec["errcode"] == -1)
                {
                    continue;
                }
                data        = (ArrayList)rec["data"];
                from        = (string)rec["FROM"];
                personality = (int)rec["personality"];
                choose      = (int)data[0];

                if (choose == 0)//shutting down the slave
                {
                    running         = false;
                    sending_data    = new object[2];
                    sending_data[0] = 0;
                    sending_data[1] = true;
                }
                else if (choose == 20)//writing to the window on the top
                {
                    Console.WriteLine("Input of " + (string)data[1]);
                    keybd.TextEntry((string)data[1]);
                    keybd.KeyPress(WindowsInput.Native.VirtualKeyCode.RETURN);
                    sending_data    = new object[2];
                    sending_data[0] = 20;
                    sending_data[1] = data[1];
                }
                else if (choose == 21)//checking if Geforce Experience process is working (input when "nvcontainer" is 5)
                {
                    Process[] plist = Process.GetProcessesByName("nvcontainer");
                    Console.WriteLine(plist.Length.ToString());
                    foreach (Process i in plist)
                    {
                        Console.WriteLine("Process: {0} - ID: {1}", i.ProcessName, i.Id);
                    }

                    sending_data = new object[2]
                    {
                        21, plist.Length
                    };
                }
                else if (choose == 22)//toggle window visibility
                {
                    sending_data = Toggle_visibility(handle);
                }

                //sending back a feedback
                if (sending_data != null)
                {
                    sen_pack = new Package(from, sending_data);//packing
                    Send_data(sen_pack);
                }
            }

            listener.Close();
        }
 /// <summary>
 /// Initiates the input of one or more characters
 /// </summary>
 /// <param name="text"></param>
 protected void OutputText(string text)
 {
     keyboard.TextEntry(text);
 }
Beispiel #5
0
 private void Text(string text)
 {
     Logger.Log("Sending text: " + text);
     Keyboard.TextEntry(text);
 }