diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 0329417bb..5b67a756b 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -45,6 +45,7 @@ true true true + 38ead84566f241de8f334abe173b1038 x64 @@ -195,6 +196,9 @@ ..\packages\MahApps.Metro.1.4.3\lib\net45\MahApps.Metro.dll + + ..\packages\TaskScheduler.2.6.5\lib\net452\Microsoft.Win32.TaskScheduler.dll + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll True @@ -1094,6 +1098,7 @@ + diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs index 978297814..6635c2415 100644 --- a/Artemis/Artemis/ArtemisBootstrapper.cs +++ b/Artemis/Artemis/ArtemisBootstrapper.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -18,8 +15,6 @@ using Artemis.ViewModels; using Caliburn.Micro; using Newtonsoft.Json; using Ninject; -using NLog; -using LogManager = NLog.LogManager; namespace Artemis { @@ -41,7 +36,7 @@ namespace Artemis AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; } - + private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) { // Get rid of the keyboard hook in case of a crash, otherwise input freezes up system wide until Artemis is gone @@ -57,10 +52,10 @@ namespace Artemis var e = ctx.EventArgs as MouseEventArgs; // If there is an image control, get the scaled position - if ((img != null) && (e != null)) + if (img != null && e != null) { var position = e.GetPosition(img); - return (int) (img.Source.Width*(position.X/img.ActualWidth)); + return (int) (img.Source.Width * (position.X / img.ActualWidth)); } // If there is another type of of IInputControl get the non-scaled position - or do some processing to get a scaled position, whatever needs to happen @@ -77,14 +72,14 @@ namespace Artemis var e = ctx.EventArgs as MouseEventArgs; // If there is an image control, get the scaled position - if ((img != null) && (e != null)) + if (img != null && e != null) { var position = e.GetPosition(img); - return (int) (img.Source.Width*(position.Y/img.ActualWidth)); + return (int) (img.Source.Width * (position.Y / img.ActualWidth)); } // If there is another type of of IInputControl get the non-scaled position - or do some processing to get a scaled position, whatever needs to happen - if ((e != null) && (input != null)) + if (e != null && input != null) return e.GetPosition(input).Y; // Return 0 if no processing could be done @@ -94,14 +89,6 @@ namespace Artemis protected override void Configure() { - // Sleep for a while if ran from autorun to allow full system boot - if (Environment.GetCommandLineArgs().Contains("--autorun")) - { - var logger = LogManager.GetCurrentClassLogger(); - logger.Info("Artemis was run using the autorun shortcut, sleeping for 15 sec."); - Thread.Sleep(15000); - } - _kernel = new StandardKernel(new BaseModules(), new ManagerModules()); _kernel.Bind().To().InSingletonScope(); @@ -151,4 +138,4 @@ namespace Artemis InputHook.Start(); } } -} \ No newline at end of file +} diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs index 769be1fc3..d88b8190c 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeDataModel.cs @@ -51,6 +51,8 @@ namespace Artemis.Modules.Games.CounterStrike public class Round { public string phase { get; set; } + public string bomb { get; set; } + public string win_team { get; set; } } [MoonSharpUserData] diff --git a/Artemis/Artemis/Properties/Resources.Designer.cs b/Artemis/Artemis/Properties/Resources.Designer.cs index be17825d8..998a7d83b 100644 --- a/Artemis/Artemis/Properties/Resources.Designer.cs +++ b/Artemis/Artemis/Properties/Resources.Designer.cs @@ -70,6 +70,29 @@ namespace Artemis.Properties { } } + /// + /// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-16"?> + ///<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> + /// <RegistrationInfo> + /// <Date>2017-11-12T17:45:45.4993602</Date> + /// <Author>SpoinkyNL</Author> + /// <Description>Task to run Artemis on PC startup without showing a UAC dialog</Description> + /// <URI>\Artemis autorun</URI> + /// </RegistrationInfo> + /// <Triggers> + /// <LogonTrigger> + /// <Enabled>true</Enabled> + /// <Delay>PT30S</Delay> + /// </LogonTrigger> + /// </Triggers> + /// <Set [rest of string was truncated]";. + /// + internal static string Artemis_autorun { + get { + return ResourceManager.GetString("Artemis_autorun", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Artemis/Artemis/Properties/Resources.resx b/Artemis/Artemis/Properties/Resources.resx index 529de8e53..8518cab2e 100644 --- a/Artemis/Artemis/Properties/Resources.resx +++ b/Artemis/Artemis/Properties/Resources.resx @@ -226,4 +226,7 @@ ..\Modules\Games\WoW\Resources\wow-addon.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Artemis autorun.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 + \ No newline at end of file diff --git a/Artemis/Artemis/Resources/Artemis autorun.xml b/Artemis/Artemis/Resources/Artemis autorun.xml new file mode 100644 index 000000000..cd46cbf98 Binary files /dev/null and b/Artemis/Artemis/Resources/Artemis autorun.xml differ diff --git a/Artemis/Artemis/Settings/GeneralSettings.cs b/Artemis/Artemis/Settings/GeneralSettings.cs index 13240abee..e4883c874 100644 --- a/Artemis/Artemis/Settings/GeneralSettings.cs +++ b/Artemis/Artemis/Settings/GeneralSettings.cs @@ -4,10 +4,12 @@ using System.IO; using System.Windows; using Artemis.DAL; using Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing; +using Artemis.Properties; using Artemis.Utilities; using Artemis.Utilities.ActiveWindowDetection; using Caliburn.Micro; using MahApps.Metro; +using Microsoft.Win32.TaskScheduler; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Squirrel; @@ -111,10 +113,8 @@ namespace Artemis.Settings { try { - if (Autorun) - mgr.CreateShortcutsForExecutable("Artemis.exe", ShortcutLocation.Startup, false, "--autorun"); - else - mgr.RemoveShortcutsForExecutable("Artemis.exe", ShortcutLocation.Startup); + // Clean up the shortcut used by the old method + mgr.RemoveShortcutsForExecutable("Artemis.exe", ShortcutLocation.Startup); } catch (FileNotFoundException) { @@ -125,6 +125,25 @@ namespace Artemis.Settings // Ignored, only happens when running from VS } + using (var ts = new TaskService()) + { + var existing = ts.FindTask("Artemis autorun"); + if (Autorun) + { + // Overwrite any existing tasks in case the installation folder changed + var path = Path.GetTempFileName(); + var xml = Resources.Artemis_autorun.Replace("{{executablePath}}", mgr.RootAppDirectory + "\\Update.exe"); + + File.WriteAllText(path, xml); + ts.RootFolder.ImportTask(null, path); + File.Delete(path); + } + else if (existing != null) + { + // Remove the task if it is present + ts.RootFolder.DeleteTask("Artemis autorun"); + } + } } } @@ -159,4 +178,4 @@ namespace Artemis.Settings ScreenCaptureManager.UpdateRate = 1.0 / ScreenCaptureFPS; } } -} \ No newline at end of file +} diff --git a/Artemis/Artemis/packages.config b/Artemis/Artemis/packages.config index 451475e77..992429d67 100644 --- a/Artemis/Artemis/packages.config +++ b/Artemis/Artemis/packages.config @@ -30,5 +30,6 @@ + \ No newline at end of file