From 6ab18fdf70c1343891d18995164444c1efac5894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C5=A0paninger?= Date: Mon, 16 Sep 2024 06:52:25 +0000 Subject: [PATCH 1/5] Update FakeDeckUI/FakeDeck/Class/AutoUpdateHelper.cs --- FakeDeckUI/FakeDeck/Class/AutoUpdateHelper.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/FakeDeckUI/FakeDeck/Class/AutoUpdateHelper.cs b/FakeDeckUI/FakeDeck/Class/AutoUpdateHelper.cs index 5470aaa..996abea 100644 --- a/FakeDeckUI/FakeDeck/Class/AutoUpdateHelper.cs +++ b/FakeDeckUI/FakeDeck/Class/AutoUpdateHelper.cs @@ -20,6 +20,7 @@ namespace FakeDeck.Class AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent; AutoUpdater.Synchronous = true; AutoUpdater.ShowRemindLaterButton = false; + AutoUpdater.ClearAppDirectory = false; //AutoUpdater.ReportErrors = Debugger.IsAttached; AutoUpdater.HttpUserAgent = ("FakeDeck-v" + Assembly.GetExecutingAssembly().GetName().Version); AutoUpdater.Start("https://api.github.com/repos/GamerClassN7/FakeDeck/releases/latest"); From 1666be73b3349eef0e917baf43885c572ee585c3 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Tue, 17 Sep 2024 08:19:21 +0200 Subject: [PATCH 2/5] Readme --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 3beae3a..bbfabf3 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,16 @@ Just add desired macros to `configuration.yaml` and start the application, tahn - name: Key value: spacer ``` +### Process Macro +```yaml +- button: cmd + function: ProcessMacro + parameters: + - name: process + value: "cmd.exe" + - name: arguments #Optional Proces Arguments + value: "-d C:/" +``` ### Comon Macro Parameters ```yaml ... From 7fb6b4c89c27d59b2d90e79ba94c52b0e159d005 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 17 Sep 2024 06:17:43 -0700 Subject: [PATCH 3/5] Process Starting --- .../FakeDeck/ButtonType/ProcessMacro.cs | 47 +++++++++++++++++++ FakeDeckUI/FakeDeck/Class/FakeDeckMain.cs | 34 ++++++++------ FakeDeckUI/FakeDeck/configuration.yaml | 16 +++++++ 3 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs diff --git a/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs b/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs new file mode 100644 index 0000000..9f2ba34 --- /dev/null +++ b/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using System.Windows; +using static System.Text.Json.JsonElement; + +namespace FakeDeck.ButtonType +{ + class ProcessMacro : Button + { + public static string getButton(string process, string arguments = "", string? icon = null, string? image = null) + { + Dictionary parameters = new Dictionary() { { "process", process } }; + if (!string.IsNullOrEmpty(arguments)) + { + parameters.Add("arguments", arguments); + } + + if (!string.IsNullOrEmpty(icon) || !string.IsNullOrEmpty(image)) + { + process = null; + } + + return getButtonHTML(icon, image, process, "button\\ProcessMacro", null, parameters); + } + + public static bool invokeAction(string process, string arguments = "") + { + if (!System.IO.File.ReadAllText("./configuration.yaml").Contains(process)) + { + Debug.WriteLine("not known process"); + return true; + } + + Process notePad = new Process(); + notePad.StartInfo.FileName = process; + notePad.StartInfo.Arguments = arguments; + notePad.Start(); + return true; + } + } +} diff --git a/FakeDeckUI/FakeDeck/Class/FakeDeckMain.cs b/FakeDeckUI/FakeDeck/Class/FakeDeckMain.cs index 58c050c..2f17717 100644 --- a/FakeDeckUI/FakeDeck/Class/FakeDeckMain.cs +++ b/FakeDeckUI/FakeDeck/Class/FakeDeckMain.cs @@ -14,19 +14,19 @@ namespace FakeDeck.Class { private static string cachePath = "./cache/"; public static string pageHeader = - "" + - "" + - " " + - " HttpListener Example" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - "
"; + "" + + "" + + " " + + " HttpListener Example" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; public static string pageFooter = "
" + " " + @@ -161,7 +161,13 @@ namespace FakeDeck.Class string pageContent = ""; foreach (JsonElement button in selectedPage.GetProperty("buttons").EnumerateArray()) { - pageContent += AbstractionHelper.getButtonVisual(button); + try + { + pageContent += AbstractionHelper.getButtonVisual(button); + } + catch (Exception ex) { + + } } if (Directory.Exists(cachePath)) diff --git a/FakeDeckUI/FakeDeck/configuration.yaml b/FakeDeckUI/FakeDeck/configuration.yaml index cb23c76..70aeca4 100644 --- a/FakeDeckUI/FakeDeck/configuration.yaml +++ b/FakeDeckUI/FakeDeck/configuration.yaml @@ -108,6 +108,22 @@ pages: - page: media buttons: + - button: notepad + function: ProcessMacro + parameters: + - name: process + value: "notepad.exe" + - name: image + value: "https://www.club386.com/wp-content/uploads/2021/12/notepad-icon-696x632.jpg" + + - button: cmd + function: ProcessMacro + parameters: + - name: process + value: "cmd.exe" + - name: image + value: "https://winaero.com/blog/wp-content/uploads/2019/06/WIndows-Terminal-icon.png" + - button: mute function: MediaMacro parameters: From 9d33f9a223fe6bfe9ba5137445da1c3e1242725b Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Tue, 17 Sep 2024 08:21:01 +0200 Subject: [PATCH 4/5] Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbfabf3..5459352 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ Just add desired macros to `configuration.yaml` and start the application, tahn - name: process value: "cmd.exe" - name: arguments #Optional Proces Arguments - value: "-d C:/" + value: "/C ipconfig" ``` ### Comon Macro Parameters ```yaml From 600a08dd517075b44f59d0940ffda8e8c23ee5db Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 17 Sep 2024 06:23:17 -0700 Subject: [PATCH 5/5] Process Macro Fixes --- FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs | 11 +++++++++-- FakeDeckUI/FakeDeck/configuration.yaml | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs b/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs index 9f2ba34..0dbc210 100644 --- a/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs +++ b/FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; @@ -31,10 +32,16 @@ namespace FakeDeck.ButtonType public static bool invokeAction(string process, string arguments = "") { - if (!System.IO.File.ReadAllText("./configuration.yaml").Contains(process)) + if (!File.ReadAllText("./configuration.yaml").Contains(process)) { Debug.WriteLine("not known process"); - return true; + return false; + } + + if (!File.ReadAllText("./configuration.yaml").Contains(arguments)) + { + Debug.WriteLine("not known arguments"); + return false; } Process notePad = new Process(); diff --git a/FakeDeckUI/FakeDeck/configuration.yaml b/FakeDeckUI/FakeDeck/configuration.yaml index 70aeca4..51dee2b 100644 --- a/FakeDeckUI/FakeDeck/configuration.yaml +++ b/FakeDeckUI/FakeDeck/configuration.yaml @@ -121,6 +121,8 @@ pages: parameters: - name: process value: "cmd.exe" + - name: arguments + value: "/C ping google.com -t" - name: image value: "https://winaero.com/blog/wp-content/uploads/2019/06/WIndows-Terminal-icon.png"