本文目錄一覽:
求把電腦用的按鍵精靈代碼轉譯為auto.js用的代碼
主要是Goto 繼續——Rem 繼續 如何轉化和 顏色判斷中的「如果是則執行A,否則執行B」怎麼寫 其他的沒問題了 下面是參考代碼 Rem 繼續 MoveTo 826, 296 Delay 1000 LeftClick 1 Delay 5000 IfColor 928,663,”232352″,2 Then MoveTo 928,663 Delay 3000 LeftClick 1 Else MoveTo 706, 577 LeftClick 1 MoveTo 801, 249 Delay 3000 LeftClick 1 MoveTo 728, 577 Delay 3000 LeftClick 1 MoveTo 614, 447 Delay 3000 LeftClick 1 MoveTo 739, 291 Delay 3000 LeftClick 1 MoveTo 952, 652 Delay 3000 LeftClick 1 End If Delay 120000 For 20 Delay 5000 IfColor 1140,680,”FFFFFF”,0 Then MoveTo 1145, 678 LeftClick 1 Delay 15000 Goto 繼續 Else MoveTo 790, 450 Delay 3000 LeftClick 1 MoveTo 728, 580 Delay 3000 LeftClick 1 End If Next
Autojs手機版教程
AutoJs最新版本apk是一款頗為實用的安卓手機免root腳本製作工具,其中的代碼都是入門級別的,有點程序基礎的用戶都能看懂,而對編程全然不知的用戶只要修改應用中的坐標和次數也能夠輕鬆完成腳本編輯,遊戲錄製、應用功能啟動等一觸即達。
一個不需要Root許可權的類似按鍵精靈的自動操作軟體,可以實現自動點擊、滑動、輸入文字、打開應用等。注意:這裡的不需要Root許可權指的是一般軟體,遊戲的自動點擊等是需要Root許可權的。
AutoJs最新版本apk特色:
1.簡單易用的自動操作函數;
2.懸浮窗錄製和運行;
3.豐富的文檔、教程與示例;
4.更專業強大的選擇器API,提供對屏幕上的控制項的尋找、遍歷、獲取信息、操作等。類似於Google的UI測試框架UiAutomator,您也可以把他當做移動版UI測試框架使用;
6.採用JavaScript為腳本語言,支持簡單的代碼補全。您也可以把他當作簡便的JavaScript IDE使用;
7.帶有界面分析工具,類似Android Studio的LayoutInspector,可以分析界面層次和範圍、獲取界面上的控制項信息;
8.支持使用Root許可權以提供更強大的屏幕點擊、滑動、錄製功能和運行shell命令。
AutoJs最新版本apk使用說明:
有些按鈕或者部件是圖標而不是文字(例如發送朋友圈的照相機圖標以及QQ下方的消息、練聯繫人、動態圖標),這是不能通過click來點擊,只能通過描述圖標所在的區域來點擊。
用js代碼做一個簡易計算器
function test(){
var txt1 = document.getElementById(“txt1”),
txt2 = document.getElementById(“txt2”),
txt3 = document.getElementById(“txt3”),
opt = document.getElementById(“sel”);
txt3.value = eval(txt1.value + opt.value + txt2.value);//eval函數可計算某個字元串,並執行其中的的js代碼
}
input type=”text” id=”txt1″ /
select id=”sel”
option value=”+”+/option
option value=”-“-/option
option value=”*”*/option
option value=”/”//option
/select
input type=”text” id=”txt2″ /
=
input type=”text” id=”txt3″ /
input type=”button” id=”btn” value=”計算” onclick=”test()”/
如何使用javascript編寫一個計算器
首先,由於JS的存在數值的精度誤差問題:
0.1+0.2 //0.30000000000000004
0.3-0.1 //0.19999999999999998
所以在編寫計算器是應首先解決計算精度問題,以下四個代碼段分別是js中精確的加減乘除運算函數
//浮點數加法運算
function floatAdd(arg1,arg2){
var r1,r2,m;
try{r1=arg1.toString().split(“.”)[1].length}catch(e){r1=0}
try{r2=arg2.toString().split(“.”)[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2));
return (arg1*m+arg2*m)/m
}
//浮點數減法運算
function floatSub(arg1,arg2){
var r1,r2,m,n;
try{r1=arg1.toString().split(“.”)[1].length}catch(e){r1=0}
try{r2=arg2.toString().split(“.”)[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2));
//動態控制精度長度
n=(r1=r2)?r1:r2;
return ((arg1*m-arg2*m)/m).toFixed(n);
}
//浮點數乘法運算
function floatMul(arg1,arg2){
var m=0,s1=arg1.toString(),s2=arg2.toString();
try{m+=s1.split(“.”)[1].length}catch(e){}
try{m+=s2.split(“.”)[1].length}catch(e){}
return Number(s1.replace(“.”,””))*Number(s2.replace(“.”,””))/Math.pow(10,m)
}
//浮點數除法運算
function floatDiv(arg1,arg2) {
var t1 = 0, t2 = 0, r1, r2;
try {t1 = arg1.toString().split(“.”)[1].length} catch (e) {}
try {t2 = arg2.toString().split(“.”)[1].length} catch (e) {}
with (Math) {
r1 = Number(arg1.toString().replace(“.”, “”));
r2 = Number(arg2.toString().replace(“.”, “”));
return (r1 / r2) * pow(10, t2 – t1);
}
}
以下是詳細的計算器代碼:
HTML5
!DOCTYPE html
html lang=”en”
head
meta charset=”UTF-8″
title簡單計算器/title
link href=”main.css” rel=”stylesheet”
/head
body
div id=”calculator”
div id=”calculator_container”
h3計算器/h3
table id=”calculator_table”
tbody
tr
td colspan=”5″
input type=”text” id=”resultIpt” readonly=”readonly” value=”” size=”17″ maxlength=”17″ style=”width:294px;color: black”
/td
/tr
tr
tdinput type=”button” value=”←” class=”btn_color1 btn_operation”/td
tdinput type=”button” value=”全清” class=”btn_color1 btn_operation”/td
tdinput type=”button” value=”清屏” class=”btn_color1″/td
tdinput type=”button” value=”﹢/﹣” class=”btn_color2 btn_operation”/td
tdinput type=”button” value=”1/×” class=”btn_color2 btn_operation”/td
/tr
tr
tdinput type=”button” value=”7″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”8″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”9″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”÷” class=”btn_color4 btn_operation”/td
tdinput type=”button” value=”%” class=”btn_color2 btn_operation”/td
/tr
tr
tdinput type=”button” value=”4″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”5″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”6″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”×” class=”btn_color4 btn_operation”/td
tdinput type=”button” value=”√” class=”btn_color2 btn_operation”/td
/tr
tr
tdinput type=”button” value=”1″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”2″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”3″ class=”btn_color3 btn_number”/td
tdinput type=”button” value=”-” class=”btn_color4 btn_operation”/td
td rowspan=”2″
input type=”button” value=”=” class=”btn_color2″ style=”height: 82px” id=”simpleEqu”
/td
/tr
tr
td colspan=”2″
input type=”button” value=”0″ class=”btn_color3 btn_number” style=”width:112px”
/td
tdinput type=”button” value=”.” class=”btn_color3 btn_number” /td
tdinput type=”button” value=”+” class=”btn_color4 btn_operation”/td
/tr
/tbody
/table
/div
/div
script type=”text/javascript” src=”calculator.js”/script
/body
/html
CSS3
* {
margin: 0;
padding: 0;
}
#calculator{
position: relative;
margin: 50px auto;
width: 350px;
height: 400px;
border: 1px solid gray;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 2px 2px 4px gray;
-moz-box-shadow: 2px 2px 4px gray;
box-shadow: 2px 2px 4px gray;
behavior:url(“ie-css3.htc”); /*IE8-*/
}
#calculator_table{
position: relative;
margin: 10px auto;
border-collapse:separate;
border-spacing:10px 20px;
}
h3{
position: relative;
width: 60px;
height: 30px;
margin: 0 auto;
}
#calculator_table td{
width: 50px;
height: 30px;
border: 1px solid gray;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
behavior:url(“ie-css3.htc”); /*IE8-*/
}
#calculator_table td input{
font-size: 16px;
border: none;
width: 50px;
height: 30px;
color: white;
}
input.btn_color1{
background-color: orange;
}
input.btn_color2{
background-color: #133645;
}
input.btn_color3{
background-color: #59807d;
}
input.btn_color4{
background-color: seagreen;
}
input:active{
-webkit-box-shadow: 3px 3px 3px gray;
-moz-box-shadow: 3px 3px 3px gray;
box-shadow: 3px 3px 3px gray;
behavior:url(“ie-css3.htc”); /*IE8-*/
}
JS
window.onload=function() {
var resultIpt = document.getElementById(“resultIpt”); //獲取輸出文本框
var btns_number = document.getElementsByClassName(“btn_number”); //獲取數字輸入按鈕
var btns_operation = document.getElementsByClassName(“btn_operation”); //獲取操作按鈕
var simpleEqu = document.getElementById(“simpleEqu”); //獲取”=”按鈕
var temp = “”;
var num1= 0,num2=0;
//獲取第一個數
for(var i=0;ibtns_number.length;i++){
btns_number[i].onclick=function (){
temp += this.value;
resultIpt.value = temp;
};
}
//對獲取到的數進行操作
for(var j=0;jbtns_operation.length;j++) {
btns_operation[j].onclick = function () {
num1=parseFloat(resultIpt.value);
oper = this.value;
if(oper==”1/×”){
num1 = Math.pow(num1,-1); //取倒數
resultIpt.value = num1.toString();
}else if(oper==”﹢/﹣”){ //取相反數
num1 = -num1;
resultIpt.value = num1.toString();
}else if(oper==”√”){ //取平方根
num1 =Math.sqrt(num1);
resultIpt.value = num1.toString();
}else if(oper==”←”){ //刪除個位
resultIpt.value = resultIpt.value.substring(0, resultIpt.value.length – 1);
}else if(oper==”全清”){ //清除數字
resultIpt.value = “”;
}
else{ //oper==”+” “-” “×” “÷” “%”時,繼續輸入第二數字
temp = “”;
resultIpt.value = temp;
}
}
}
//輸出結果
simpleEqu.onclick=function(){
num2=parseFloat(temp); //取得第二個數字
calculate(num1, num2, oper);
resultIpt.value = result.toString();
}
};
//定義一個計算函數
function calculate(num1, num2, oper) {
switch (oper) {
case “+”:
result=floatAdd(num1, num2); //求和
break;
case “-”:
result=floatSub(num1, num2); //求差
break;
case “×”:
result=floatMul(num1, num2); //求積
break;
case “÷”:
result=floatDiv(num1, num2); //求商
break;
case “%”:
result=num1%num2; //求餘數
break;
}
}
//精確計算
//浮點數加法運算
function floatAdd(arg1,arg2){
var r1,r2,m;
try{r1=arg1.toString().split(“.”)[1].length}catch(e){r1=0}
try{r2=arg2.toString().split(“.”)[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2));
return (arg1*m+arg2*m)/m
}
//浮點數減法運算
function floatSub(arg1,arg2){
var r1,r2,m,n;
try{r1=arg1.toString().split(“.”)[1].length}catch(e){r1=0}
try{r2=arg2.toString().split(“.”)[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2));
//動態控制精度長度
n=(r1=r2)?r1:r2;
return ((arg1*m-arg2*m)/m).toFixed(n);
}
//浮點數乘法運算
function floatMul(arg1,arg2){
var m=0,s1=arg1.toString(),s2=arg2.toString();
try{m+=s1.split(“.”)[1].length}catch(e){}
try{m+=s2.split(“.”)[1].length}catch(e){}
return Number(s1.replace(“.”,””))*Number(s2.replace(“.”,””))/Math.pow(10,m)
}
//浮點數除法運算
function floatDiv(arg1,arg2) {
var t1 = 0, t2 = 0, r1, r2;
try {t1 = arg1.toString().split(“.”)[1].length} catch (e) {}
try {t2 = arg2.toString().split(“.”)[1].length} catch (e) {}
with (Math) {
r1 = Number(arg1.toString().replace(“.”, “”));
r2 = Number(arg2.toString().replace(“.”, “”));
return (r1 / r2) * pow(10, t2 – t1);
}
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/284680.html