Browse Source

just commit

HOME 4 weeks ago
parent
commit
66477ef942

+ 5 - 10
ChromePictureSearchExtension/wwwroot/ChromeExtension/background.js

@@ -8,17 +8,12 @@
 
 const idToUrl = {};
 
-chrome.runtime.onInstalled.addListener(function () {
-
-    menuItems.forEach(p => {
-        chrome.contextMenus.create({
-            id: p.id, contexts: ["image"], title: `${p.id}${p.name} 搜索图片`
-        })
-        idToUrl[p.id] = p.url;
+menuItems.forEach(p => {
+    chrome.contextMenus.create({
+        id: p.id, contexts: ["image"], title: `${p.id}${p.name} 搜索图片`
     })
-
-
-});
+    idToUrl[p.id] = p.url;
+})
 
 chrome.contextMenus.onClicked.addListener((info, tab) => {
     var searchUrl = idToUrl[info.menuItemId] + info.srcUrl;

File diff suppressed because it is too large
+ 1 - 1
IpAddressExpander/Program.cs


+ 65 - 0
SendCtrlC/Program.cs

@@ -0,0 +1,65 @@
+using System.Runtime.InteropServices;
+
+namespace SendCtrlC
+{
+    internal static class Program
+    {
+        [DllImport("kernel32.dll", SetLastError = true)]
+        private static extern bool AttachConsole(uint dwProcessId);
+
+        [DllImport("kernel32.dll", SetLastError = true)]
+        private static extern bool GenerateConsoleCtrlEvent(uint dwCtrlEvent, uint dwProcessGroupId);
+
+        [DllImport("kernel32.dll")]
+        private static extern bool FreeConsole();
+
+        [DllImport("kernel32.dll")]
+        private static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate? handlerRoutine, bool add);
+
+        private delegate bool ConsoleCtrlDelegate(uint ctrlType);
+
+        private const uint CTRL_C_EVENT = 0;
+
+        private enum ExitCode
+        {
+            Success = 0,
+            InvalidArgument = 1,
+            AttachConsoleFailed = 2,
+            GenerateCtrlEventFailed = 3
+        }
+
+        private static int Main(string[] args)
+        {
+            if (args.Length != 1)
+            {
+                return (int)ExitCode.InvalidArgument;
+            }
+
+            if (!uint.TryParse(args[0], out uint processId))
+            {
+                return (int)ExitCode.InvalidArgument;
+            }
+
+            // 尝试附加到指定进程的控制台
+            if (!AttachConsole(processId))
+            {
+                return (int)ExitCode.AttachConsoleFailed;
+            }
+
+            // 设置控制处理程序以避免自己进程接收到信号
+            SetConsoleCtrlHandler(null, true);
+
+            // 发送CTRL_C_EVENT
+            if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0))
+            {
+                return (int)ExitCode.GenerateCtrlEventFailed;
+            }
+
+            // 释放控制台
+            FreeConsole();
+
+            // 如果没有异常发生,退出代码为Success
+            return (int)ExitCode.Success;
+        }
+    }
+}

+ 11 - 0
SendCtrlC/SendCtrlC.csproj

@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net8.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <UseWindowsForms>false</UseWindowsForms>
+    <ImplicitUsings>enable</ImplicitUsings>
+  </PropertyGroup>
+
+</Project>

+ 7 - 0
StrangeTools.sln

@@ -108,6 +108,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WndTricker", "WndTricker\Wn
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChromePictureSearchExtension", "ChromePictureSearchExtension\ChromePictureSearchExtension.csproj", "{002A99F8-D7CF-4CB9-96EC-0EC3483BD822}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendCtrlC", "SendCtrlC\SendCtrlC.csproj", "{D78D0DC3-C680-40A6-AC91-ADBA4D89B1D4}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -290,6 +292,10 @@ Global
 		{002A99F8-D7CF-4CB9-96EC-0EC3483BD822}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{002A99F8-D7CF-4CB9-96EC-0EC3483BD822}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{002A99F8-D7CF-4CB9-96EC-0EC3483BD822}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D78D0DC3-C680-40A6-AC91-ADBA4D89B1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D78D0DC3-C680-40A6-AC91-ADBA4D89B1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D78D0DC3-C680-40A6-AC91-ADBA4D89B1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D78D0DC3-C680-40A6-AC91-ADBA4D89B1D4}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -342,6 +348,7 @@ Global
 		{FD45C8F2-2FFB-4856-BB29-5083250FCADB} = {3120ADE6-C606-42F1-9AA8-B7F1A8933CD7}
 		{4AE26278-2703-4F64-8A95-9348E0FFCF91} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
 		{002A99F8-D7CF-4CB9-96EC-0EC3483BD822} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+		{D78D0DC3-C680-40A6-AC91-ADBA4D89B1D4} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {017A8C58-F476-47E7-9CBE-077A98A76AB4}