├── .build
├── default.Manifest.xml
├── default.init.aardio
└── default.main.aardio
├── .gitignore
├── LICENSE
├── README.md
├── config
├── length.table
└── setting.table
├── default.aproj
├── dlg
├── child.aardio
├── setting.aardio
└── test.aardio
├── lib
├── config.aardio
└── transaction.aardio
└── main.aardio
/.build/default.Manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 | 休息一下
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
52 |
53 |
54 |
55 |
56 |
57 | True/PM
58 |
59 |
60 |
--------------------------------------------------------------------------------
/.build/default.init.aardio:
--------------------------------------------------------------------------------
1 | //发布前触发
2 | import ide;
--------------------------------------------------------------------------------
/.build/default.main.aardio:
--------------------------------------------------------------------------------
1 | //此触发器在生成EXE以后执行
2 | import ide;
3 | import fsys;
4 |
5 | //获取生成的EXE文件路径
6 | var publishFile = ide.getPublishPath();
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /dist
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Hookin.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rest
2 |
3 | windows 平台休息提醒工具,使用 arrdio 语言编写。**不完善,将尝试用中介者模式重写。**
4 |
5 | 
6 |
7 | ## 功能:
8 |
9 | - 小憩
10 |
11 | - 休息(基于小憩的间隔次数)
12 |
13 | - 稍后提醒
14 |
15 | - 下次提醒
16 |
17 | - 多显示器
18 |
19 | - 空闲时间暂停(鼠标和键盘空闲 `>=5` 分钟触发)
20 |
21 | ## todo
22 |
23 | - [ ] 开机启动
24 |
--------------------------------------------------------------------------------
/config/length.table:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/config/setting.table:
--------------------------------------------------------------------------------
1 | {
2 | anap={time_s=40;free_m=20;userd=true};
3 | late={anap=true;rest=false};
4 | rest={time_m=5;mode="anap";free_anap=2;userd=true};
5 | pass={anap=true;rest=false}
6 | }
--------------------------------------------------------------------------------
/default.aproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/dlg/child.aardio:
--------------------------------------------------------------------------------
1 | import win.ui;
2 | /*DSG{{*/
3 | var winform = win.form(text="休息一下";left=0;top=0;right=600;bottom=600;bgcolor=8421376;border="none";exmode="toolwindow";mode="popup")
4 | winform.add(
5 | date={cls="static";text="11月11日 星期八";left=100;top=160;right=500;bottom=208;align="center";aw=1;color=15793151;font=LOGFONT(h=-27;name='微软雅黑');transparent=1;z=4};
6 | mainBtn={cls="static";text='\u23F3 稍后提醒 (ctrl + x)';left=100;top=540;right=500;bottom=570;align="center";aw=1;color=15793151;font=LOGFONT(h=-20;name='微软雅黑');notify=1;transparent=1;z=1};
7 | progress={cls="plus";left=200;top=360;right=400;bottom=372;aw=1;border={color=-1040;radius=10;width=2};forecolor=15793151;z=2};
8 | static2={cls="static";text="10s";left=200;top=368;right=400;bottom=392;align="center";aw=1;color=15793151;font=LOGFONT(h=-18;name='微软雅黑');transparent=1;z=6};
9 | static4={cls="static";text="活动身体,看向远方……";left=100;top=264;right=500;bottom=328;align="center";aw=1;color=15793151;font=LOGFONT(h=-37;name='微软雅黑');transparent=1;z=5};
10 | time={cls="static";text="11:11";left=200;top=72;right=400;bottom=152;align="center";aw=1;color=15793151;font=LOGFONT(h=-70;name='微软雅黑');ownerDraw=1;transparent=1;z=3}
11 | )
12 | /*}}*/
13 |
14 | import thread.event;
15 | import thread.table;
16 | var timeEvent = thread.event("time_s GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
17 | var shareT = thread.table("shareT");
18 | var remainNum=0;
19 | win.setTopmost(winform.hwnd);
20 | winform.progress.setProgressRange(0,1000);
21 |
22 | // 屏蔽 alt + F4;设置 ctrl + x 关闭
23 | import win.ui.accelerator;
24 | var accelerator = win.ui.accelerator({
25 | {
26 | alt = true; vkey = 0x73/*_VK_F4*/;
27 | };
28 | {
29 | ctrl = true; vkey = 'X'#; oncommand = function(id,event){ timeEvent.set(); }
30 | };
31 | },winform );
32 |
33 |
34 |
35 | winform.mainBtn.oncommand = function(id,event){
36 | timeEvent.set();
37 | }
38 |
39 | winform.mainBtn.wndproc = function(hwnd,message,wParam,lParam){
40 | import win.cur;
41 | if(message=0x200/*_WM_MOUSEMOVE*/){
42 | win.cur.load(32649/*_IDC_HAND*/)
43 | win.cur.setCur()
44 | }
45 | }
46 |
47 | var IntervalID=winform.setInterval(
48 | -1,function(){
49 | import time;
50 |
51 |
52 | winform.time.text=tostring(time(,"%H:%M:%S"));
53 | winform.date.text=tostring(time(,"%Y-%m-%d, %A"));
54 |
55 | //var remainNum= shareT.showTime-(time().getMilliTime()-inTime)
56 |
57 | winform.progress.stepProgress(-math.round(1000/(shareT.showTime/1000+1)));
58 |
59 |
60 | winform.static2.text=math.round(remainNum)+"s";
61 | remainNum-=1;
62 |
63 | }
64 | )
65 | winform.wndproc = function(hwnd,message,wParam,lParam){
66 | if(message=0x18/*_WM_SHOWWINDOW*/&&wParam=true){
67 | //在当前显示器全屏置顶
68 | import sys.monitor;
69 | win.setRect(winform.hwnd,sys.monitor.getInfoFromWindow( winform.hwnd).rcMonitor);
70 | win.setForeground(winform.hwnd)
71 | win.setTopmost(winform.hwnd);
72 |
73 | winform.progress.stepProgress(1000);
74 | remainNum=shareT.showTime/1000;
75 | winform.changeInterval(IntervalID,1000);
76 | winform.mainBtn.show(true)
77 | if(shareT.hasLate&&shareT.lateNum<2){
78 | winform.mainBtn.text="⏳ 稍后提醒 (ctrl + x)"
79 | }elseif(shareT.hasPass){
80 | winform.mainBtn.text="⏳ 下次提醒 (ctrl + x)"
81 | }else {
82 | winform.mainBtn.show(false)
83 | }
84 | return true;
85 |
86 | }elseif(message=0x18/*_WM_SHOWWINDOW*/&&wParam=false){
87 | winform.changeInterval(IntervalID,-1);
88 | }
89 |
90 | }
91 |
92 |
93 | win.loopMessage();
94 | return winform;
--------------------------------------------------------------------------------
/dlg/setting.aardio:
--------------------------------------------------------------------------------
1 | import win.ui;
2 | /*DSG{{*/
3 | var winform = win.form(text="休息一下 - 设置";right=351;bottom=567;max=false)
4 | winform.add(
5 | anap={cls="checkbox";text="小憩 - 稍作休息";left=24;top=48;right=264;bottom=72;checked=1;disabled=1;font=LOGFONT(h=-13;name='微软雅黑');z=2};
6 | anapFree={cls="static";text="1";left=264;top=80;right=296;bottom=96;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=11};
7 | anapTime={cls="static";text="1";left=264;top=104;right=296;bottom=120;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=20};
8 | apple={cls="button";text="应用修改";left=8;top=528;right=344;bottom=560;font=LOGFONT(h=-13;name='微软雅黑');z=36};
9 | checkbox3={cls="checkbox";text="开机启动";left=24;top=480;right=160;bottom=504;disabled=1;font=LOGFONT(h=-13;name='微软雅黑');z=28};
10 | groupbox={cls="groupbox";text="设置时间";left=8;top=16;right=344;bottom=280;font=LOGFONT(h=-13;name='微软雅黑');z=1};
11 | groupbox2={cls="groupbox";text="允许稍后提醒";left=8;top=288;right=344;bottom=360;edge=1;font=LOGFONT(h=-13;name='微软雅黑');z=21};
12 | groupbox3={cls="groupbox";text="允许跳过提醒 - 稍后提醒两次后显示";left=8;top=368;right=344;bottom=440;edge=1;font=LOGFONT(h=-13;name='微软雅黑');z=24};
13 | groupbox4={cls="groupbox";text="其他设置";left=8;top=448;right=344;bottom=520;edge=1;font=LOGFONT(h=-13;name='微软雅黑');z=27};
14 | isAnapMode={cls="radiobutton";text="Radiobutton";left=32;top=216;right=48;bottom=232;z=32};
15 | isTimeMode={cls="radiobutton";text="Radiobutton";left=32;top=192;right=48;bottom=208;disabled=1;group=1;z=31};
16 | lateAnap={cls="checkbox";text="小憩";left=24;top=320;right=160;bottom=344;checked=1;font=LOGFONT(h=-13;name='微软雅黑');z=22};
17 | lateRest={cls="checkbox";text="休息";left=192;top=320;right=328;bottom=344;checked=1;font=LOGFONT(h=-13;name='微软雅黑');z=23};
18 | passAnap={cls="checkbox";text="小憩";left=24;top=400;right=160;bottom=424;checked=1;font=LOGFONT(h=-13;name='微软雅黑');z=25};
19 | passRest={cls="checkbox";text="休息";left=192;top=400;right=328;bottom=424;checked=1;font=LOGFONT(h=-13;name='微软雅黑');z=26};
20 | reset={cls="button";text="重置";left=272;top=32;right=336;bottom=56;z=29};
21 | rest={cls="checkbox";text="休息";left=24;top=160;right=336;bottom=184;checked=1;font=LOGFONT(h=-13;name='微软雅黑');z=3};
22 | restFree={cls="static";text="1";left=264;top=192;right=296;bottom=208;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=16};
23 | restFreeAnap={cls="static";text="1";left=264;top=216;right=296;bottom=232;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=34};
24 | restTime={cls="static";text="1";left=264;top=248;right=296;bottom=264;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=13};
25 | static={cls="static";text="每间隔";left=48;top=216;right=88;bottom=232;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=30};
26 | static10={cls="static";text="小憩";left=32;top=104;right=72;bottom=120;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=14};
27 | static12={cls="static";text="休息";left=32;top=248;right=72;bottom=264;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=17};
28 | static13={cls="static";text="——————————————————————";left=24;top=136;right=328;bottom=152;align="center";transparent=1;z=19};
29 | static16={cls="static";text="次小憩";left=296;top=216;right=336;bottom=232;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=35};
30 | static2={cls="static";text="每";left=32;top=80;right=72;bottom=96;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=4};
31 | static3={cls="static";text="每";left=48;top=192;right=88;bottom=208;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=5};
32 | static4={cls="static";text="分钟";left=296;top=80;right=336;bottom=96;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=6};
33 | static5={cls="static";text="分钟";left=296;top=192;right=336;bottom=208;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=7};
34 | static6={cls="static";text="秒";left=296;top=104;right=336;bottom=120;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=8};
35 | static7={cls="static";text="分钟";left=296;top=248;right=336;bottom=264;font=LOGFONT(h=-13;name='微软雅黑');transparent=1;z=9};
36 | trackbar={cls="trackbar";left=64;top=72;right=264;bottom=102;max=100;min=1;z=10};
37 | trackbar2={cls="trackbar";left=64;top=96;right=264;bottom=126;max=100;min=1;z=12};
38 | trackbar3={cls="trackbar";left=64;top=184;right=264;bottom=214;disabled=1;max=100;min=1;z=15};
39 | trackbar4={cls="trackbar";left=88;top=208;right=264;bottom=238;max=100;min=1;z=33};
40 | trackbar5={cls="trackbar";left=64;top=240;right=264;bottom=270;max=100;min=1;z=18}
41 | )
42 | /*}}*/
43 |
44 | import transaction;
45 | import thread.event;
46 |
47 |
48 | // 重置
49 | winform.reset.oncommand = function(id,event){
50 | transaction.stop()
51 | transaction.resetConfig()
52 | getConfig()
53 | }
54 |
55 | function getConfig(){
56 | var config = transaction.getConfig();
57 | winform.anap.checked=config.setting.anap.userd;
58 | winform.trackbar.pos=config.setting.anap.free_m;
59 | winform.anapFree.text=config.setting.anap.free_m;
60 |
61 | winform.trackbar2.pos=config.setting.anap.time_s;
62 | winform.anapTime.text=config.setting.anap.time_s;
63 |
64 |
65 | // 休息
66 | winform.rest.checked=config.setting.rest.userd;
67 | if(config.setting.rest.mode!="anap"){
68 | winform.trackbar3.pos=config.setting.rest.free_m;
69 | winform.restFree.text=config.setting.rest.free_m;
70 | winform.isTimeMode.checked=true;
71 | }else {
72 | winform.trackbar4.pos=config.setting.rest.free_anap;
73 | winform.restFreeAnap.text=config.setting.rest.free_anap;
74 | winform.isAnapMode.checked=true;
75 |
76 | }
77 | winform.trackbar5.pos=config.setting.rest.time_m;
78 | winform.restTime.text=config.setting.rest.time_m;
79 |
80 | //稍后提醒
81 | winform.lateAnap.checked=config.setting.late.anap;
82 | winform.lateRest.checked=config.setting.late.rest;
83 |
84 | //跳过提醒
85 | winform.passAnap.checked=config.setting.pass.anap;
86 | winform.passRest.checked=config.setting.pass.rest;
87 |
88 |
89 |
90 | }
91 |
92 | function setConfig(){
93 |
94 | var config = transaction.getConfig();
95 | config.setting.anap.userd=winform.anap.checked;
96 | //config.setting.anap.free_m=winform.trackbar.pos;
97 | config.setting.anap.free_m=winform.anapFree.text;
98 |
99 | //config.setting.anap.time_s=winform.trackbar2.pos;
100 | config.setting.anap.time_s=winform.anapTime.text;
101 |
102 |
103 | //休息
104 | config.setting.rest.userd=winform.rest.checked;
105 | if(winform.isAnapMode.checked==false){
106 | //config.setting.rest.free_m=winform.trackbar3.pos;
107 | config.setting.rest.free_m=winform.restFree.text;
108 | config.setting.rest.mode="time";
109 | }else {
110 | //config.setting.rest.free_anap=winform.trackbar4.pos;
111 | config.setting.rest.free_anap=winform.restFreeAnap.text;
112 | config.setting.rest.mode="anap";
113 | }
114 | //config.setting.rest.time_m=winform.trackbar5.pos;
115 | config.setting.rest.time_m=winform.restTime.text;
116 |
117 | //稍后提醒
118 | config.setting.late.anap=winform.lateAnap.checked;
119 | config.setting.late.rest=winform.lateRest.checked;
120 |
121 | //跳过提醒
122 | config.setting.pass.anap=winform.passAnap.checked;
123 | config.setting.pass.rest=winform.passRest.checked;
124 |
125 | config.saveAll();
126 |
127 |
128 |
129 | }
130 |
131 |
132 |
133 | winform.trackbar.oncommand = function(id,event,pos){
134 | winform.anapFree.text = winform.trackbar.pos;
135 | }
136 |
137 | winform.trackbar2.oncommand = function(id,event,pos){
138 | winform.anapTime.text = winform.trackbar2.pos;
139 | }
140 |
141 | winform.trackbar3.oncommand = function(id,event,pos){
142 | winform.restFree.text = winform.trackbar3.pos;
143 | }
144 |
145 | winform.trackbar4.oncommand = function(id,event,pos){
146 | winform.restFreeAnap.text = winform.trackbar4.pos;
147 | }
148 |
149 | winform.trackbar5.oncommand = function(id,event,pos){
150 | winform.restTime.text = winform.trackbar5.pos;
151 | }
152 |
153 |
154 |
155 | winform.apple.oncommand = function(id,event){
156 | setConfig();
157 |
158 |
159 | transaction.stop();
160 | //thread.create(anap,winform,transaction.getConfig())
161 | transaction.start();
162 | }
163 |
164 |
165 |
166 | getConfig();
167 |
168 | winform.show();
169 | win.loopMessage();
170 | return winform;
--------------------------------------------------------------------------------
/dlg/test.aardio:
--------------------------------------------------------------------------------
1 | import win.ui;
2 | /*DSG{{*/
3 | var winform = win.form(text="线程命令";right=599;bottom=503)
4 | winform.add(
5 | button={cls="button";text="waitOne";left=184;top=144;right=352;bottom=216;z=1};
6 | button2={cls="button";text="wait";left=184;top=296;right=352;bottom=392;z=2};
7 | button3={cls="button";text="Button";left=160;top=424;right=504;bottom=472;z=3};
8 | button4={cls="button";text="Button";left=400;top=336;right=560;bottom=384;z=5};
9 | progress={cls="plus";left=56;top=40;right=528;bottom=56;forecolor=32768;z=4};
10 | static={cls="static";text="Static";left=184;top=72;right=400;bottom=104;transparent=1;z=6}
11 | )
12 | /*}}*/
13 |
14 | import thread.event;
15 | var timeEvent = thread.event("time_s GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
16 |
17 | winform.button.oncommand = function(id,event){
18 | timeEvent.waitOne(5000);
19 | win.msgbox("waitOne")
20 | }
21 |
22 | winform.button2.oncommand = function(id,event){
23 | timeEvent.wait(5000);
24 | win.msgbox("wait")
25 | }
26 | winform.progress.setProgressRange(1,100);
27 | winform.progress.stepProgress(100);
28 | winform.button3.oncommand = function(id,event){
29 | import sys.monitor;
30 | import thread.event;
31 | import console;
32 |
33 |
34 | var frmChildenArr={};
35 | for( hMonitor,monitorInfo in sys.monitor.eachInfo() ){
36 | console.log("for")
37 |
38 | var frmChild = win.loadForm("\dlg\child.aardio");
39 | //frmChild.enableDpiScaling(false)
40 |
41 |
42 | table.push(frmChildenArr,frmChild)
43 |
44 | frmChild.show()
45 | //frmChild.enableDpiScaling(false)
46 | //win.setRect(frmChild.hwnd,monitorInfo.rcMonitor);
47 | //win.setRect(frmChild.hwnd,monitorInfo.rcMonitor);
48 | //win.setRect(frmChild.hwnd,monitorInfo.rcMonitor);
49 | //frmChild.show(false)
50 | console.log("for end")
51 | }
52 | }
53 |
54 | winform.button4.oncommand = function(id,event){
55 | inTime=time().getMilliTime();
56 | win.delay(500)
57 | winform.progress.setProgressRange(0,1000);
58 | winform.progress.stepProgress(1000)
59 | winform.setInterval(
60 | 1000,function(){
61 | import time;
62 |
63 | if(inTime!=-1){
64 |
65 |
66 | var remainNum= 6000-math.floor((time().getMilliTime()-inTime)/1000)*1000;
67 | winform.progress.stepProgress(-math.round(1000/(6000/1000+1)));
68 | winform.static.text=math.round(remainNum/1000)+"s";
69 | }
70 | }
71 | )
72 |
73 |
74 | }
75 |
76 | winform.show();
77 |
78 | win.loopMessage();
--------------------------------------------------------------------------------
/lib/config.aardio:
--------------------------------------------------------------------------------
1 | //config 配置文件
2 | import fsys.config;
3 | config = fsys.config("/config/");
4 | //config = fsys.config( io.appData("/软件作者/应用程序名/") );
5 |
6 | //不需要序列化的配置名字前请添加下划线
7 | namespace config {
8 | __appName = "应用程序名";
9 | __appVersion = "1.0.0.01";
10 | __appDescription = "这是一个测试程序";
11 | __website = "http://www.aardio.com/";
12 | }
13 |
14 | /**intellisense(config)
15 | __appName = 应用程序名
16 | __appVersion = 应用程序内部版本号
17 | __appDescription = 程序说明
18 | __website = 官方网站
19 | ? = 配置文件名,\n读写配置并序列化为一个表对象,\n表的成员值可以是支持序列化的普通变量,支持table对象\n配置文件在首次使用时自动加载,退出程序时自动保存\n!fsys_table.
20 | end intellisense**/
--------------------------------------------------------------------------------
/lib/transaction.aardio:
--------------------------------------------------------------------------------
1 |
2 | namespace transaction{
3 | //import console;
4 | import win;
5 | import fsys.config;
6 | import thread;
7 |
8 | function getConfig(){
9 |
10 | var config=fsys.config();
11 | if(config.setting.anap) return config;
12 | return resetConfig();
13 | };
14 | function resetConfig(){
15 | var config=fsys.config();
16 | config.setting.anap={};
17 | config.setting.anap.userd=true;
18 | config.setting.anap.free_m=20;
19 | config.setting.anap.time_s=40;
20 |
21 | config.setting.rest={};
22 | config.setting.rest.userd=true;
23 | config.setting.rest.free_m=null;
24 | config.setting.rest.mode="anap";
25 | config.setting.rest.free_anap=2;
26 | config.setting.rest.time_m=5;
27 |
28 | config.setting.late={};
29 | config.setting.late.anap=true;
30 | config.setting.late.rest=false;
31 |
32 | config.setting.pass={};
33 | config.setting.pass.anap=true;
34 | config.setting.pass.rest=false;
35 |
36 | config.saveAll();
37 | return config;;
38 | };
39 | function start(){
40 | thread.invoke(
41 | main
42 | )
43 |
44 | };
45 | function stop(){
46 | var timeEvent = thread.event("time_s GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
47 | var stopEvent = thread.event("stopEvent GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
48 | stopEvent.set();
49 | timeEvent.set();
50 | };
51 |
52 | function main(){
53 | import win;
54 | import table;
55 | import thread;
56 | import thread.command;
57 | import thread.table;
58 | import fsys.config;
59 | import sys.monitor;
60 | import thread.event;
61 | //import console;
62 |
63 |
64 | var frmChildenArr={};
65 | for( hMonitor,monitorInfo in sys.monitor.eachInfo() ){
66 | //console.log("for")
67 |
68 | var frmChild = win.loadForm("\dlg\child.aardio");
69 | win.setRect(frmChild.hwnd,monitorInfo.rcMonitor);
70 | table.push(frmChildenArr,frmChild)
71 | //console.log("for end")
72 | }
73 |
74 | var timeEvent = thread.event("time_s GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
75 | var stopEvent = thread.event("stopEvent GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
76 | timeEvent.reset();
77 | stopEvent.reset();
78 |
79 | var shareT = thread.table("shareT");
80 | shareT.lateNum=0;
81 |
82 | var config=fsys.config();
83 | var freeTime=config.setting.anap.free_m*60*1000;
84 | var freeAnapNum=tonumber(config.setting.rest.free_anap);
85 | var anapNum=0;
86 |
87 | //-30000是为弹出pop
88 | while(!stopEvent.wait(freeTime-30000)){
89 | anapNum+=1;
90 | //console.log(anapNum,freeAnapNum)
91 | if(anapNum>freeAnapNum&&config.setting.rest.userd){
92 | //间隔AnapNum个小憩后,执行休息时间
93 | anapNum=0;
94 | shareT.showTime=config.setting.rest.time_m*60*1000;
95 | shareT.hasLate=config.setting.late.rest;
96 | shareT.hasPass=config.setting.pass.rest;
97 | shareT.modeName="rest";
98 | //console.log("休息")
99 | thread.command.showCountdownPop(shareT.modeName,30000);
100 | if(timeEvent.wait(30000))break;
101 | }else {
102 | shareT.showTime=config.setting.anap.time_s*1000;
103 | shareT.hasLate=config.setting.late.anap;
104 | shareT.hasPass=config.setting.pass.anap;
105 | shareT.modeName="anap";
106 | //console.log("小憩")
107 | if(timeEvent.wait(20000))break;
108 | thread.command.showCountdownPop(shareT.modeName,10000);
109 | if(timeEvent.wait(10000))break;
110 | }
111 |
112 | for(index,frmChild in frmChildenArr){
113 | frmChild.show();
114 | //win.setRect(frmChild.hwnd,monitorInfo.rcMonitor);
115 | //console.log("win.show",shareT.hasLate,shareT.lateNum,shareT.showTime);
116 | }
117 |
118 |
119 | //创建工作线程防止wait阻塞
120 | win.invoke(
121 | function(shareT,frmChildenArr){
122 | import win;
123 | import thread.command;
124 | import thread.event;
125 | var timeEvent = thread.event("time_s GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
126 | while(timeEvent.wait(shareT.showTime)&&shareT.hasLate){
127 | if(shareT.lateNum<2){//可以稍等2次
128 | shareT.lateNum+=1;
129 | for(index,frmChild in frmChildenArr){
130 | frmChild.show(false);
131 | }
132 | //sleep(10000)
133 | //如果触发暂停
134 | if(timeEvent.wait(10000))break;
135 | thread.command.showCountdownPop(shareT.modeName,10000);
136 | //sleep(10000)
137 | if(timeEvent.wait(10000))break;
138 | for(index,frmChild in frmChildenArr){
139 | frmChild.show();
140 | }
141 |
142 | }else {
143 | shareT.lateNum=0;
144 | break;
145 | }
146 | }
147 | shareT.lateNum=0;
148 | }
149 | ,shareT,frmChildenArr);
150 |
151 |
152 |
153 | for(index,frmChild in frmChildenArr){
154 | frmChild.show(false);
155 | }
156 |
157 |
158 | }
159 |
160 |
161 |
162 | };
163 |
164 |
165 | function rest(){
166 |
167 | var frmChild = ..mainForm.loadForm("\dlg\child.aardio");
168 | frmChild.show();
169 |
170 | };
171 |
172 |
173 |
174 |
175 | }
176 |
--------------------------------------------------------------------------------
/main.aardio:
--------------------------------------------------------------------------------
1 | import win.ui;
2 | /*DSG{{*/
3 | mainForm = win.form(text="休息一下";right=419;bottom=550)
4 | mainForm.add(
5 | button={cls="button";text="quite";left=295;top=493;right=407;bottom=532;z=1};
6 | button2={cls="button";text="Button";left=54;top=377;right=240;bottom=459;z=2}
7 | )
8 | /*}}*/
9 |
10 | import thread;
11 | import win.util.tray;
12 | var tray = win.util.tray(mainForm);//创建托盘图标
13 | tray.message = 0xACCF/*_WM_TRAYMESSAGE*/
14 | tray.tip = "休息提醒" //设置鼠标提示
15 |
16 | mainForm.trayPop=function(text,title){
17 | tray.pop(text,title);
18 | }
19 |
20 |
21 | import thread.command;
22 | var listener = thread.command();
23 | listener.showCountdownPop = function(modeName,time_ms){
24 | thread.invoke(
25 | function(modeName,time_ms,mainForm){
26 | var name;
27 | if(modeName=="anap"){
28 | name="小憩"
29 | }else {
30 | name="休息"
31 | }
32 |
33 | mainForm.trayPop("将在 "+(time_ms/1000)+"秒 后 "+name+"!")
34 | sleep(5000-100);//提早关闭pop
35 | mainForm.trayPop("");
36 | return true;
37 | }
38 | ,modeName,time_ms,mainForm)
39 | }
40 |
41 | mainForm.button.oncommand = function(id,event){
42 | tray.delete();
43 | win.quitMessage();
44 | }
45 |
46 | mainForm.button2.oncommand = function(id,event){
47 |
48 | var frmSetting = mainForm.loadForm("\dlg\setting.aardio");// setting
49 | frmSetting.show();
50 | }
51 |
52 | mainForm.wndproc = {
53 | [0xACCF/*_WM_TRAYMESSAGE*/ ] = function(hwnd,message,wParam,lParam){
54 | if( lParam = 0x205/*_WM_RBUTTONUP*/ ){
55 | var pt = ::POINT();
56 | ::User32.GetCursorPos(pt);
57 |
58 |
59 | //弹出托盘菜单以前,一定要前置主窗口中,不然不点击菜单不会消失
60 | win.setForeground(mainForm.hwnd)
61 | mainForm.popmenu.popup(pt.x,pt.y,true )
62 | }
63 | }
64 | }
65 |
66 | mainForm.popmenu = win.ui.popmenu(mainForm);//创建弹出菜单
67 |
68 | import thread.event;
69 | import transaction;
70 |
71 | var timeEvent = thread.event("time_s GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
72 | var stopEvent = thread.event("stopEvent GUID:3CDA0FC7-A96D-4850-9A28-DA1DD4464B44")
73 |
74 | var idleTimeStop=false;
75 | mainForm.setInterval(
76 | 2*1000,function(){
77 | //import console;
78 | if(win.getIdleTime()>=5*60*1000&&idleTimeStop==false){
79 | transaction.stop();
80 | idleTimeStop=true;
81 | }elseif(win.getIdleTime()<100&&idleTimeStop){
82 | transaction.stop();
83 | transaction.start();
84 | idleTimeStop=false;
85 | //console.log("idleTimeStop=*/true")
86 | }
87 |
88 | //console.log("win.getIdleTime()"+win.getIdleTime())
89 | }
90 | )
91 | mainForm.popmenu.addTable( {
92 | { "设置"; function(id){
93 | var frmSetting = mainForm.loadForm("\dlg\setting.aardio");// setting
94 | frmSetting.show(true);
95 | } };
96 | { "暂停"; function(id){
97 | if(mainForm.popmenu.checked(2)){
98 | mainForm.popmenu.check(2,false);
99 | transaction.stop();
100 | transaction.start();
101 | }else {
102 | mainForm.popmenu.check(2);
103 | transaction.stop();
104 | }
105 |
106 | } };{ /*分隔线*/ };
107 | { "退出"; function(id){
108 | transaction.stop();
109 | tray.delete();
110 | win.quitMessage();
111 | } };
112 | } );
113 |
114 |
115 | //mainForm.show();
116 | import fsys.config;
117 |
118 | if(!fsys.config().setting.anap){
119 |
120 | var frmChild = mainForm.loadForm("\dlg\setting.aardio");
121 | frmChild.show();
122 |
123 | }else {
124 | transaction.start();
125 | }
126 |
127 |
128 |
129 | return win.loopMessage();
--------------------------------------------------------------------------------