Пример #1
0
        public void KeyX()
        {
            bool down = false, up = false;

            Hook.I().AddKeyHook((Key k) =>
            {
                if (k == Key.X)
                {
                    down = true;
                }

                Console.WriteLine("d");
            }, (Key k) =>
            {
                if (k == Key.X)
                {
                    up = true;
                }

                Console.WriteLine("u");
            });

            Thread.Sleep(w);
            ks.KeyPress(VirtualKeyCode.VK_X);
            Assert.IsTrue(down && up);
        }
Пример #2
0
 public void ExcluirItem()
 {
     bd.SalvarPosicaoAtual();
     Thread.Sleep(250);
     mouse.LeftButtonDoubleClick();
     movimento.MoveCursorLixeira();
     mouse.LeftButtonClick();
     teclado.KeyPress(VirtualKeyCode.RETURN);
     movimento.MoveCursorInicial();
 }
Пример #3
0
        private void PressOneKey(string[] keys)
        {
            var key = keys.Single();

            if (Enum.TryParse <VirtualKeyCode>(key, out var keyCode))
            {
                _keyboard.KeyPress(keyCode);
            }
        }
        private static void CtrlWinKey(VirtualKeyCode virtualKeyCode)
        {
            _keyboardSimulator.KeyDown(VirtualKeyCode.LCONTROL);
            _keyboardSimulator.KeyDown(VirtualKeyCode.LWIN);

            _keyboardSimulator.KeyPress(virtualKeyCode);

            _keyboardSimulator.KeyUp(VirtualKeyCode.LWIN);
            _keyboardSimulator.KeyUp(VirtualKeyCode.LCONTROL);
        }
Пример #5
0
        private async Task SimulateHoldKey(VirtualKeyCode keyCode, CancellationToken ct)
        {
            _wowWindow.SetForeground();
            _simulator.KeyPress(keyCode);
            await Sleep(190);

            while (!ct.IsCancellationRequested)
            {
                _wowWindow.SetForeground();
                _simulator.KeyUp(keyCode);
                await Sleep(100);
            }
        }
        private void SimulateKeyStrokesToCaptureConsoleContent()
        {
            // InputSimulator did not work here simulating ALT+SPACE
            // The solution was -----v
            User32.keybd_event(0x12, 1, 0, IntPtr.Zero);
            Thread.Sleep(10);
            User32.keybd_event(0x20, 1, 0, IntPtr.Zero);
            Thread.Sleep(10);
            User32.keybd_event(0x20, 1, User32.KEYEVENTF.KEYEVENTF_KEYUP, IntPtr.Zero);
            Thread.Sleep(10);
            User32.keybd_event(0x12, 1, User32.KEYEVENTF.KEYEVENTF_KEYUP, IntPtr.Zero);
            Thread.Sleep(10);

            keyboard
            .KeyPress(VirtualKeyCode.VK_E, VirtualKeyCode.VK_S, VirtualKeyCode.RETURN)
            .Sleep(200);
        }
        private void dataGrid_CurrentCellChanged(object sender, EventArgs e)
        {
            DataGridCellInfo currentCell = dataGrid.CurrentCell;

            if (invalidItems.Count > 0 && currentCell.Item != lastEdit.Row.Item)
            {
                foreach (T item in invalidItems)
                {
                    (dataGrid.ItemsSource as IList <T>).Remove(item);
                }

                invalidItems.Clear();
                RefreshAndRefocus(currentCell);

                if (dataGrid.Items.IndexOf(currentCell.Item) != placeholderIndex)
                {
                    keyboard.KeyPress(VirtualKeyCode.DOWN);
                    keyboard.KeyPress(VirtualKeyCode.UP);
                }
                else if (dataGrid.Columns.Count > 1)
                {
                    if (currentCell.Column.DisplayIndex == 0)
                    {
                        keyboard.KeyPress(VirtualKeyCode.RIGHT);
                        keyboard.KeyPress(VirtualKeyCode.LEFT);
                    }
                    else
                    {
                        keyboard.KeyPress(VirtualKeyCode.LEFT);
                        keyboard.KeyPress(VirtualKeyCode.RIGHT);
                    }
                }

                if (!dataGrid.Items.Contains(lastEdit.Row.Item) && dataGrid.Items.CurrentItem == lastEdit.Row.Item &&
                    lastEdit.EditAction == DataGridEditAction.Commit && !lastEdit.Cancel)
                {
                    (dataGrid.ItemsSource as IList <T>).Add((T)lastEdit.Row.Item);
                    RefreshAndRefocus(currentCell);
                }
            }

            if (currentCell.Item == CollectionView.NewItemPlaceholder)
            {
                placeholderIndex = dataGrid.Items.IndexOf(currentCell.Item);
            }
        }
Пример #8
0
        public void Input()
        {
            foreach (var key in keys)
            {
                if (key.IsWait())
                {
                    Thread.Sleep((int)key.WaitMillis);
                }
                else
                {
                    var codes = key.GetVirtualKeyCodes();
                    foreach (var code in codes)
                    {
                        if (code != VirtualKeyCode.VK_5)
                        {
                            keyboard.KeyPress(code);
                        }
                    }
                }
            }

            foreach (var key in keys)
            {
                if (!key.IsWait())
                {
                    var codes = key.GetVirtualKeyCodes();
                    foreach (var code in codes)
                    {
                        if (code != VirtualKeyCode.VK_5)
                        {
                            keyboard.KeyUp(code);
                        }
                    }
                }
            }
        }
Пример #9
0
 public void PressTab()
 {
     keyboard.Sleep(500);
     keyboard.KeyPress(VirtualKeyCode.TAB);
 }
Пример #10
0
        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();
        }
Пример #11
0
 /// <summary>
 ///  Initiates an input into the OS so simulate a key press action.
 /// </summary>
 protected void KeyPress()
 {
     keyboard.KeyPress(KeyCode);
 }
Пример #12
0
 private void KeyPress(Keys key)
 {
     Logger.Log("Sending key: " + key);
     Keyboard.KeyPress(key.ToVitual());
 }
Пример #13
0
 private static void k(VirtualKeyCode key)
 {
     SetForegroundWindow(windowHandle);
     ksim.KeyPress(key);
     ksim.Sleep(DELAY_BETWWEN_KEYS);
 }
 private static void k(VirtualKeyCode key)
 {
     ksim.KeyPress(key);
     ksim.Sleep(150);
 }