diff --git a/ClevoFanControl/ClevoFanControl.csproj b/ClevoFanControl/ClevoFanControl.csproj
index ecd2b16..638284b 100644
--- a/ClevoFanControl/ClevoFanControl.csproj
+++ b/ClevoFanControl/ClevoFanControl.csproj
@@ -43,8 +43,12 @@
app.manifest
+
+ ..\packages\TaskScheduler.2.9.2\lib\net452\Microsoft.Win32.TaskScheduler.dll
+
+
@@ -83,6 +87,7 @@
True
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/ClevoFanControl/frmMain.Designer.cs b/ClevoFanControl/frmMain.Designer.cs
index 302ec98..e75bb3a 100644
--- a/ClevoFanControl/frmMain.Designer.cs
+++ b/ClevoFanControl/frmMain.Designer.cs
@@ -40,6 +40,7 @@ private void InitializeComponent() {
this.mnuProfile50 = new System.Windows.Forms.ToolStripMenuItem();
this.mnuProfileMax = new System.Windows.Forms.ToolStripMenuItem();
this.mnuSeparator2 = new System.Windows.Forms.ToolStripSeparator();
+ this.mnuAutostart = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem();
this.mnuExit = new System.Windows.Forms.ToolStripMenuItem();
this.pnlCPUStats = new System.Windows.Forms.Panel();
@@ -180,10 +181,11 @@ private void InitializeComponent() {
this.mnuProfile50,
this.mnuProfileMax,
this.mnuSeparator2,
+ this.mnuAutostart,
this.mnuAbout,
this.mnuExit});
this.mnuMain.Name = "mnuMain";
- this.mnuMain.Size = new System.Drawing.Size(182, 170);
+ this.mnuMain.Size = new System.Drawing.Size(182, 192);
//
// mnuShowWindow
//
@@ -229,6 +231,13 @@ private void InitializeComponent() {
//
this.mnuSeparator2.Name = "mnuSeparator2";
this.mnuSeparator2.Size = new System.Drawing.Size(178, 6);
+ //
+ // mnuAutostart
+ //
+ this.mnuAutostart.Name = "mnuAutostart";
+ this.mnuAutostart.Size = new System.Drawing.Size(181, 22);
+ this.mnuAutostart.Text = "Auto Start";
+ this.mnuAutostart.Click += new System.EventHandler(this.mnuAutostart_Click);
//
// mnuAbout
//
@@ -854,6 +863,7 @@ private void InitializeComponent() {
private System.Windows.Forms.NotifyIcon icoTray;
private System.Windows.Forms.ContextMenuStrip mnuMain;
private System.Windows.Forms.ToolStripMenuItem mnuShowWindow;
+ private System.Windows.Forms.ToolStripMenuItem mnuAutostart;
private System.Windows.Forms.ToolStripMenuItem mnuAbout;
private System.Windows.Forms.ToolStripMenuItem mnuExit;
private System.Windows.Forms.Panel pnlCPUStats;
diff --git a/ClevoFanControl/frmMain.cs b/ClevoFanControl/frmMain.cs
index 58f4151..46c4e70 100644
--- a/ClevoFanControl/frmMain.cs
+++ b/ClevoFanControl/frmMain.cs
@@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
+using Microsoft.Win32.TaskScheduler;
//using OpenHardwareMonitor.Hardware;
@@ -133,6 +134,7 @@ private void Form1_Load(object sender, EventArgs e) {
gpuFanTable = defaultGpuFanTable;
LoadFanTableAndConfig();
+ CheckAutoStartState();
SetSliderValuesFromTable();
@@ -666,6 +668,35 @@ private void LoadFanTableAndConfig() {
}
+ private void CheckAutoStartState(){
+ using (TaskService ts = new TaskService())
+ {
+ Microsoft.Win32.TaskScheduler.Task task = ts.GetTask("ClevoFanControl");
+ if (task == null){
+ mnuAutostart.Checked = false;
+ return;
+ }
+ else
+ {
+ if (!task.IsActive){
+ mnuAutostart.Checked = false;
+ return;
+ }
+ foreach(Microsoft.Win32.TaskScheduler.Action a in task.Definition.Actions){
+ if(a.ActionType == TaskActionType.Execute){
+ Microsoft.Win32.TaskScheduler.ExecAction exec = (Microsoft.Win32.TaskScheduler.ExecAction)a;
+ if (exec.Path == Application.ExecutablePath){
+ mnuAutostart.Checked = true;
+ return;
+ }
+ }
+ }
+ }
+ mnuAutostart.Checked = false;
+ return;
+ }
+ }
+
private void SaveFanTableAndConfig() {
var path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\";
@@ -727,13 +758,49 @@ private void ShowWindow() {
WindowState = FormWindowState.Normal;
ShowInTaskbar = true;
}
+
+ private void AutoStartToggle(){
+ using (TaskService ts = new TaskService())
+ {
+ if (mnuAutostart.Checked == false)
+ {
+ ts.RootFolder.DeleteTask("ClevoFanControl",false);
+ // Create a new task definition and assign properties
+ TaskDefinition td = ts.NewTask();
+ td.RegistrationInfo.Description = "ClevoFanControl auto start.";
+
+ // Create a trigger
+ td.Triggers.Add(new LogonTrigger());
+ string exe_path = Application.ExecutablePath;
+
+ // Create an action that will launch ClevoFanControl
+ td.Actions.Add(new ExecAction(exe_path, null));
+ // Start on battety used
+ td.Settings.DisallowStartIfOnBatteries = false;
+
+ // Run with highest privilege
+ td.Principal.RunLevel = TaskRunLevel.Highest;
+
+
+ // Register the task in the root folder
+ ts.RootFolder.RegisterTaskDefinition("ClevoFanControl", td);
+ mnuAutostart.Checked = true;
+ }
+ else
+ {
+ ts.RootFolder.DeleteTask("ClevoFanControl", false);
+ mnuAutostart.Checked = false;
+ }
+ }
+ }
+
private void ExitApp() {
tmrMain.Enabled = false;
//computer.Close();
//SetFansToMaximum();
- fan?.SetFansAuto(0);
- fan?.SetFansAuto(1);
- fan?.SetFansAuto(2);
+ fan?.SetFansAuto(255);
+ //fan?.SetFansAuto(1);
+ //fan?.SetFansAuto(2);
fan?.Dispose();
SaveFanTableAndConfig();
Close();
@@ -773,6 +840,10 @@ private void mnuShowWindow_Click(object sender, EventArgs e) {
ShowWindow();
}
+ private void mnuAutostart_Click(object sender, EventArgs e)
+ {
+ AutoStartToggle();
+ }
private void icoTray_DoubleClick(object sender, EventArgs e) {
ShowWindow();
}
@@ -888,9 +959,10 @@ private void btnProfileDefault_CheckedChanged(object sender, EventArgs e) {
//gpuFanTable = defaultGpuFanTable;
////tabFanCurves.Enabled = false;
//tmrMain.Enabled = false;
- fan?.SetFansAuto(0);
- fan?.SetFansAuto(1);
- fan?.SetFansAuto(2);
+ // pass 255 just set all fan auto
+ fan?.SetFansAuto(255);
+ //fan?.SetFansAuto(1);
+ //fan?.SetFansAuto(2);
mnuProfileManual.Checked = false;
mnuProfileDefault.Checked = true;
mnuProfileMax.Checked = false;
diff --git a/ClevoFanControl/frmMain.resx b/ClevoFanControl/frmMain.resx
index 1b62743..94b7cc1 100644
--- a/ClevoFanControl/frmMain.resx
+++ b/ClevoFanControl/frmMain.resx
@@ -1916,9 +1916,6 @@
301, 17
-
- 301, 17
-
395, 17
diff --git a/ClevoFanControl/packages.config b/ClevoFanControl/packages.config
new file mode 100644
index 0000000..515fe39
--- /dev/null
+++ b/ClevoFanControl/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file