From 079170e0ae6c99fa081528d3a3c91ec95632b54c Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sun, 12 Nov 2017 18:26:16 +0100 Subject: [PATCH] Added bomb and win_team to CS:GO datamodel Autorun now creates a task that doesn't prompt an UAC dialog --- Artemis/Artemis/Artemis.csproj | 5 +++ Artemis/Artemis/ArtemisBootstrapper.cs | 27 +++++----------- .../CounterStrike/CounterStrikeDataModel.cs | 2 ++ .../Artemis/Properties/Resources.Designer.cs | 23 ++++++++++++++ Artemis/Artemis/Properties/Resources.resx | 3 ++ Artemis/Artemis/Resources/Artemis autorun.xml | Bin 0 -> 3228 bytes Artemis/Artemis/Settings/GeneralSettings.cs | 29 +++++++++++++++--- Artemis/Artemis/packages.config | 1 + 8 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 Artemis/Artemis/Resources/Artemis autorun.xml 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 0000000000000000000000000000000000000000..cd46cbf98c499c3eed04c6c03cfd95c43f456198 GIT binary patch literal 3228 zcmbuC+fNfw5XR@(#Q$N#yIj3QQcDoLG(l{j4KKb_T1rE2=@yX~|8@2E&Ee2J+fplL zv)$#)?VIn+%pQLKs@R@=w}JI7vv1b1iRIR_kqzyQt=X2X+a}Kp$h&n`5kuGh@HMU*b;L3@0Nz8$JTIbngWkUR% z`vT2%M>9b8#u2qyzd^cT+aTVw=e%w5zTvi0p3^&2Yj-#^@Kx-DC|x|{$R}t_c~|x| z?hD>RPSOqfhpy9MU2(STmFK_ZzuRQ4m0hC0xcgn_{WaGP90^YaBr_l4Yvz03u8Dt1 z)CvAiVPoXEUD>T2+mYL*I;s63xrn(5R^$6js)hZS;xR*hO?H{>^EP#sm4Ajzt93iz zSA4WwevPlpSq|8QQF7r7+;{oA#offCY*iyIDry9?A>YNgQuIysqDJ0d=5V!~7qKGT z@)&ia2d%BXld4d0)a42lU*6>-$1Xln%~UT`#5=TF_LY1)WL||G;p{lhvMl1A?YZ`> zkNqu{b)xN1C8zhSMM=?4x&9rWv{LLj5i;-4fcuol>bcO*lBQ8UkwxF-W6w<;5voFy zKs#E8r9SrOj=lz)Lsllpj=66|T~*CoEsUA& zu|L9|3vsklKbLzv?(ZVKV)WouQz|FxFk6c@<+@#_S@f$KkNB47Re|GJPqQ5q22CM- zYv;3D%_7B9o_ecJ#EN~S=Gt5xkd*mIWog9u%7~1Vy)4sAeLg%l#F%zxK;^0f_n8c1 zuc@594d;h)-2e5KVr%+zYl5RkA8GEji672PZJ*m=LTM*-x*4L8cJSjoq$tj)m@7Ot z;34o@&U%qX>f;@!&ko3SstC+Acn(-Q@@J3r@MVnO#nmj*D0TljXwJx=zO}FX+c3W# z?bKBdcau8l{2sB+P6u!>WTitsQ$NubPin<8XP5&qi}b4-Wb!pA^y3fv;eI1eaVFQ{ zUuUwPT*6zni@C^a@T?PG7p}#x(CVxIjBCvLh>SFwa`KMzDdS`=8|9^MPR_Yo8FpA# b#6|v!QKd7VX|OEv7g*4GgPiogL)HEOh3yar literal 0 HcmV?d00001 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