当前位置:   article > 正文

autojs一个经典的飘浮工具栏界面源码_autojs悬浮窗ui界面

autojs悬浮窗ui界面

autojs一般的项目都会有一个全屏界面,点击按钮,弹出个小悬浮窗。

但是也有的时候只需要直接弹出小窗就够用了。这时候就用到了。

  1. "ui";
  2. importClass(android.view.View);
  3. auto.waitFor();
  4. auto.setMode('normal');
  5. setInterval(()=>{}, 1000);
  6. threads.start(function () {
  7. var window = floaty.window(
  8. <vertical>
  9. <button id="center" margin="0" w="60">移动</button>
  10. <button id="start" margin="0" w="60">开始</button>
  11. <button id="stop" margin="0" w="60" visibility="gone">停止</button>
  12. <button id="console" margin="0" w="60">调试</button>
  13. <button id="exit" margin="0" w="60">关闭</button>
  14. </vertical>
  15. );
  16. window.setPosition(window.getX(), window.getY() + 200);
  17. var x = 0,
  18. y = 0,
  19. windowX = 0,
  20. windowY = 0,
  21. isRuning = false,
  22. showConsole = false,
  23. isShowingAll = true;
  24. window.center.setOnTouchListener(function (view, event) {
  25. switch (event.getAction()) {
  26. case event.ACTION_DOWN:
  27. x = event.getRawX();
  28. y = event.getRawY();
  29. windowX = window.getX();
  30. windowY = window.getY();
  31. break;
  32. case event.ACTION_MOVE:
  33. window.setPosition(windowX + (event.getRawX() - x), windowY + (event.getRawY() - y));
  34. break;
  35. case event.ACTION_UP:
  36. if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
  37. ui.run(function () {
  38. if (isShowingAll) {
  39. isShowingAll = false;
  40. window.start.setVisibility(View.GONE);
  41. window.stop.setVisibility(View.GONE);
  42. window.console.setVisibility(View.GONE);
  43. window.exit.setVisibility(View.GONE);
  44. } else {
  45. isShowingAll = true;
  46. if (isRuning) {
  47. window.start.setVisibility(View.GONE);
  48. window.stop.setVisibility(View.VISIBLE);
  49. } else {
  50. window.start.setVisibility(View.VISIBLE);
  51. window.stop.setVisibility(View.GONE);
  52. }
  53. window.console.setVisibility(View.VISIBLE);
  54. window.exit.setVisibility(View.VISIBLE);
  55. }
  56. });
  57. }
  58. break;
  59. }
  60. return true;
  61. });
  62. window.start.click(function () {
  63. isRuning = true;
  64. ui.run(function () {
  65. window.start.setVisibility(View.GONE);
  66. window.stop.setVisibility(View.VISIBLE);
  67. });
  68. startAuto();
  69. });
  70. function stopAuto () {
  71. isRuning = false;
  72. ui.run(function () {
  73. window.start.setVisibility(View.VISIBLE);
  74. window.stop.setVisibility(View.GONE);
  75. });
  76. threads.shutDownAll();
  77. }
  78. window.stop.click(stopAuto);
  79. window.console.click(function () {
  80. threads.start(function () {
  81. if (showConsole == false) {
  82. showConsole = true;
  83. console.show();
  84. } else {
  85. showConsole = false;
  86. console.hide();
  87. }
  88. });
  89. });
  90. window.exit.click(function () {
  91. exit();
  92. });
  93. });

运行后,会弹出基本全功能的悬浮窗来。可以开始,停止。以及拖动。

自己加上,实际需要运行的代码就行了

还不收藏起来??

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/111730
推荐阅读
相关标签
  

闽ICP备14008679号