mirror of
https://github.com/lin-ycv/EverythingPowerToys.git
synced 2025-01-08 11:57:59 +08:00
parent
f4dfbe2572
commit
a4a3c9c031
@ -2,7 +2,7 @@
|
||||
<Import Project="..\..\..\..\Version.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<ProjectGuid>{64467D32-4786-4ADD-9B77-FBF3C965D3D1}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Community.PowerToys.Run.Plugin.Everything</RootNamespace>
|
||||
|
@ -51,6 +51,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
if (CanFileBeRunAsAdmin(record.Path))
|
||||
{
|
||||
contextMenus.Add(CreateRunAsAdminContextMenu(record));
|
||||
contextMenus.Add(CreateRunAsUserContextMenu(record));
|
||||
}
|
||||
|
||||
// https://learn.microsoft.com/en-us/windows/apps/design/style/segoe-ui-symbol-font
|
||||
@ -169,6 +170,33 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
};
|
||||
}
|
||||
|
||||
// Function to add the context menu item to run as admin
|
||||
private static ContextMenuResult CreateRunAsUserContextMenu(SearchResult record)
|
||||
{
|
||||
return new ContextMenuResult
|
||||
{
|
||||
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
||||
Title = Properties.Resources.run_as_user,
|
||||
Glyph = "\xE7EE",
|
||||
FontFamily = "Segoe MDL2 Assets",
|
||||
AcceleratorKey = Key.U,
|
||||
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
|
||||
Action = _ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Task.Run(() => Helper.RunAsUser(record.Path));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception($"Failed to run {record.Path} as different user, {e.Message}", e, MethodBase.GetCurrentMethod().DeclaringType);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Function to test if the file can be run as admin
|
||||
private bool CanFileBeRunAsAdmin(string path)
|
||||
{
|
||||
|
11
Properties/Resources.Designer.cs
generated
11
Properties/Resources.Designer.cs
generated
@ -196,7 +196,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Selected result can update query text. Helps Display additional info, but may change display results..
|
||||
/// Looks up a localized string similar to Selected result can update query text. Helps display additional info, but may change display results..
|
||||
/// </summary>
|
||||
public static string QueryText_Description {
|
||||
get {
|
||||
@ -231,6 +231,15 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Run as different user (Ctrl+Shift+U).
|
||||
/// </summary>
|
||||
public static string run_as_user {
|
||||
get {
|
||||
return ResourceManager.GetString("run_as_user", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Copy.
|
||||
/// </summary>
|
||||
|
@ -174,10 +174,13 @@
|
||||
<data name="run_as_admin" xml:space="preserve">
|
||||
<value>Run as administrator (Ctrl+Shift+Enter)</value>
|
||||
</data>
|
||||
<data name="run_as_user" xml:space="preserve">
|
||||
<value>Run as different user (Ctrl+Shift+U)</value>
|
||||
</data>
|
||||
<data name="SwapCopy" xml:space="preserve">
|
||||
<value>Copy</value>
|
||||
</data>
|
||||
<data name="SwapCopy_Description" xml:space="preserve">
|
||||
<value>Set Ctrl+C to copy file/folder, Ctrl+Alt+C to copy path.</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
@ -162,6 +162,9 @@
|
||||
<data name="run_as_admin" xml:space="preserve">
|
||||
<value>以管理员身份运行 (Ctrl+Shift+Enter)</value>
|
||||
</data>
|
||||
<data name="run_as_user" xml:space="preserve">
|
||||
<value>以不同的使用者身份运行(Ctrl+Shift+U)</value>
|
||||
</data>
|
||||
<data name="SwapCopy_Description" xml:space="preserve">
|
||||
<value>使用 Ctrl+C 复制档案,Ctrl+Alt+C 复制路径</value>
|
||||
</data>
|
||||
|
@ -162,6 +162,9 @@
|
||||
<data name="run_as_admin" xml:space="preserve">
|
||||
<value>以系統管理員身分執行 (Ctrl+Shift+Enter)</value>
|
||||
</data>
|
||||
<data name="run_as_user" xml:space="preserve">
|
||||
<value>以不同的使用者身份執行 (Ctrl+Shift+U)</value>
|
||||
</data>
|
||||
<data name="SwapCopy_Description" xml:space="preserve">
|
||||
<value>使用 Ctrl+C 複製檔案,Ctrl+Alt+C 複製路徑</value>
|
||||
</data>
|
||||
|
@ -3,8 +3,8 @@
|
||||
"ActionKeyword": "@",
|
||||
"IsGlobal": true,
|
||||
"Name": "Everything",
|
||||
"Author": "Yu Chieh (Victor) Lin _0.64.1_",
|
||||
"Version": "0.64.1",
|
||||
"Author": "Yu Chieh (Victor) Lin _0.65.0_",
|
||||
"Version": "0.65.0",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Lin-ycv/EverythingPowerToys",
|
||||
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
|
||||
|
Loading…
Reference in New Issue
Block a user