Skip to content

Commit

Permalink
Issue #50 Added three parameters process_id, process_name, window_title
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderPro committed Dec 11, 2021
1 parent 49d5cd7 commit 7c33637
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
18 changes: 18 additions & 0 deletions SmartSystemMenu/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,24 @@ private void WindowGetMsg(object sender, WndProcEventArgs e)
foreach (var parameter in argumentParameters)
{
var parameterName = parameter.TrimStart(item.BeginParameter).TrimEnd(item.EndParameter);
if (string.Compare(parameterName, StartProgramMenuItem.PARAMETER_PROCESS_ID, true) == 0)
{
arguments = arguments.Replace(parameter, window.Process?.Id.ToString() ?? string.Empty);
continue;
}

if (string.Compare(parameterName, StartProgramMenuItem.PARAMETER_PROCESS_NAME, true) == 0)
{
arguments = arguments.Replace(parameter, Path.GetFileName(window.Process?.GetMainModuleFileName() ?? string.Empty));
continue;
}

if (string.Compare(parameterName, StartProgramMenuItem.PARAMETER_WINDOW_TITLE, true) == 0)
{
arguments = arguments.Replace(parameter, window.GetWindowText());
continue;
}

var parameterForm = new ParameterForm(parameterName, _settings.LanguageSettings);
var result = parameterForm.ShowDialog(window.Win32Window);

Expand Down
4 changes: 4 additions & 0 deletions SmartSystemMenu/Settings/StartProgramMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ namespace SmartSystemMenu.Settings
{
public class StartProgramMenuItem : ICloneable
{
public const string PARAMETER_PROCESS_ID = "process_id";
public const string PARAMETER_PROCESS_NAME = "process_name";
public const string PARAMETER_WINDOW_TITLE = "window_title";

public string Title { get; set; }

public string FileName { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions SmartSystemMenu/SmartSystemMenu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@
<item title="Calculator" fileName="calc.exe" arguments="" runAs="normal" showWindow="true" beginParameter="%" endParameter="%" />
<item title="Paint" fileName="mspaint.exe" arguments="" runAs="normal" showWindow="true" beginParameter="%" endParameter="%" />
<item title="Explorer" fileName="explorer.exe" arguments="" runAs="normal" showWindow="true" beginParameter="%" endParameter="%" />
<item title="Kill Process" fileName="taskkill.exe" arguments="/IM &quot;%Process Name%&quot; /F" runAs="administrator" showWindow="false" beginParameter="%" endParameter="%" />
<item title="Kill Process PID" fileName="taskkill.exe" arguments="/F /PID %PID%" runAs="administrator" showWindow="false" beginParameter="%" endParameter="%" />
<item title="Open Command Window" fileName="cmd.exe" arguments="" runAs="normal" showWindow="true" beginParameter="%" endParameter="%" />
<item title="Kill This Process" fileName="taskkill.exe" arguments="/F /PID %process_id%" runAs="administrator" showWindow="false" beginParameter="%" endParameter="%" />
<item title="Kill Process By PID" fileName="taskkill.exe" arguments="/F /PID %PID%" runAs="administrator" showWindow="false" beginParameter="%" endParameter="%" />
<item title="Kill Process By Name" fileName="taskkill.exe" arguments="/IM &quot;%Process Name%&quot; /F" runAs="administrator" showWindow="false" beginParameter="%" endParameter="%" />
</startProgramItems>
</menuItems>
<closer type="" key1="" key2="" mouseButton="" />
Expand Down
2 changes: 1 addition & 1 deletion SmartSystemMenu/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public WindowInfo GetWindowInfo()

try
{
info.Parent = Path.GetFileName(process.GetParentProcess().MainModule.FileName);
info.Parent = Path.GetFileName(process.GetParentProcess().GetMainModuleFileName());
}
catch
{
Expand Down

0 comments on commit 7c33637

Please sign in to comment.