コード例 #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("");
        }
コード例 #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;
             });
         }
     });
 }
コード例 #3
0
ファイル: Inputer.cs プロジェクト: MichaelOfGH/AutumnBox
 /// <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();
 }
コード例 #4
0
        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);
        }
コード例 #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();
 }
コード例 #6
0
 /// <summary>
 /// 触发键入事件
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public ICommandResult RaiseKeyEvent(AndroidKeyCode code)
 {
     return(RaiseKeyEvent((int)code));
 }
コード例 #7
0
ファイル: Commands.cs プロジェクト: r3c0d3/TastyScript
 public static void KeyEvent(AndroidKeyCode code)
 {
     Main.AndroidDriver.SendCommand($"input keyevent {(int)code}");
 }