Exemplo n.º 1
0
        public override string CallBase()
        {
            var argsList = ProvidedArgs.First("keyevent");

            if (argsList == null)
            {
                Compiler.ExceptionListener.Throw(new ExceptionHandler(ExceptionType.NullReferenceException, "Arguments cannot be null.", LineValue));
                return(null);
            }

            if (Main.AndroidDriver != null)
            {
                //FunctionHelpers.AndroidBack();
                AndroidKeyCode newcol = AndroidKeyCode.A;
                var            nofail = Enum.TryParse <AndroidKeyCode>(argsList.ToString().UnCleanString(), out newcol);
                if (!nofail)
                {
                    Compiler.ExceptionListener.Throw(new ExceptionHandler(ExceptionType.CompilerException,
                                                                          $"The Key Event {argsList.ToString()} could not be found.", LineValue));
                    return(null);
                }
                Commands.KeyEvent(newcol);
            }
            else
            {
                Main.IO.Print($"[DRIVERLESS] Keyevent {argsList.ToString()}");
            }
            return("");
        }
Exemplo n.º 2
0
 private void InputImpl(object para)
 {
     Task.Run(() =>
     {
         try
         {
             ETapper._app.RunOnUIThread(() =>
             {
                 Input.CanExecuteProp = false;
             });
             AndroidKeyCode code = (AndroidKeyCode)para;
             executor.AdbShell(Device, $"input keyevent {(int)code}");
         }
         catch (Exception e)
         {
             SLogger <ETapper> .Warn($"can not input key {para}", e);
         }
         finally
         {
             ETapper._app.RunOnUIThread(() =>
             {
                 Input.CanExecuteProp = true;
             });
         }
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// 模拟按键
 /// </summary>
 /// <param name="keyCode">安卓键值,如果秋之盒中没有你需要的键值定义,可以进行强转: (AndroidKeyCode)233</param>
 /// <exception cref="Exceptions.AdbShellCommandFailedException"></exception>
 public void PressKey(AndroidKeyCode keyCode)
 {
     CmdStation.GetShellCommand(Device,
                                $"input keyevent {(int)keyCode}")
     .To(RaiseOutput)
     .Execute()
     .ThrowIfShellExitCodeNotEqualsZero();
 }
        public AndroidGameControllerState WithButton(AndroidKeyCode code, bool value = true)
        {
            fixed(uint *buttonsPtr = buttons)
            {
                if (value)
                {
                    buttonsPtr[(int)code / 32] |= (uint)1 << ((int)code % 32);
                }
                else
                {
                    buttonsPtr[(int)code / 32] &= ~((uint)1 << ((int)code % 32));
                }
            }

            return(this);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 模拟按键
 /// </summary>
 /// <param name="keyCode">安卓键值,如果秋之盒中没有你需要的键值定义,可以进行强转: (AndroidKeyCode)233</param>
 /// <exception cref="Exceptions.AdbShellCommandFailedException"></exception>
 public void PressKey(AndroidKeyCode keyCode)
 {
     Executor.AdbShell(Device,
                       $"input keyevent {(int)keyCode}")
     .ThrowIfShellExitCodeNotEqualsZero();
 }
Exemplo n.º 6
0
 /// <summary>
 /// 触发键入事件
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public ICommandResult RaiseKeyEvent(AndroidKeyCode code)
 {
     return(RaiseKeyEvent((int)code));
 }
Exemplo n.º 7
0
 public static void KeyEvent(AndroidKeyCode code)
 {
     Main.AndroidDriver.SendCommand($"input keyevent {(int)code}");
 }