Skip to content

Commit

Permalink
使用原子窗体、提示用户以管理员权限运行、开机自启自动获取管理员权限并跳过警告窗口
Browse files Browse the repository at this point in the history
  • Loading branch information
YrracOwl authored Jul 12, 2022
1 parent ff32133 commit 5b4a3ce
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
4 changes: 3 additions & 1 deletion default.aproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="电源计划管理器" libEmbed="true" icon="res\battery-level.ico" ui="win" output="电源计划管理器.exe" CompanyName="YrracOwl" FileDescription="电源计划管理器" LegalCopyright="Copyright (C) YrracOwl 2022" ProductName="电源计划管理器" InternalName="电源计划管理器" FileVersion="0.0.0.04" ProductVersion="0.0.0.04" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<project ver="10" name="电源计划管理器" libEmbed="true" icon="res\battery-level.ico" ui="win" output="电源计划管理器.exe" CompanyName="YrracOwl" FileDescription="电源计划管理器" LegalCopyright="Copyright (C) YrracOwl 2022" ProductName="电源计划管理器" InternalName="电源计划管理器" FileVersion="1.0.0.11" ProductVersion="1.0.0.11" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
<folder name="资源文件" path="res" embed="true" local="false" ignored="false">
<file name="battery-level.ico" path="res\battery-level.ico" comment="res\battery-level.ico"/>
<file name="runAsAdmin.bmp" path="res\runAsAdmin.bmp" comment="res\runAsAdmin.bmp"/>
</folder>
<folder name="窗体文件" path="dlg" comment="目录" embed="true" local="false" ignored="false">
<file name="askForAdmin.aardio" path="dlg\askForAdmin.aardio" comment="dlg\askForAdmin.aardio"/>
<file name="settings.aardio" path="dlg\settings.aardio" comment="dlg\settings.aardio"/>
</folder>
</project>
33 changes: 33 additions & 0 deletions dlg/askForAdmin.aardio
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fonts.fontAwesome;
import win.ui;
/*DSG{{*/
var winform = win.form(text="请以管理员启动";right=383;bottom=279;border="thin";max=false;min=false)
winform.add(
picturebox={cls="picturebox";left=8;top=112;right=376;bottom=216;image=$"\res\runAsAdmin.bmp";z=2};
plus={cls="plus";text="确定并退出";left=112;top=232;right=272;bottom=270;align="left";font=LOGFONT(h=-19);forecolor=-2104577;iconStyle={align="left";font=LOGFONT(h=-16;name='FontAwesome');padding={left=16}};iconText='\uF011';notify=1;textPadding={left=39};z=4};
static={cls="static";text="请右键程序,点击“以管理员身份运行”!";left=8;top=40;right=376;bottom=64;align="center";center=1;font=LOGFONT(h=-20;underline=1);transparent=1;z=1};
static2={cls="static";text="如下所示";left=8;top=72;right=376;bottom=96;align="center";center=1;font=LOGFONT(h=-20;underline=1);transparent=1;z=3}
)
/*}}*/

winform.plus.skin({
foreground={
active=0xFFF78987;
default=0xFFFFE2DF;
disabled=0xFF8A4343;
focus=0xFFCF6565;
hover=0xFFFFBAB7
};
color={
default=0xFF000000;
disabled=0xFF6D6D6D
}
})

winform.plus.oncommand = function(id,event){
winform.endModal("关闭程序")
}

winform.show();
win.loopMessage();
return winform;
23 changes: 16 additions & 7 deletions dlg/settings.aardio
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import win.ui;
/*DSG{{*/
var winform = win.form(text="设置";right=255;bottom=175;border="thin")
var winform = win.form(text="设置";right=255;bottom=207;border="thin")
winform.add(
checkPowerPlan={cls="checkbox";text="监控并阻止对当前计划的修改";left=24;top=80;right=248;bottom=96;z=4};
loopTime1={cls="radiobutton";text="10秒";left=48;top=112;right=96;bottom=128;checked=1;z=5};
loopTime2={cls="radiobutton";text="1分钟";left=112;top=112;right=168;bottom=128;z=6};
loopTime3={cls="radiobutton";text="1小时";left=176;top=112;right=240;bottom=128;z=7};
checkPowerPlan={cls="checkbox";text="监控并阻止对当前计划的修改";left=24;top=112;right=248;bottom=128;z=4};
loopTime1={cls="radiobutton";text="10秒";left=48;top=144;right=96;bottom=160;checked=1;z=5};
loopTime2={cls="radiobutton";text="1分钟";left=112;top=144;right=168;bottom=160;z=6};
loopTime3={cls="radiobutton";text="1小时";left=176;top=144;right=240;bottom=160;z=7};
noClose={cls="checkbox";text="最小化到托盘";left=24;top=80;right=248;bottom=96;z=9};
notify={cls="checkbox";text="电源计划更改时通知我";left=24;top=48;right=248;bottom=64;z=2};
openSysSetting={cls="button";text="打开系统的电源计划设置";left=24;top=136;right=232;bottom=160;z=3};
openSysSetting={cls="button";text="打开系统的电源计划设置";left=24;top=168;right=232;bottom=192;z=3};
powerUp={cls="checkbox";text="开机启动";left=24;top=16;right=248;bottom=32;z=1};
static={cls="static";text="轮询间隔:";left=48;top=96;right=120;bottom=112;transparent=1;z=8}
static={cls="static";text="轮询间隔:";left=48;top=128;right=120;bottom=144;transparent=1;z=8}
)
/*}}*/

Expand All @@ -25,6 +26,10 @@ if(..config.mainform.watchPlan){
winform.checkPowerPlan.checked = ..config.mainform.watchPlan;
}

if(..config.mainform.noClose){
winform.noClose.checked = ..config.mainform.noClose;
}

if(!..config.mainform.loopTime){
..config.mainform.loopTime = 1000*10;
winform.loopTime1.checked = true
Expand Down Expand Up @@ -87,6 +92,10 @@ winform.loopTime3.oncommand = function(id,event){
..config.mainform.loopTime = 1000*60*60;
}

winform.noClose.oncommand = function(id,event){
..config.mainform.noClose = winform.noClose.checked;
}

winform.show();
win.loopMessage();
return winform;
2 changes: 1 addition & 1 deletion main.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,4 @@ else {
}
}

return win.loopMessage();
return win.loopMessage();
Binary file added res/runAsAdmin.bmp
Binary file not shown.

0 comments on commit 5b4a3ce

Please sign in to comment.