Skip to content

Commit 013ed00

Browse files
committed
增加功能
增加根据系统主题选择颜色; 增加自启动选项;
1 parent fab7bf3 commit 013ed00

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

default.aproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<project ver="10" name="RunCat_with_aardio" libEmbed="true" icon="res\appIcon.ico" ui="win" output="RunCat_with_aardio.exe" CompanyName="单位名称" FileDescription="RunCat_with_aardio" LegalCopyright="Copyright (C) 作者 2022" ProductName="RunCat_with_aardio" InternalName="RunCat_with_aardio" FileVersion="0.0.0.04" ProductVersion="0.0.0.04" publishDir="/dist/" dstrip="false" local="false" ignored="false">
2+
<project ver="10" name="RunCat_with_aardio" libEmbed="true" icon="res\appIcon.ico" ui="win" output="RunCat_with_aardio.exe" CompanyName="单位名称" FileDescription="RunCat_with_aardio" LegalCopyright="Copyright (C) 作者 2022" ProductName="RunCat_with_aardio" InternalName="RunCat_with_aardio" FileVersion="0.0.0.05" ProductVersion="0.0.0.05" publishDir="/dist/" dstrip="false" local="false" ignored="false">
33
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
44
<folder name="资源文件" path="res" embed="true" local="false" ignored="false">
55
<file name="appIcon.ico" path="res\appIcon.ico" comment="res\appIcon.ico"/>

lib/config.aardio

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ namespace config {
1010
__website = "https://github.com/doomiris/";
1111
}
1212
if !config.system.cpuCheckFrequency
13-
config.system.cpuCheckFrequency = 60;
13+
config.system.cpuCheckFrequency = 1;
14+
15+
1416
/**intellisense(config)
1517
__appName = 应用程序名
1618
__appVersion = 应用程序内部版本号

main.aardio

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import process;
1010
/*DSG{{*/
1111
mainForm = win.form(text="RunCat_with_aardio";right=296;bottom=263)
1212
mainForm.add(
13+
autoCat={cls="radiobutton";text="自动";left=200;top=43;right=262;bottom=65;dl=1;dt=1;z=5};
1314
blackcat={cls="radiobutton";text="黑猫";left=114;top=43;right=176;bottom=65;dl=1;dt=1;z=4};
15+
checkbox={cls="checkbox";text="加入windows启动项";left=9;top=226;right=158;bottom=252;db=1;dl=1;z=6};
1416
cpuCheckFrequency={cls="edit";left=112;top=188;right=194;bottom=211;dl=1;dt=1;edge=1;num=1;tabstop=1;z=1};
1517
static={cls="static";text="CPU检测频率(秒)";left=9;top=191;right=106;bottom=214;dl=1;dt=1;transparent=1;z=2};
1618
whitecat={cls="radiobutton";text="白猫";left=24;top=43;right=86;bottom=65;checked=1;dl=1;dt=1;group=1;z=3}
@@ -52,7 +54,20 @@ _iconLib = {
5254
}
5355
}
5456
/*}}*/
55-
var iconTab = config.system.whitecat ? _iconLib[1] : _iconLib[2];
57+
var isLightTheme = function(){
58+
import win.reg;
59+
var v = win.reg.query("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "SystemUsesLightTheme");
60+
if v===null return true;
61+
else return v==0 ? false : true;
62+
}
63+
64+
var getIconIndex = function(){
65+
if config.system.autoCat return isLightTheme() ? 2:1 ;
66+
else return config.system.blackcat ? 2:1 ;
67+
}
68+
69+
var iconTab = _iconLib[getIconIndex()];
70+
5671

5772
/*创建托盘图标{{*/
5873
var tray = win.util.tray(mainForm);
@@ -69,7 +84,6 @@ import console
6984
console.open();
7085
*/
7186

72-
7387
_ANIMATE_DEFAULT_INTERVAL = 200;
7488

7589

@@ -92,13 +106,14 @@ cpuCheck_timer.onTimer = function(hwnd,msg,id,tick){
92106
var ret, idleTime, kernelTime, userTime = GetSystemTimes(0, 0, 0);
93107
var usage = 0;
94108
if ret {
95-
var t = (idleTime + userTime - idleTime)/1000/_coreNum;
109+
var t = (idleTime + userTime - idleTime)/10000/_coreNum;
96110
table.push(cpuTms, t);
97111
if #cpuTms > 2 table.shift(cpuTms);
98112
if #cpuTms == 2 {
99-
var per = math.abs(cpuTms[2] - cpuTms[1]) / owner.getInterval() * 1000;
100-
usage = per * 100 /* _% */ / _Frequency /* cpu 使用率 是这么计算的吗? */;
113+
var per = math.abs(cpuTms[2] - cpuTms[1]) / owner.getInterval() * 100;
114+
usage = per * 100 * 100 /* _% */ / _Frequency /* cpu 使用率 是这么计算的吗? */;
101115
}
116+
102117
}
103118
if usage > 0 {
104119
tray.tip = "CPU: " ++ math.round(usage, 1) ++ "%";
@@ -159,13 +174,29 @@ mainForm.blackcat.oncommand = function(id,event){
159174
config.system.save();
160175
iconTab = _iconLib[2];
161176
}
162-
177+
mainForm.autoCat.oncommand = function(id,event){
178+
if event !== 0/*_BN_CLICKED*/ return ;
179+
config.system.save();
180+
iconTab = _iconLib[(isLightTheme() ? 2:1)];
181+
}
163182
mainForm.cpuCheckFrequency.onModified = function(modified){
164183
config.system.save();
165184
cpuCheck_timer.setInterval(owner.text * 1000);
166185
}
186+
var setStartup = function(add = true){
187+
if _STUDIO_INVOKED return ;
188+
import win.reg;
189+
var reg = win.reg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run");
190+
if add reg.setSzValue(config.__appName, '"' + io._exepath + '"' );
191+
else reg.delKey(config.__appName);
192+
reg.close();
193+
}
194+
mainForm.checkbox.oncommand = function(id,event){
195+
if event !== 0/*_BN_CLICKED*/ return ;
196+
setStartup(owner.checked);
197+
}
167198

168-
mainForm.show();
199+
//mainForm.show();
169200

170201
iconBlink_timer.enable();
171202
cpuCheck_timer.enable();

0 commit comments

Comments
 (0)