diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index cc0612303278..48dc65e24394 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -657,6 +657,7 @@ Elems ELogo elseif Emoji +emptyrecyclebin ENABLEDPOPUP endforeach endif @@ -693,6 +694,13 @@ eventdatemissed eventlog everytime evt +EWX +EWXFORCE +EWXFORCEIFHUNG +EWXLOGOFF +EWXPOWEROFF +EWXREBOOT +EWXSHUTDOWN examplehandler examplepowertoy EXCLUDEFILES @@ -768,6 +776,7 @@ FOFX FOLDERID folderpath fonttbl +FORCEIFHUNG FORCEOFFLINE foreach formatetc @@ -1680,6 +1689,7 @@ Portugu posix powerappscds powerlauncher +POWEROFF powerpreview powerrename POWERRENAMETEST @@ -1688,6 +1698,7 @@ powertoy POWERTOYNAME powertoysinterop powertoyssetup +Powrprof ppenum ppidl pprm diff --git a/PowerToys.sln b/PowerToys.sln index 83317057c7f3..451d73283f5a 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -271,6 +271,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest-ColorPickerUI", "s EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logging", "src\logging\logging.vcxproj", "{7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Sys", "src\modules\launcher\Plugins\Microsoft.Plugin.Sys\Microsoft.Plugin.Sys.csproj", "{FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Sys.UnitTests", "src\modules\launcher\Plugins\Microsoft.Plugin.Sys.UnitTests\Microsoft.Plugin.Sys.UnitTests.csproj", "{DA5A6FE9-0040-40CC-83CC-764AE5306590}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logger", "src\common\logger\logger.vcxproj", "{D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}" EndProject Global @@ -551,6 +555,14 @@ Global {7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}.Debug|x64.Build.0 = Debug|x64 {7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}.Release|x64.ActiveCfg = Release|x64 {7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F}.Release|x64.Build.0 = Release|x64 + {FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Debug|x64.ActiveCfg = Debug|x64 + {FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Debug|x64.Build.0 = Debug|x64 + {FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Release|x64.ActiveCfg = Release|x64 + {FD8EB419-FF9C-4D88-BB6F-BF6CED37747B}.Release|x64.Build.0 = Release|x64 + {DA5A6FE9-0040-40CC-83CC-764AE5306590}.Debug|x64.ActiveCfg = Debug|x64 + {DA5A6FE9-0040-40CC-83CC-764AE5306590}.Debug|x64.Build.0 = Debug|x64 + {DA5A6FE9-0040-40CC-83CC-764AE5306590}.Release|x64.ActiveCfg = Release|x64 + {DA5A6FE9-0040-40CC-83CC-764AE5306590}.Release|x64.Build.0 = Release|x64 {D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}.Debug|x64.ActiveCfg = Debug|x64 {D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}.Debug|x64.Build.0 = Debug|x64 {D9B8FC84-322A-4F9F-BBB9-20915C47DDFD}.Release|x64.ActiveCfg = Release|x64 @@ -634,6 +646,8 @@ Global {4FA206A5-F69F-4193-BF8F-F6EEB496734C} = {4AFC9975-2456-4C70-94A4-84073C1CED93} {090CD7B7-3B0C-4D1D-BC98-83EB5D799BC1} = {1D78B84B-CA39-406C-98F4-71F7EC266CC0} {7E1E3F13-2BD6-3F75-A6A7-873A2B55C60F} = {1AFB6476-670D-4E80-A464-657E01DFF482} + {FD8EB419-FF9C-4D88-BB6F-BF6CED37747B} = {4AFC9975-2456-4C70-94A4-84073C1CED93} + {DA5A6FE9-0040-40CC-83CC-764AE5306590} = {4AFC9975-2456-4C70-94A4-84073C1CED93} {D9B8FC84-322A-4F9F-BBB9-20915C47DDFD} = {1AFB6476-670D-4E80-A464-657E01DFF482} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/ImageTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/ImageTests.cs new file mode 100644 index 000000000000..01db4be4546a --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/ImageTests.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Linq; +using System.Text; +using Mono.Collections.Generic; +using Moq; +using NUnit.Framework; +using Wox.Infrastructure; +using Wox.Plugin; + +namespace Microsoft.Plugin.Sys.UnitTests +{ + public class ImageTests + { + [SetUp] + public void Setup() + { + StringMatcher.Instance = new StringMatcher(); + } + + [TestCase("shutdown", "Images\\shutdown.dark.png")] + [TestCase("restart", "Images\\restart.dark.png")] + [TestCase("sign out", "Images\\logoff.dark.png")] + [TestCase("lock", "Images\\lock.dark.png")] + [TestCase("sleep", "Images\\sleep.dark.png")] + [TestCase("hibernate", "Images\\sleep.dark.png")] + [TestCase("empty recycle", "Images\\recyclebin.dark.png")] + public void IconThemeDarkTest(string typedString, string expectedResult) + { + // Setup + Mock
main = new Mock
(); + main.Object.IconTheme = "dark"; + string[] terms = { typedString }; + Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection(terms), string.Empty); + + // Act + var result = main.Object.Query(expectedQuery).FirstOrDefault().IcoPath; + + // Assert + Assert.AreEqual(expectedResult, result); + } + + [TestCase("shutdown", "Images\\shutdown.light.png")] + [TestCase("restart", "Images\\restart.light.png")] + [TestCase("sign out", "Images\\logoff.light.png")] + [TestCase("lock", "Images\\lock.light.png")] + [TestCase("sleep", "Images\\sleep.light.png")] + [TestCase("hibernate", "Images\\sleep.light.png")] + [TestCase("empty recycle", "Images\\recyclebin.light.png")] + public void IconThemeLightTest(string typedString, string expectedResult) + { + // Setup + Mock
main = new Mock
(); + main.Object.IconTheme = "light"; + string[] terms = { typedString }; + Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection(terms), string.Empty); + + // Act + var result = main.Object.Query(expectedQuery).FirstOrDefault().IcoPath; + + // Assert + Assert.AreEqual(expectedResult, result); + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/Microsoft.Plugin.Sys.UnitTests.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/Microsoft.Plugin.Sys.UnitTests.csproj new file mode 100644 index 000000000000..d4fa0cea3804 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/Microsoft.Plugin.Sys.UnitTests.csproj @@ -0,0 +1,50 @@ + + + + netcoreapp3.1 + + false + x64 + Microsoft.Plugin.Sys.UnitTests + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + GlobalSuppressions.cs + + + StyleCop.json + + + + + 1.1.118 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + 3.3.0 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/QueryTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/QueryTests.cs new file mode 100644 index 000000000000..69c7d6ca9383 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys.UnitTests/QueryTests.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Linq; +using Mono.Collections.Generic; +using Moq; +using NUnit.Framework; +using Wox.Infrastructure; +using Wox.Plugin; + +namespace Microsoft.Plugin.Sys.UnitTests +{ + public class QueryTests + { + [SetUp] + public void Setup() + { + StringMatcher.Instance = new StringMatcher(); + } + + [TestCase("shutdown", "Shutdown computer")] + [TestCase("restart", "Restart computer")] + [TestCase("sign out", "Sign out of computer")] + [TestCase("lock", "Lock computer")] + [TestCase("sleep", "Put computer to sleep")] + [TestCase("hibernate", "Hibernate computer")] + [TestCase("empty recycle", "Empty Recycle Bin")] + public void QueryResults(string typedString, string expectedResult) + { + // Setup + Mock
main = new Mock
(); + string[] terms = { typedString }; + Query expectedQuery = new Query(typedString, typedString, new ReadOnlyCollection(terms), string.Empty); + + // Act + var result = main.Object.Query(expectedQuery).FirstOrDefault().SubTitle; + + // Assert + Assert.AreEqual(expectedResult, result); + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/lock.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/lock.dark.png new file mode 100644 index 000000000000..a91a4b325525 Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/lock.dark.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/lock.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/lock.light.png new file mode 100644 index 000000000000..8ed2f8e7a727 Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/lock.light.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/logoff.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/logoff.dark.png new file mode 100644 index 000000000000..601a49eff6db Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/logoff.dark.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/logoff.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/logoff.light.png new file mode 100644 index 000000000000..c7e055d7cf3b Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/logoff.light.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/recyclebin.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/recyclebin.dark.png new file mode 100644 index 000000000000..809d6ac27e7a Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/recyclebin.dark.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/recyclebin.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/recyclebin.light.png new file mode 100644 index 000000000000..6548f6c79590 Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/recyclebin.light.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/restart.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/restart.dark.png new file mode 100644 index 000000000000..60397b02ad06 Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/restart.dark.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/restart.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/restart.light.png new file mode 100644 index 000000000000..cae79c40b40b Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/restart.light.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/shutdown.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/shutdown.dark.png new file mode 100644 index 000000000000..dc6a55bec84e Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/shutdown.dark.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/shutdown.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/shutdown.light.png new file mode 100644 index 000000000000..ec0aac979375 Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/shutdown.light.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/sleep.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/sleep.dark.png new file mode 100644 index 000000000000..6c880dd4e8ff Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/sleep.dark.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/sleep.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/sleep.light.png new file mode 100644 index 000000000000..d185e7be0778 Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Images/sleep.light.png differ diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Main.cs new file mode 100644 index 000000000000..00dd6bc1c73b --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Main.cs @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Windows; +using System.Windows.Interop; +using ManagedCommon; +using Microsoft.Plugin.Sys.Win32; +using Wox.Infrastructure; +using Wox.Plugin; + +namespace Microsoft.Plugin.Sys +{ + public class Main : IPlugin, IPluginI18n + { + private PluginInitContext _context; + + internal const int EWXLOGOFF = 0x00000000; + internal const int EWXSHUTDOWN = 0x00000001; + internal const int EWXREBOOT = 0x00000002; + internal const int EWXFORCE = 0x00000004; + internal const int EWXPOWEROFF = 0x00000008; + internal const int EWXFORCEIFHUNG = 0x00000010; + + public string IconTheme { get; set; } + + public void Init(PluginInitContext context) + { + this._context = context; + _context.API.ThemeChanged += OnThemeChanged; + UpdateIconTheme(_context.API.GetCurrentTheme()); + } + + public List Query(Query query) + { + if (query == null) + { + throw new ArgumentNullException(paramName: nameof(query)); + } + + var commands = Commands(); + var results = new List(); + + foreach (var c in commands) + { + var titleMatch = StringMatcher.FuzzySearch(query.Search, c.Title); + if (titleMatch.Score > 0) + { + c.Score = titleMatch.Score; + c.SetTitleHighlightData(titleMatch.MatchData); + results.Add(c); + } + } + + return results; + } + + private List Commands() + { + var results = new List(); + results.AddRange(new[] + { + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_shutdown_computer, + SubTitle = Properties.Resources.Microsoft_plugin_sys_shutdown_computer_description, + IcoPath = $"Images\\shutdown.{IconTheme}.png", + Action = c => + { + Process.Start("shutdown", "/s /t 0"); + return true; + }, + }, + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_restart_computer, + SubTitle = Properties.Resources.Microsoft_plugin_sys_restart_computer_description, + IcoPath = $"Images\\restart.{IconTheme}.png", + Action = c => + { + Process.Start("shutdown", "/r /t 0"); + return true; + }, + }, + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_sign_out, + SubTitle = Properties.Resources.Microsoft_plugin_sys_sign_out_description, + IcoPath = $"Images\\logoff.{IconTheme}.png", + Action = c => + { + NativeMethods.ExitWindowsEx(EWXLOGOFF, 0); + return true; + }, + }, + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_lock, + SubTitle = Properties.Resources.Microsoft_plugin_sys_lock_description, + IcoPath = $"Images\\lock.{IconTheme}.png", + Action = c => + { + NativeMethods.LockWorkStation(); + return true; + }, + }, + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_sleep, + SubTitle = Properties.Resources.Microsoft_plugin_sys_sleep_description, + IcoPath = $"Images\\sleep.{IconTheme}.png", + Action = c => + { + NativeMethods.SetSuspendState(false, true, true); + return true; + }, + }, + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_hibernate, + SubTitle = Properties.Resources.Microsoft_plugin_sys_hibernate_description, + IcoPath = $"Images\\sleep.{IconTheme}.png", // Icon change needed + Action = c => + { + NativeMethods.SetSuspendState(true, true, true); + return true; + }, + }, + new Result + { + Title = Properties.Resources.Microsoft_plugin_sys_emptyrecyclebin, + SubTitle = Properties.Resources.Microsoft_plugin_sys_emptyrecyclebin_description, + IcoPath = $"Images\\recyclebin.{IconTheme}.png", + Action = c => + { + // http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html + // FYI, couldn't find documentation for this but if the recycle bin is already empty, it will return -2147418113 (0x8000FFFF (E_UNEXPECTED)) + // 0 for nothing + var result = NativeMethods.SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0); + if (result != (uint)NativeMethods.HRESULT.S_OK && result != 0x8000FFFF) + { + var name = "Plugin: " + Properties.Resources.Microsoft_plugin_sys_plugin_name; + var message = $"Error emptying recycle bin, error code: {result}\n" + + "please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137"; + _context.API.ShowMsg(name, message); + } + + return true; + }, + }, + }); + return results; + } + + private void UpdateIconTheme(Theme theme) + { + if (theme == Theme.Light || theme == Theme.HighContrastWhite) + { + IconTheme = "light"; + } + else + { + IconTheme = "dark"; + } + } + + private void OnThemeChanged(Theme currentTheme, Theme newTheme) + { + UpdateIconTheme(newTheme); + } + + public string GetTranslatedPluginDescription() + { + return Properties.Resources.Microsoft_plugin_sys_plugin_description; + } + + public string GetTranslatedPluginTitle() + { + return Properties.Resources.Microsoft_plugin_sys_plugin_name; + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Microsoft.Plugin.Sys.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Microsoft.Plugin.Sys.csproj new file mode 100644 index 000000000000..1c192329afd1 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Microsoft.Plugin.Sys.csproj @@ -0,0 +1,144 @@ + + + + + Library + netcoreapp3.1 + Properties + Microsoft.Plugin.Sys + Microsoft.Plugin.Sys + $(Version).0 + true + false + false + x64 + en-US + + + + true + ..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Microsoft.Plugin.Sys\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + 4 + false + + + + ..\..\..\..\..\x64\Release\modules\launcher\Plugins\Microsoft.Plugin.Sys\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + 4 + + + true + + + + true + + + + + + + + + GlobalSuppressions.cs + + + StyleCop.json + + + + + 1.1.118 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + 3.3.0 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + PreserveNewest + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Properties/Resources.Designer.cs new file mode 100644 index 000000000000..6aa3b2f6246e --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Properties/Resources.Designer.cs @@ -0,0 +1,207 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Plugin.Sys.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Plugin.Sys.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Empty Recycle Bin. + /// + internal static string Microsoft_plugin_sys_emptyrecyclebin { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_emptyrecyclebin", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Empty Recycle Bin. + /// + internal static string Microsoft_plugin_sys_emptyrecyclebin_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_emptyrecyclebin_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hibernate. + /// + internal static string Microsoft_plugin_sys_hibernate { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_hibernate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hibernate computer. + /// + internal static string Microsoft_plugin_sys_hibernate_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_hibernate_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lock. + /// + internal static string Microsoft_plugin_sys_lock { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_lock", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lock computer. + /// + internal static string Microsoft_plugin_sys_lock_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_lock_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Provides Windows related commands, shutdown, lock, sleep ..... + /// + internal static string Microsoft_plugin_sys_plugin_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_plugin_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Windows System Commands. + /// + internal static string Microsoft_plugin_sys_plugin_name { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_plugin_name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Restart. + /// + internal static string Microsoft_plugin_sys_restart_computer { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_restart_computer", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Restart computer. + /// + internal static string Microsoft_plugin_sys_restart_computer_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_restart_computer_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shutdown. + /// + internal static string Microsoft_plugin_sys_shutdown_computer { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_shutdown_computer", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shutdown computer. + /// + internal static string Microsoft_plugin_sys_shutdown_computer_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_shutdown_computer_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sign out. + /// + internal static string Microsoft_plugin_sys_sign_out { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_sign_out", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sign out of computer. + /// + internal static string Microsoft_plugin_sys_sign_out_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_sign_out_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sleep. + /// + internal static string Microsoft_plugin_sys_sleep { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_sleep", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Put computer to sleep. + /// + internal static string Microsoft_plugin_sys_sleep_description { + get { + return ResourceManager.GetString("Microsoft_plugin_sys_sleep_description", resourceCulture); + } + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Properties/Resources.resx b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Properties/Resources.resx new file mode 100644 index 000000000000..874a6540d1ef --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Properties/Resources.resx @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Empty Recycle Bin + This should align to the action in Windows of emptying the recycle bin on your computer. + + + Empty Recycle Bin + This should align to the action in Windows of emptying the recycle bin on your computer. + + + Hibernate + This should align to the action in Windows of a hibernating your computer. + + + Hibernate computer + This should align to the action in Windows of a hibernating your computer. + + + Lock + This should align to the action in Windows of a locking your computer. + + + Lock computer + This should align to the action in Windows of a locking your computer. + + + Provides Windows related commands, shutdown, lock, sleep .... + This should align to the actions in Windows relating to shutting down, signing out, locking, sleeping, restarting, emptying the recycle bin, and hibernating your computer. + + + Windows System Commands + Windows operating system commands. + + + Restart + This should align to the action in Windows of a restarting your computer. + + + Restart computer + This should align to the action in Windows of a restarting your computer. + + + Shutdown + This should align to the action in Windows of a shutting down your computer. + + + Shutdown computer + This should align to the action in Windows of a shutting down your computer. + + + Sign out + This should align to the action in windows of a signing out back to the lock screen. + + + Sign out of computer + This should align to the action in windows of a signing out back to the lock screen. + + + Sleep + This should align to the action in Windows of a making your computer go to sleep. + + + Put computer to sleep + This should align to the action in Windows of a making your computer go to sleep. + + \ No newline at end of file diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Win32/NativeMethods.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Win32/NativeMethods.cs new file mode 100644 index 000000000000..7e63e1de2c62 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/Win32/NativeMethods.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.Plugin.Sys.Win32 +{ + internal class NativeMethods + { + [DllImport("user32")] + internal static extern bool ExitWindowsEx(uint uFlags, uint dwReason); + + [DllImport("user32")] + internal static extern void LockWorkStation(); + + [DllImport("Shell32.dll", CharSet = CharSet.Unicode)] + internal static extern uint SHEmptyRecycleBin(IntPtr hWnd, uint dwFlags); + + [DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)] + internal static extern bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent); + + // http://www.pinvoke.net/default.aspx/Enums/HRESULT.html + public enum HRESULT : uint + { + S_FALSE = 0x0001, + S_OK = 0x0000, + } + } +} diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/plugin.json b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/plugin.json new file mode 100644 index 000000000000..759d7259b9b5 --- /dev/null +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Sys/plugin.json @@ -0,0 +1,12 @@ +{ + "ID":"CEA08895D2544B019B2E9C5009600DF4", + "ActionKeyword":"*", + "Name":"System Commands", + "Description":"Provide System related commands. e.g. shutdown,lock,setting etc.", + "Author":"Wox", + "Version":"1.0.0", + "Language":"csharp", + "Website":"https://aka.ms/powertoys", + "ExecuteFileName":"Microsoft.Plugin.Sys.dll", + "IcoPath":"Images\\lock.png" +} diff --git a/src/modules/launcher/Wox.Infrastructure/StringMatcher.cs b/src/modules/launcher/Wox.Infrastructure/StringMatcher.cs index bebe110f36b0..8679f18bb24a 100644 --- a/src/modules/launcher/Wox.Infrastructure/StringMatcher.cs +++ b/src/modules/launcher/Wox.Infrastructure/StringMatcher.cs @@ -9,6 +9,7 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.Plugin.Program.UnitTests")] +[assembly: InternalsVisibleTo("Microsoft.Plugin.Sys.UnitTests")] namespace Wox.Infrastructure {