1
之前退出登录才能多开,是因为微信设置了互斥锁,防止用户多开。快捷键估计也是微信设置了什么锁。我试试能不能解决。
好的,这个是个大痛点,有多开的用户,应该都用的上,期待能搞定😘
大佬,我搜了下,ai回复这样的,不知道可不可行,不懂这些代码,不敢去尝试修改。
config.ini
using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Threading; class WeChatMultiOpen { // 微信配置文件路径(需替换为你的实际路径) private static readonly string WeChatConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\WeChat Files\All Users\config\config.ini"; // 微信安装路径(默认路径,可修改) private static readonly string WeChatExePath = Environment.GetEnvironmentVariable("ProgramFiles(x86)") + @"\Tencent\WeChat\WeChat.exe"; public static void Main() { // 1. 确保微信关闭 KillWeChatProcesses(); // 2. 修改配置文件,设置不同快捷键 SetWeChatHotkey("Ctrl+Alt+Q", WeChatConfigPath); // 第一个实例 StartWeChat(); SetWeChatHotkey("Ctrl+Alt+E", WeChatConfigPath); // 第二个实例 StartWeChat(); Console.WriteLine("微信多开成功,快捷键已设置!"); Console.ReadKey(); } // 结束所有微信进程 private static void KillWeChatProcesses() { foreach (var process in Process.GetProcessesByName("WeChat")) { process.Kill(); process.WaitForExit(); } Thread.Sleep(1000); // 确保进程完全关闭 } // 启动微信 private static void StartWeChat() { Process.Start(WeChatExePath); Thread.Sleep(2000); // 等待微信启动 } // 修改微信快捷键配置 private static void SetWeChatHotkey(string hotkey, string configPath) { try { // 如果文件不存在,创建默认配置 if (!File.Exists(configPath)) { Directory.CreateDirectory(Path.GetDirectoryName(configPath)); File.WriteAllText(configPath, "[hotkey]\nopen=" + hotkey); } else { var lines = File.ReadAllLines(configPath); bool found = false; for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith("open=")) { lines[i] = "open=" + hotkey; found = true; break; } } if (!found) { Array.Resize(ref lines, lines.Length + 1); lines[lines.Length - 1] = "open=" + hotkey; } File.WriteAllLines(configPath, lines); } // 设置为只读,防止微信修改 File.SetAttributes(configPath, FileAttributes.ReadOnly); } catch (Exception ex) { Console.WriteLine("修改配置失败: " + ex.Message); } } }
使用 Visual Studio 创建一个 C# 控制台应用,粘贴代码。
修改 WeChatExePath 和 WeChatConfigPath 为你的微信实际路径。
WeChatExePath
WeChatConfigPath
编译运行(需要管理员权限)。
如果微信仍然会覆盖 config.ini,可以用 Windows API 强制绑定快捷键到不同微信窗口:
using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; class WeChatHotkeyManager { [DllImport("user32.dll")] public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk); [DllImport("user32.dll")] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("user32.dll")] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); private const int MOD_CTRL = 0x0002; private const int MOD_ALT = 0x0001; private const int HOTKEY_ID1 = 1; // Ctrl+Alt+Q private const int HOTKEY_ID2 = 2; // Ctrl+Alt+E public static void Main() { // 注册全局快捷键 RegisterHotKey(IntPtr.Zero, HOTKEY_ID1, MOD_CTRL | MOD_ALT, (int)Keys.Q); RegisterHotKey(IntPtr.Zero, HOTKEY_ID2, MOD_CTRL | MOD_ALT, (int)Keys.E); // 使用消息循环监听快捷键 Application.Run(new HotkeyMessageWindow()); // 退出时注销快捷键 UnregisterHotKey(IntPtr.Zero, HOTKEY_ID1); UnregisterHotKey(IntPtr.Zero, HOTKEY_ID2); } private class HotkeyMessageWindow : Form { protected override void WndProc(ref Message m) { if (m.Msg == 0x0312) // WM_HOTKEY { int id = m.WParam.ToInt32(); if (id == HOTKEY_ID1) { FocusWeChatWindow("微信1"); // 替换为你的微信窗口标题 } else if (id == HOTKEY_ID2) { FocusWeChatWindow("微信2"); } } base.WndProc(ref m); } private void FocusWeChatWindow(string windowTitle) { IntPtr hWnd = FindWindow(null, windowTitle); if (hWnd != IntPtr.Zero) { SetForegroundWindow(hWnd); } } } }
编译运行此代码(需要管理员权限)。
确保微信窗口标题正确(可以在任务管理器查看微信窗口名称)。
按下 Ctrl+Alt+Q 和 Ctrl+Alt+E 切换不同微信窗口。
Ctrl+Alt+Q
Ctrl+Alt+E
也要研究一下,毕竟涉及到用户的数据,确保安全。
之前退出登录才能多开,是因为微信设置了互斥锁,防止用户多开。快捷键估计也是微信设置了什么锁。我试试能不能解决。
好的,这个是个大痛点,有多开的用户,应该都用的上,期待能搞定😘
大佬,我搜了下,ai回复这样的,不知道可不可行,不懂这些代码,不敢去尝试修改。
方法 1:直接修改
config.ini
+ 多开微信代码示例
代码1
如何运行?
使用 Visual Studio 创建一个 C# 控制台应用,粘贴代码。
修改
WeChatExePath
和WeChatConfigPath
为你的微信实际路径。编译运行(需要管理员权限)。
方法 2:使用 Windows API 监听全局快捷键
如果微信仍然会覆盖
config.ini
,可以用 Windows API 强制绑定快捷键到不同微信窗口:代码2
运行方式
编译运行此代码(需要管理员权限)。
确保微信窗口标题正确(可以在任务管理器查看微信窗口名称)。
按下
Ctrl+Alt+Q
和Ctrl+Alt+E
切换不同微信窗口。也要研究一下,毕竟涉及到用户的数据,确保安全。