api: threads, events

This commit is contained in:
hyb1996
2017-12-28 21:21:41 +08:00
parent 729958d419
commit 3647cef81b
13 changed files with 394 additions and 34 deletions

View File

@@ -0,0 +1,23 @@
auto();
threads.start(function(){
//在子线程中调用observeKey()从而使按键事件处理在子线程执行
events.observeKey();
events.on("key_down", function(keyCode, events){
//音量键关闭脚本
if(keyCode == keys.volume_up){
exit();
}
});
});
toast("音量上键关闭脚本");
events.on("exit", function(){
toast("脚本已结束");
});
while(true){
log("脚本运行中...");
sleep(2000);
}