예제 #1
0
        public void Receive()
        {
            _socket.BeginReceiveFrom(state.buffer, 0, bufSize, SocketFlags.None, ref epFrom, recv = (ar) =>
            {
                State so  = (State)ar.AsyncState;
                int bytes = _socket.EndReceiveFrom(ar, ref epFrom);
                _socket.BeginReceiveFrom(so.buffer, 0, bufSize, SocketFlags.None, ref epFrom, recv, so);
                Keyboard.ScanCodeShort k = (Keyboard.ScanCodeShort)(int) so.buffer[0];//(int)so.buffer[0];
                Keyboard.INPUT[] Inputs  = new Keyboard.INPUT[1];
                Keyboard.INPUT Input     = new Keyboard.INPUT();
                Input.type         = 1; // 1 = Keyboard Input
                Input.U.ki.wScan   = k;
                Input.U.ki.dwFlags = Keyboard.KEYEVENTF.SCANCODE;
                Inputs[0]          = Input;
                Keyboard.SendInput(1, Inputs, Keyboard.INPUT.Size);
                // Keyboard.Send(k);
                // VirtualKeyCode key =  (VirtualKeyCode) (int)so.buffer[0];
                // InputSimulator input = new InputSimulator();
                // input.Keyboard.KeyPress(key);



                Console.WriteLine("RECV: {0}: {1}, {2}", epFrom.ToString(), bytes, Encoding.ASCII.GetString(so.buffer, 0, bytes));
            }, state);
            // Keyboard.ScanCodeShort k = (int)0;
            //Keyboard.Send(k);
        }
예제 #2
0
 protected void SendKey(Keyboard.ScanCodeShort key, float duration, Action callback)
 {
     if (!IsActive)
     {
         return;
     }
     ActionManager.SendAction(() => { KeyUtils.Send(key); }, duration, callback);
 }
예제 #3
0
 private Func <bool> createHardwareKeyCodeFunc(Keyboard.ScanCodeShort scanCode)
 {
     return(() =>
     {
         hardwareInputSim.Send(scanCode);
         return true;
     });
 }
예제 #4
0
 public void QueueKeypress(Keyboard.ScanCodeShort key, int delay)
 {
     if (queuedKeyDelay > 0 || fzzy.isLoading)
     {
         return;
     }
     queuedKey      = key;
     queuedKeyDelay = delay;
 }
예제 #5
0
        public static void fj(Keyboard.ScanCodeShort a)
        {
            Keyboard.keydown(a);

            sleep(105);
            Keyboard.keyup(a);
            sleep(136);
            Keyboard.keydown(a);
            sleep(114);
            Keyboard.keyup(a);
        }
예제 #6
0
        public static void Send(Keyboard.ScanCodeShort key)
        {
            if (WinUtils.GetActiveWindow() != WindowToSendKeysIn || _currentKey != null)
            {
                return;
            }

            _currentKey = key;
            _keyboard.Send(_currentKey.Value);
            _timerCombination.Restart();
        }
예제 #7
0
        private static ConcurrentQueue <Keyboard.ScanCodeShort> GetCombination(string message)
        {
            ConcurrentQueue <Keyboard.ScanCodeShort> combination = new ConcurrentQueue <Keyboard.ScanCodeShort>();

            foreach (var ch in message)
            {
                Keyboard.ScanCodeShort keyCode = GetScanCode(ch);
                combination.Enqueue(keyCode);
            }

            return(combination);
        }
예제 #8
0
        public static void readkeys()
        {
            string configs = @".\config.txt";

            List <string> lines = File.ReadAllLines(configs).ToList();

            foreach (var line in lines)
            {
                string[] entries = line.Split('=');

                switch (entries[0].ToLower())
                {
                case "attack":
                    attack = checkkeys(entries[1]);
                    break;

                case "jump":
                    jump = checkkeys(entries[1]);
                    break;

                case "buff1":
                    buff1 = checkkeys(entries[1]);
                    break;

                case "buff2":
                    buff2 = checkkeys(entries[1]);
                    break;

                case "buff3":
                    buff3 = checkkeys(entries[1]);
                    break;

                case "rush":
                    rush = checkkeys(entries[1]);
                    break;

                default:
                    break;
                }
                //Console.WriteLine(entries[0] + "=" + entries[1]);
                //Console.WriteLine(entries[1]);
            }
        }
예제 #9
0
 public void PressMovement(Keyboard.ScanCodeShort key)
 {
     if (pressedKeys.ContainsKey(key)) return;
     fzzy.board.Press(key);
     pressedKeys[key] = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
 }
예제 #10
0
        private void AddInputButton_Click(object sender, EventArgs e)
        {
            try
            {
                List <TimelineItem> tempItems = new List <TimelineItem>(); // it's a list because sometimes we need to add two events
                tempItems.Add(new TimelineItem());                         // there will always be one event added

                InputType tabType = (InputType)Enum.Parse(typeof(InputType), InputTypeTabs.SelectedTab.Text, true);

                switch (tabType)
                {
                case InputType.KeyCode:
                    if (!HardwareKeyCodeTabCheck.Checked)
                    {
                        VirtualKeyCode virtualKeyCode = (VirtualKeyCode)KeyCodeTabCombo.SelectedItem;

                        if (SplitKeyCodeTabCheck.Checked)
                        {
                            tempItems[0].name = tabType.ToString() + " - Pressed Down " + virtualKeyCode.ToString();
                            tempItems[0].func = createKeyCodeFunc(KeyPressType.Down, virtualKeyCode);

                            tempItems.Add(new TimelineItem());
                            tempItems[1].name = tabType.ToString() + " - Pressed Up " + virtualKeyCode.ToString();
                            tempItems[1].func = createKeyCodeFunc(KeyPressType.Up, virtualKeyCode);
                        }
                        else     // We just do a regular keypress
                        {
                            tempItems[0].name = tabType.ToString() + " - Pressed Down & Up " + virtualKeyCode.ToString();
                            tempItems[0].func = createKeyCodeFunc(KeyPressType.Press, virtualKeyCode);
                        }
                    }
                    else     // use hardware key input instead
                    {
                        Keyboard.ScanCodeShort scanCode = (Keyboard.ScanCodeShort)HardwareKeyCodeTabCombo.SelectedItem;

                        tempItems[0].name = tabType.ToString() + " - Hardware input " + scanCode.ToString();
                        tempItems[0].func = createHardwareKeyCodeFunc(scanCode);
                    }
                    break;

                case InputType.Mouse:
                    int            moveX          = (int)MoveXMouseTabInput.Value;
                    int            moveY          = (int)MoveYMouseTabInput.Value;
                    bool           moveAbsolute   = AbsoluteMouseTabCheck.Checked;
                    int            scrollHor      = (int)ScrollHorMouseTabInput.Value;
                    int            scrollVert     = (int)ScrollVertMouseTabInput.Value;
                    MouseClickType mouseClickType = (MouseClickType)MouseClickMouseTabCombo.SelectedItem;
                    int            xID            = (int)XIDMouseTabInput.Value;

                    tempItems[0].name = tabType.ToString() + " - ";
                    if (moveX != 0 || moveY != 0 || moveAbsolute)
                    {
                        tempItems[0].name += "Move " + (moveAbsolute? "to " : "by ") + moveX + "," + moveY + " ";
                    }
                    if (scrollHor != 0 || scrollVert != 0)
                    {
                        tempItems[0].name += "Scroll by " + scrollHor + "," + scrollVert + " ";
                    }
                    if (mouseClickType != MouseClickType.None)
                    {
                        tempItems[0].name += mouseClickType.ToString() + " ";
                        if (mouseClickType.ToString().Contains("X"))
                        {
                            tempItems[0].name += "button ID " + xID + " ";
                        }
                    }
                    if (moveX == 0 && moveY == 0 && !moveAbsolute && scrollHor == 0 && scrollVert == 0 && mouseClickType == MouseClickType.None)
                    {
                        throw new Exception("No mouse input configuration was made");
                    }

                    tempItems[0].func = createMouseFunc(moveX, moveY, moveAbsolute, scrollHor, scrollVert, mouseClickType, xID);
                    break;

                case InputType.String:
                    string message = StringTabInput.Text;
                    if (message.Length > 1000)
                    {
                        throw new Exception("String message too long");
                    }
                    tempItems[0].name = tabType.ToString() + " - \"" + message + "\"";
                    tempItems[0].func = createStringFunc(message);
                    break;

                case InputType.Delay:
                    int delay = (int)DelayTabInput.Value;
                    tempItems[0].name = tabType.ToString() + " - " + delay + "ms";
                    tempItems[0].func = createDelayFunc(delay);
                    break;

                default:
                    throw new Exception("Somehow, no input type tab was selected.");
                }

                TimelineList.Items.AddRange(tempItems.ToArray());
            }
            catch (Exception err)
            {
                Console.WriteLine("Error occurred when trying to add new input to timeline: {0}", err.Message);
            }
        }
 protected BaseNumPadAction(Keyboard.ScanCodeShort keyToSend)
 {
     KeyToSend = keyToSend;
 }