吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 16394|回复: 43
收起左侧

[其他转载] 使用auto.js写的一个复杂界面,分享给大家

[复制链接]
52Douyin 发表于 2020-2-17 12:18
今天为大家献上我写的一个复制的android界面,是基于Auto.js 4.1.1开发的


界面中包含4个Frame,同学们可以自行扩展学习。


第一Frame
001.png
第2Frame

第二页

第二页


第3Frame

第三页

第三页


第4Frame

第四页

第四页






下面上代码




[JavaScript] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
"ui";
 
auto();
var color = "#000000";
//数据源
var _golDataSource;
var _golHasBind = false;//是否绑定数据
var _golFolder = "./runJs/";
/**
 * 当前刷新app的索引
 */
var _golRunIndex = 0;
 
/**
 * card按钮宽度
 */
var _golCardWidth = 0;
/**
 * card按钮高度
 */
var _golCardHeigth = 200
/**
 * 共通方法类
 */
var golRunComm = null;
/**
 * 主线程
 */
var _golThread;
/**
 * 保存窗口数据和窗口状态
 */
var _golStorage = null;
 
/**小窗体的大小 */
var floaty_window_W;
var floaty_window_H;
/**按钮名称 */
var floaty_window_BtnStr;
//-----窗口数据结束
 
var key = "default";
 
var path_img = "file://./res/assests/ewm.jpg"
 
_golCardWidth = parseInt(device.width * 0.155);
 
 
Main();//主入口
 
ui.layout(
    <drawer id="drawer">
        <vertical>
            <appbar>
                <toolbar bg="#FF5c50e6" id="toolbar" title="自动刷新" paddingTop="2dp" h="auto" >
                    <button bg="#FF00CED1" id="BtnExit" layout_gravity="right" textColor="#ffffff" text="离开" style="Widget.AppCompat.Button.Borderless.Colored" w="auto" />
                </toolbar>
                <tabs id="tabs" />
            </appbar>
            <viewpager id="viewpager">
                {/* 第一级 */}
                <frame>
                    <scroll>
                        <vertical>
                            <horizontal gravity="center_vertical">
                                <card w="{{_golCardWidth}}" h="{{_golCardHeigth}}"
                                    layout_width="0dp" layout_weight="3"
                                    margin="4" cardCornerRadius="15dp" cardBackgroundColor="#f5f5f5"
                                    cardElevation="15dp" gravity="left" foreground="?selectableItemBackground">
                                    <vertical>
                                        <linear margin="0 40 0 0">
                                            <View bg="#2196f3" h="*" w="10" />
                                            <text id="name" w="*" h="40" hint="欢迎自动刷新" />
                                        </linear>
                                        <button id="BtnStart" text="开始刷新" w="{{_golCardWidth}}" />
                                    </vertical>
                                </card>
                                <card w="{{_golCardWidth}}" h="{{_golCardHeigth}}"
                                    layout_width="0dp" layout_weight="3"
                                    margin="4" cardCornerRadius="15dp" cardBackgroundColor="#f5f5f5"
                                    cardElevation="15dp" gravity="right" foreground="?selectableItemBackground">
                                    <vertical>
                                        <linear margin="0 40 0 0">
                                            <img w="30" h="30" src="@drawable/ic_person_black_48dp" />
                                            <text id="name" w="*" h="40" hint="自动点赞" />
                                        </linear>
                                        <button text="未完成" w="{{_golCardWidth}}" />
                                    </vertical>
                                </card>
                            </horizontal>
                            <horizontal gravity="center_vertical">
                                <card w="{{_golCardWidth}}" h="{{_golCardHeigth}}"
                                    layout_width="0dp" layout_weight="3"
                                    margin="4" cardCornerRadius="15dp" cardBackgroundColor="#f5f5f5"
                                    cardElevation="15dp" gravity="left" foreground="?selectableItemBackground">
                                    <vertical>
                                        <linear margin="0 40 0 0">
                                            <View bg="#2196f3" h="*" w="10" />
                                            <text id="name" w="*" h="40" hint="公众号'学生快乐编程'" />
                                        </linear>
                                        <button text="未完成" w="{{_golCardWidth}}" />
                                    </vertical>
                                </card>
                                <card w="{{_golCardWidth}}" h="{{_golCardHeigth}}"
                                    layout_width="0dp" layout_weight="3"
                                    margin="4" cardCornerRadius="15dp" cardBackgroundColor="#f5f5f5"
                                    cardElevation="15dp" gravity="right" foreground="?selectableItemBackground">
                                    <vertical>
                                        <linear margin="0 40 0 0">
                                            <img w="30" h="30" src="@drawable/ic_person_black_48dp" />
                                            <text id="name" w="*" h="40" hint="预留功能" />
                                        </linear>
                                        <button text="未完成" w="{{_golCardWidth}}" />
                                    </vertical>
                                </card>
                            </horizontal>
 
                            <vertical h="auto" align="center" marginTop="1">
                                <img layout_gravity="center" src="{{path_img}}" w="120" h="120" />
                                <text w="auto" glayout_gravity="center" color="#111111" size="13" text="关注公众号:学生快乐编程" />
                            </vertical>
 
                        </vertical>
                    </scroll>
                </frame>
                {/*
                第二级
                 注释:
                 -修改排序内容 */}
                <frame>
                    <vertical>
                        <horizontal weightSum="8" bg='#FF5c50e6'>
                            <button layout_width="0dp" layout_weight="4" id="BtnSave" text="手动保存" />
                            <button layout_width="0dp" layout_weight="4" id="BtnBegin" text="开始刷新" />
                        </horizontal>
                        <scroll>
                            <vertical>
                                <card id="card0" w="*" h="70" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                    <horizontal gravity="center_vertical">
                                        <View bg="#000080" h="*" w="10" />
                                        <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                            <text id="appCnName0" text="" textColor="#222222" textSize="14sp" maxLines="1" />
                                            <text id="filepath0" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                            <text id="app0" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                        </vertical>
                                        <text w="auto" gravity="right" color="#111111" size="13" text="排序" />
                                        <input id="sortid0" text="" textSize="13sp" maxLines="1" inputType="number" />
                                        <text w="auto" gravity="right" color="#111111" size="13" text="(秒)" />
                                        <input id="t0" w="auto" gravity="right" textSize="13sp" text="" inputType="number" />
                                        <checkbox id="done0" marginLeft="4" marginRight="6" checked="true" />
                                    </horizontal>
                                </card>
 
                                <card id="card1" w="*" h="70" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                    <horizontal gravity="center_vertical">
                                        <View bg="#00008B" h="*" w="10" />
                                        <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                            <text id="appCnName1" text="" textColor="#222222" textSize="14sp" maxLines="1" />
                                            <text id="filepath1" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                            <text id="app1" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                        </vertical>
                                        <text w="auto" gravity="right" color="#111111" size="13" text="排序" />
                                        <input id="sortid1" text="" textSize="13sp" maxLines="1" inputType="number" />
                                        <text w="auto" gravity="right" color="#111111" size="13" text="(秒)" />
                                        <input id="t1" w="auto" gravity="right" textSize="13sp" text="" inputType="number" />
                                        <checkbox id="done1" marginLeft="4" marginRight="6" checked="false" />
                                    </horizontal>
                                </card>
 
                                <card id="card2" w="*" h="70" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                    <horizontal gravity="center_vertical">
                                        <View bg="#0000CD" h="*" w="10" />
                                        <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                            <text id="appCnName2" text="" textColor="#222222" textSize="14sp" maxLines="1" />
                                            <text id="filepath2" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                            <text id="app2" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                        </vertical>
                                        <text w="auto" gravity="right" color="#111111" size="13" text="排序" />
                                        <input id="sortid2" text="" textSize="13sp" maxLines="1" inputType="number" />
                                        <text w="auto" gravity="right" color="#111111" size="13" text="(秒)" />
                                        <input id="t2" w="auto" gravity="right" textSize="13sp" text="" inputType="number" />
                                        <checkbox id="done2" marginLeft="4" marginRight="6" checked="false" />
                                    </horizontal>
                                </card>
 
                                <card id="card3" w="*" h="70" margin="10 5" cardCornerRadius="2dp"
                                    cardElevation="1dp" foreground="?selectableItemBackground">
                                    <horizontal gravity="center_vertical">
                                        <View bg="#0000FF" h="*" w="10" />
                                        <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                            <text id="appCnName3" text="" textColor="#222222" textSize="14sp" maxLines="1" />
                                            <text id="filepath3" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                            <text id="app3" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                        </vertical>
                                        <text w="auto" gravity="right" color="#111111" size="13" text="排序" />
                                        <input id="sortid3" textSize="13sp" maxLines="1" inputType="number" />
                                        <text w="auto" gravity="right" color="#111111" size="13" text="(秒)" />
                                        <input id="t3" w="auto" gravity="right" textSize="13sp" text="" inputType="number" />
                                        <checkbox id="done3" marginLeft="4" marginRight="6" checked="false" />
                                    </horizontal>
                                </card>
 
                                <card id="card4" w="*" h="70" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                    <horizontal gravity="center_vertical">
                                        <View bg="#00BFFF" h="*" w="10" />
                                        <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                            <text id="appCnName4" text="" textColor="#222222" textSize="14sp" maxLines="1" />
                                            <text id="filepath4" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                            <text id="app4" text="" textColor="#999999" textSize="12sp" maxLines="1" />
                                        </vertical>
                                        <text w="auto" gravity="right" color="#111111" size="13" text="排序" />
                                        <input id="sortid4" textSize="13sp" maxLines="1" inputType="number" />
                                        <text w="auto" gravity="right" color="#111111" size="13" text="(秒)" />
                                        <input id="t4" w="auto" gravity="right" textSize="13sp" text="" inputType="number" />
                                        <checkbox id="done4" marginLeft="4" marginRight="6" checked="false" />
                                    </horizontal>
                                </card>
 
 
                            </vertical>
                        </scroll>
                    </vertical>
                </frame>
                {/*
                    第三级
                 ?第二层结束? */}
                <frame>
                    <com.stardust.autojs.core.console.ConsoleView id="console" h="*" />
                </frame>
                {/*
                    第四级
                 ?第四层结束? */}
                <frame>
                <card id="card4" w="*" h="100" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                    <horizontal gravity="center_vertical">
                                        <View bg="#00BFFF" h="*" w="10" />
                                        <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                        <text w="auto" color="#111111" size="16" text="1、需要启动无障碍服务。" />
                                        <text w="auto" color="#111111" size="16" text="2、允许app显示在其他应用的上层。" />
                                        </vertical>  
                                        
                                    </horizontal>
                                </card>
                </frame>
                {/*
                    第五级
                 ?第五层结束? */}
                <frame>
                    <text w="auto" gravity="right" color="#111111" size="16" text="          第四页:关注公众号学生快乐编程" />
 
                </frame>
            </viewpager>
        </vertical>
        <vertical layout_gravity="left" bg="#ffffff" w="280">
            <img w="280" h="200" scaleType="fitXY" />
            <list id="menu">
                <horizontal bg="?selectableItemBackground" w="*">
                    <img w="50" h="50" padding="16" src="{{this.icon}}" tint="{{color}}" />
                    <text textColor="black" textSize="15sp" text="{{this.title}}" layout_gravity="center" />
                </horizontal>
            </list>
        </vertical>
    </drawer>
);
 
 
 
/**复选框 开始*/
//绑定勾选框事件
ui.done0.on("check", function (checked) {
    log("ck-" + checked);
 
    if (checked) {
        ui.card0.attr("bg", "#F5f5f5");
    } else {
        ui.card0.attr("bg", "#999999");
    }
 
});
/**复选框 结束*/
activity.setSupportActionBar(ui.toolbar);
 
//设置滑动页面的标题
ui.viewpager.setTitles(["主页", "配置", "日志", "帮助", "About"]);
//让滑动页面和标签栏联动
ui.tabs.setupWithViewPager(ui.viewpager);
 
//让工具栏左上角可以打开侧拉菜单
ui.toolbar.setupWithDrawer(ui.drawer);
 
/**
 * 页面头部选项卡更改侦听器
 * */
ui.viewpager.setOnPageChangeListener({
    //已选定页面发生改变时触发
    onPageSelected: function (index) {
        if (index == 1 && _golHasBind == false) {
            /**
            * 绑定,填充数据
            */
            bindDdata();
        } else if (index == 2) {
            /**控制台 */
            ui.console.setConsole(runtime.console);
            // ui.console.findViewById(org.autojs.autojs.R.id.input_container).setVisibility(android.view.View.GONE);
            //ui.console.setConsole(org.autojs.autojs.autojs.AutoJs.getInstance().getGlobalConsole());           
 
            // 设置控制台字体颜色
            let c = new android.util.SparseArray();
            let Log = android.util.Log;
            c.put(Log.VERBOSE, new java.lang.Integer(colors.parseColor("#dfc0c0c0")));
            c.put(Log.DEBUG, new java.lang.Integer(colors.parseColor("#cc000000")));
            c.put(Log.INFO, new java.lang.Integer(colors.parseColor("#ff64dd17")));
            c.put(Log.WARN, new java.lang.Integer(colors.parseColor("#ff2962ff")));
            c.put(Log.ERROR, new java.lang.Integer(colors.parseColor("#ffd50000")));
            c.put(Log.ASSERT, new java.lang.Integer(colors.parseColor("#ffff534e")));
            ui.console.setColors(c);
            /**控制台 */
        }
 
    }
})
 
/**
 * 主入口程序
 */
function Main() {
    log("main");
 
    engines.all().slice(1).forEach(script => {
        if (script.getSource().getName().indexOf(engines.myEngine().getSource())) {
            toastLog("脚本正在运行中");
            engines.myEngine().forceStop();
        }
    });
 
    ui.statusBarColor(color);
 
    _golDataSource = LoadConfig();
    _golStorage = storages.create("asianbest.vip");
 
    log("winW=" + _golStorage.get("winW"));
    log("winH=" + _golStorage.get("winH") + "-btnText-" + _golStorage.get("btnText"));
 
 
    floaty_window_W = 120;
    floaty_window_H = 120;
    floaty_window_BtnStr = "小化";
}
 
 
/**
 * 将数据填充到UI中
 */
function bindDdata() {
 
    for (let k = 0; k < _golDataSource.length; k++) {
 
        ui["filepath" + k].setText(_golDataSource[k].filepath);
 
        let appEn = _golDataSource[k].app;
        ui["app" + k].setText(appEn);
 
 
        let appCn = getAppName(appEn);
        if (null == appCn) {
 
            ui["done" + k].checked = false;
            ui["card" + k].attr("bg", "#999999");
            ui["appCnName" + k].setText(appEn);
        }
        else {
 
            ui["done" + k].checked = true;
            ui["card" + k].attr("bg", "#F5f5f5");
            ui["appCnName" + k].setText(appCn);
        }
 
        let isRun = _golDataSource[k].Run;
        if ("0" == isRun) {
            ui["done" + k].checked = false;
            ui["card" + k].attr("bg", "#A9A9A9");
        }
 
        ui["sortid" + k].setText(_golDataSource[k].sortid);
        ui["t" + k].setText(_golDataSource[k].t);
    }
    _golHasBind = true;
}
 
/**
 * 读取config文件
 */
function LoadConfig() {
 
    let _txtFile = _golFolder + "config.txt";
 
    if (files.exists(_txtFile)) {
 
        toast('读取文件' + _txtFile);
 
        var jsonStr = files.read(_txtFile);
        setTimeout(() => {
            toastLog("读取文件。");
        }, 400);
        var commFun = require(_golFolder + "CommonFun.js");
        golRunComm = new commFun();
 
        /**
        *对数组重新排序
        */
        let obj = golRunComm.ReSort(eval('(' + jsonStr + ')'));
        setTimeout(() => {
            toastLog("文件解析完成。");
        }, 400);
 
        return obj;
    }
 
}
 
/**保存按钮 */
ui.BtnSave.on("click", function () {
 
    let str = "[";
 
    for (let k = 0; k < _golDataSource.length; k++) {
 
        str += "{\"filepath\":\"" + ui["filepath" + k].text() + "\",";
        str += "\"app\":\"" + ui["app" + k].text() + "\","
        str += "\"sortid\":\"" + ui["sortid" + k].text() + "\",";
        str += "\"t\":\"" + ui["t" + k].text() + "\"}";
        if (k < _golDataSource.length - 1) {
            str += ",";
        }
    }
 
    str += "]";
 
    _golDataSource = golRunComm.ReSort(eval('(' + str + ')'));
 
    let _txtFile = _golFolder + "config.txt";
    files.write(_txtFile, str);
 
    setTimeout(() => {
        toastLog("修改文件。");
    }, 1500);
 
    bindDdata();
    setTimeout(() => {
        toastLog("更新UI界面。");
    }, 1500);
});
/**
 * 启动刷新程序
 */
ui.BtnStart.on("click", () => {
    ui.BtnStart.setText("暂停");
    ui.BtnBegin.setText("暂停");
    _golThread = threads.start(function () {
        log("Start日志");
        xuanfuchuang();
        log("启动子线程");
        ThreadStart();
    });
});
ui.BtnBegin.on("click", () => {
    ui.BtnStart.setText("暂停");
    ui.BtnBegin.setText("暂停");
    _golThread = threads.start(function () {
        log("Start日志");
        xuanfuchuang();
        log("启动子线程");
        ThreadStart();
    });
});
/**
 * 退出程序
 */
ui.BtnExit.on("click", () => {
    if (_golThread && _golThread.isAlive()) {
        log("线程" + _golThread.isAlive());
        _golThread.interrupt();
    }
    ui.finish();
});
 
function ThreadStart() {
    log("线程启动>>" + _golDataSource[0].filepath);
 
    Help(_golFolder + _golDataSource[_golRunIndex].filepath,
        _golDataSource[_golRunIndex].app,
        _golDataSource[_golRunIndex].t,
        getAppName(_golDataSource[_golRunIndex].app));
 
 
}
 
/**
*
* [url=home.php?mod=space&uid=952169]@Param[/url] {js路径} _path
* @param {app包名称} _appName
* @param {执行时间长度} _times
* @param {包中文名} _cn
*/
function Help(_path, _appName, _times, _cn) {
    var myObj = require(_path);
    var unlock = new myObj(_appName, _times, _cn, golRunComm);
    unlock.RunApp();
    Calc_golRunIndex();
    ThreadStart();
}
 
 
function xuanfuchuang() {
    w = floaty.window(
        <frame id="action" bg="#90251911" w="{{floaty_window_W}}" h="{{floaty_window_H}}" padding="2">
            <linear w="*" h='*'>
                <vertical gravity="left" padding="-1">
                    <button id="Bmin" text="{{floaty_window_BtnStr}}" w="40" h="40" textSize="8sp" />
                    <button id="yidong" text="移动" w="40" h="40" textSize="8sp" />
                    <button id="tuichu" text="退出" w="40" h="40" textSize="8sp" />
                </vertical>
                <vertical padding="0">
                    <vertical>
                        <com.stardust.autojs.core.console.ConsoleView id="ConS" margin="1" textSize="8sp" />
                    </vertical>
                </vertical>
            </linear>
        </frame>
    );
 
    setInterval(() => { }, 1000);
    /**
     * 设定窗体位置
     */
    log("窗体位置" + _golStorage.get("winx") + " pos " + _golStorage.get("winy"));
 
    if (_golStorage.get("winx") && _golStorage.get("winy")) {
        w.setPosition(_golStorage.get("winx"), _golStorage.get("winy"));
    } else {
        w.setPosition(5, 1000);
    }
 
    ui.run(() => {
        w.ConS.setConsole(runtime.console);
        //w.ConS.setConsole(org.autojs.autojs.autojs.AutoJs.getInstance().getGlobalConsole());
        //w.ConS.findViewById(org.autojs.autojs.R.id.input_container).setVisibility(android.view.View.GONE);
    });
 
    w.tuichu.click(() => {
        log("线程" + _golThread.isAlive());
 
        ui.BtnStart.setText("重启");
        ui.BtnBegin.setText("重启");
 
        Calc_golRunIndex();
 
        if (_golThread && _golThread.isAlive()) {
            _golThread.interrupt();
        }
        toastLog("退出线程 >>");
        w.close();
 
    });
 
    var x = 0, y = 0;
    var windowX, windowY;
    var downTime;
    ui.run(function () {
        windowWidth = w.getWidth();
        windowHeight = w.getHeight();
    }
    );
    /**最小化显示 */
    w.Bmin.setOnTouchListener(function (view, event) {
        switch (event.getAction()) {
            case event.ACTION_DOWN:
                x = event.getRawX();
                y = event.getRawY();
                windowX = w.getX();
                windowY = w.getY();
 
                return true;
            case event.ACTION_MOVE:
 
                let wx = windowX + (event.getRawX() - x);
                let wy = windowY + (event.getRawY() - y);
                w.setPosition(wx, wy);
                SaveFloatWinPos(wx, wy);
                SaveFloatWinStates(190, 190, w.Bmin.text());
                return true;
            case event.ACTION_UP:
 
                if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
                    if (w.Bmin.text() == "小化") {
                        w.Bmin.setText("大化");
                        w.setSize(190, 190);
                        SaveFloatWinStates(190, 190, w.Bmin.text());
                    } else {
                        w.Bmin.setText("小化");
                        w.setSize(windowWidth, windowHeight);
                        SaveFloatWinStates(windowWidth, windowHeight, w.Bmin.text());
                    }
                }
                return true;
        }
        return true;
    });
    /**移动窗体 */
    w.yidong.setOnTouchListener(function (view, event) {
        switch (event.getAction()) {
            case event.ACTION_DOWN:
                x = event.getRawX();
                y = event.getRawY();
                aw = w.getWidth();
                ah = w.getHeight();
                windowX = w.getX();
                windowY = w.getY();
                downTime = new Date().getTime();
                return true;
            case event.ACTION_MOVE:
 
                w.setPosition(windowX + (event.getRawX() - x),
                    windowY + (event.getRawY() - y));
                return true;
            case event.ACTION_UP:
 
                SaveFloatWinPos(w.getX(), w.getY());
                return true;
        }
        return true;
    });
    /**
     * 保存窗体的坐标
     * @_x x坐标
     * @_y y坐标
     */
    function SaveFloatWinPos(_x, _y) {
        _golStorage.put("winx", _x);
        _golStorage.put("winy", _y);
    };
    /**
    * 保存窗体的状态
    * _states 窗体大小
    */
    function SaveFloatWinStates(_winW, _winH, _btnStr) {
        _golStorage.put("winW", _winW);
        _golStorage.put("winH", _winH);
        _golStorage.put("btnText", _btnStr);
    };
 
}
 
/**
 * 计算当前正在运行的app索引
 * 每次循环完成,自动+1;
 * 当手动停止的时候,自动+1
 *
*/
function Calc_golRunIndex() {
 
    _golRunIndex++;
    if (_golRunIndex >= (_golDataSource.length)) {
        _golRunIndex = 0;
    }
};



同学也可以自行下载,代码放到手机根目录的‘脚本’目录下面

链接:https://pan.baidu.com/s/1Mtr_ukmBRHzdj6rHgeEIug
提取码:xahq


第一页

第一页

免费评分

参与人数 3吾爱币 +1 热心值 +3 收起 理由
炙焱閻羅 + 1 热心回复!
androllen + 1 谢谢@Thanks!
19175822732 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

可以叫我霸霸吗 发表于 2020-3-8 10:32
一按配置就出错,什么原因呢?
 楼主| 52Douyin 发表于 2020-2-17 23:09
伤心小王子 发表于 2020-2-17 18:24
楼主你好,我最近也在学习auto.js,请问一下有没有比较全面的教程推荐一下呀,b站上的视频都只有一点点,谢 ...

我学习了3个月了,如果有需要,我们可以相互交流啊。原来的开发者已经不维护了。我以前做web前端好久,js还比较熟悉。
破碎ぃ 发表于 2020-2-17 13:37
 楼主| 52Douyin 发表于 2020-2-17 14:24
第一次发帖,感谢大家支持!
发帖成功啦!
BlovedCQ 发表于 2020-2-17 18:23
内容丰富,慢慢消化,感谢楼主
伤心小王子 发表于 2020-2-17 18:24
楼主你好,我最近也在学习auto.js,请问一下有没有比较全面的教程推荐一下呀,b站上的视频都只有一点点,谢谢啦
伤心小王子 发表于 2020-2-18 13:50
52Douyin 发表于 2020-2-17 23:09
我学习了3个月了,如果有需要,我们可以相互交流啊。原来的开发者已经不维护了。我以前做web前端好久,js ...

好啊,留个联系方式吧,谢谢啦
 楼主| 52Douyin 发表于 2020-2-18 16:30
伤心小王子 发表于 2020-2-18 13:50
好啊,留个联系方式吧,谢谢啦

加我vx   DY_CWXJL
sumengzhenyue 发表于 2020-2-19 00:32
很好的帖子,感谢分享
dotdot8 发表于 2020-2-19 12:48
本帖最后由 dotdot8 于 2020-2-19 12:53 编辑

楼主,能不能分享一下图2中显示的代码,就加入到你这个帖子的源码盘的目录里,好让小白我可以学习学习
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-25 03:11

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表