当前位置:网站首页>Auto. JS learning notes 17: basic listening events and UI simple click event operations
Auto. JS learning notes 17: basic listening events and UI simple click event operations
2022-07-06 05:42:00 【PYB3】
Catalog
Delete all event listening functions
Declare that I use autojs yes 4.1.1 edition
events
Enable key listening , For example, volume keys 、Home key . Key monitoring is realized by using barrier free services , If the barrier free service is not enabled, an exception will be thrown and a prompt to start .
Only after this function is successfully executed , onKeyDown
, onKeyUp
Wait for key event monitoring to be effective .
This function is available on Android 4.3 The above can be used .
Related parameters
keys.home Home key
keys.back Return key
keys.menu Menu key
keys.volume_up Volume up button
keys.volume_down Voice Down
Code example
// Enable key listening
events.observeKey();
// Monitor volume up key press
events.onKeyDown("volume_up", function(event){
toast(" Volume up ");
unregisterReceiver();
});
// Monitor the volume and press the button to pop up
events.onKeyDown("volume_down", function(event){
toast(" Volume down ");
});
// monitor Home The key bounces
events.onKeyDown("home", function(event){
toast("Home");
});
// Press the monitor menu key
events.onKeyDown("menu", function(event){
toast(" The menu key is pressed ");
});
Register touch events
- listener {Function} Parameter is Point Function of
Register a touch monitoring function . amount to on("touch", listener)
.
events.observeTouch();
// Register a touch monitor
events.onTouch(function(s){
// When a touch event occurs, the coordinates of the touch will be printed
log(s.x + ", " + s.y);
});
Delete all event listening functions
events.removeAllTouchListeners()
Button click event
Switch
ui Local code
<vertical id = "setConfigView" w = "*" h = "auto" layout_centerInParent="true" >
<Switch id = "openSwh" w = "auto" h = "auto" textStyle = "bold" textColor = "red"
text = " Accessibility " textSize="16sp" marginBottom = "15" marginRight ="10"/>
</vertical>
Click on the event code
// Button monitoring mode
ui.openSwh.on("check", function(checked) {
// When users check the accessibility option , Jump to the page and let the user open it
if(checked && auto.service == null) {
app.startActivity({
action: "android.settings.ACCESSIBILITY_SETTINGS"
});
exit();
}
if(!checked && auto.service != null){
auto.service.disableSelf(); // Turn off accessibility services
ui.openSwh.setChecked(false);
}
});
button
ui Local code
<button id = "testServerAPI" align="center"> Test interface data </button>
Click on the event code
ui.testServerAPI.click(()=>{
testAPIState = true;
getServiceInfo();
});
timepicker
ui Code
<text id = "timePickerModeText" text = " Sliding time selection :" textColor = "black" textSize="16sp" marginTop="5" />
<timepicker id = "timePickerMode" timePickerMode="spinner" />
Listen for event code
// Sliding time selection
ui.timePickerMode.setIs24HourView(true);// Set the current time control to 24 hourly
ui.timePickerMode.setHour(9); // Set the current hour
ui.timePickerMode.setMinute(0); // Set current score (0-59)
ui.timePickerMode.setOnTimeChangedListener({
onTimeChanged: function (v, h, m) {
//h Get the value of by 24 Hour format
wxAutoConfigObj.timingTime = h + ":" + m ;
ui.timePickerModeText.setText(" Sliding time selection : " + wxAutoConfigObj.timingTime);
}
});
summary
Just remember , The above are common event handling , Learn a little hip-hop every day .
It's no use just looking without knocking
After reading, we must practice
Be sure to type the code
Be sure to run trial and error
This is meaningful learning
边栏推荐
- [force buckle]43 String multiplication
- [cloud native] 3.1 kubernetes platform installation kubespher
- 无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
- 大型网站如何选择比较好的云主机服务商?
- JDBC calls the stored procedure with call and reports an error
- 进程和线程
- 28io stream, byte output stream writes multiple bytes
- Note the various data set acquisition methods of jvxetable
- [experience] when ultralso makes a startup disk, there is an error: the disk / image capacity is too small
- ArcGIS application foundation 4 thematic map making
猜你喜欢
B站刘二大人-线性回归 Pytorch
59. Spiral matrix
进程和线程
[SQL Server Express Way] - authentification et création et gestion de comptes utilisateurs
How to use PHP string query function
Unity Vector3. Use and calculation principle of reflect
巨杉数据库再次亮相金交会,共建数字经济新时代
02. 开发博客项目之数据存储
Cuda11.1 online installation
SQLite add index
随机推荐
Go language -- language constants
Migrate Infones to stm32
移植InfoNES到STM32
Check the useful photo lossless magnification software on Apple computer
Vulhub vulnerability recurrence 73_ Webmin
自建DNS服务器,客户端打开网页慢,解决办法
Improve jpopup to realize dynamic control disable
(column 22) typical column questions of C language: delete the specified letters in the string.
实践分享:如何安全快速地从 Centos迁移到openEuler
29io stream, byte output stream continue write line feed
SequoiaDB湖仓一体分布式数据库2022.6月刊
05. 博客项目之安全
【华为机试真题详解】检查是否存在满足条件的数字组合
B站刘二大人-线性回归 Pytorch
初识数据库
毕业设计游戏商城
【torch】|torch.nn.utils.clip_grad_norm_
Embedded interview questions (I: process and thread)
How to use PHP string query function
Codeforces Round #804 (Div. 2) Editorial(A-B)