├── readme ├── 说明.txt └── logo.png ├── 神龙辅助工具.suo ├── 神龙辅助工具 ├── shenlong.ico ├── bin │ └── Debug │ │ ├── 神龙辅助工具.vshost.exe │ │ ├── config.ini │ │ └── 神龙辅助工具.vshost.exe.manifest ├── Resources │ └── Newtonsoft.Json.dll ├── obj │ └── x86 │ │ └── Debug │ │ ├── 传奇辅助.Form1.resources │ │ ├── 传奇辅助.csproj.GenerateResource.Cache │ │ ├── DesignTimeResolveAssemblyReferences.cache │ │ ├── TempPE │ │ └── Properties.Resources.Designer.cs.dll │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ └── 传奇辅助.csproj.FileListAbsolute.txt ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Program.cs ├── MouseKeyboardActivityMonitor │ ├── Controls │ │ ├── HookType.cs │ │ └── MouseKeyEventProvider.cs │ ├── WinApi │ │ ├── Mouse.cs │ │ ├── GlobalHooker.cs │ │ ├── KeyboardHookStruct.cs │ │ ├── AppHooker.cs │ │ ├── Point.cs │ │ ├── HookCallback.cs │ │ ├── MouseStructures.cs │ │ ├── Messages.cs │ │ ├── Hooker.cs │ │ └── Keyboard.cs │ ├── KeyboardHookListener.cs │ ├── KeyEventArgsExt.cs │ ├── KeyPressEventArgsExt.cs │ ├── BaseHookListener.cs │ ├── MouseEventExtArgs.cs │ └── MouseHookListener.cs ├── Tools │ ├── FileHelper.cs │ ├── FormPositionHelper.cs │ ├── XmlUtils.cs │ ├── BatUtils.cs │ ├── MouseHelper.cs │ ├── WindowUserHelper.cs │ ├── HttpUtils.cs │ └── IniHelper.cs ├── UserControlGroup │ ├── UCReName.cs │ ├── UCWindowAccount.cs │ ├── UCReName.Designer.cs │ ├── UCMain.resx │ ├── UCReName.resx │ ├── UCWindowAccount.resx │ ├── UCWindowAccount.Designer.cs │ └── UCMain.cs ├── AutoClickThread.cs ├── 神龙辅助工具.csproj ├── Form1.cs └── Form1.Designer.cs ├── README.md └── 神龙辅助工具.sln /readme/说明.txt: -------------------------------------------------------------------------------- 1 | 这个目录用于保存README.md的图片 2 | -------------------------------------------------------------------------------- /神龙辅助工具.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具.suo -------------------------------------------------------------------------------- /readme/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/readme/logo.png -------------------------------------------------------------------------------- /神龙辅助工具/shenlong.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/shenlong.ico -------------------------------------------------------------------------------- /神龙辅助工具/bin/Debug/神龙辅助工具.vshost.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/bin/Debug/神龙辅助工具.vshost.exe -------------------------------------------------------------------------------- /神龙辅助工具/Resources/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/Resources/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /神龙辅助工具/obj/x86/Debug/传奇辅助.Form1.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/obj/x86/Debug/传奇辅助.Form1.resources -------------------------------------------------------------------------------- /神龙辅助工具/bin/Debug/config.ini: -------------------------------------------------------------------------------- 1 | [Setting] 2 | RecordHotKey=F5 3 | PlayHotKey=F6 4 | StopHotKey=F7 5 | Speed=2800 6 | IsUseKey=False 7 | Keyboard=F1 8 | DelayTime=5 9 | -------------------------------------------------------------------------------- /神龙辅助工具/obj/x86/Debug/传奇辅助.csproj.GenerateResource.Cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/obj/x86/Debug/传奇辅助.csproj.GenerateResource.Cache -------------------------------------------------------------------------------- /神龙辅助工具/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /神龙辅助工具/obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll -------------------------------------------------------------------------------- /神龙辅助工具/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/respost/DragonHelperTool/HEAD/神龙辅助工具/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /神龙辅助工具/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 神龙辅助工具 2 | ### 开发语言:C# 3 | ### 开发工具:Microsoft Visual Studio 2010 4 | ## 软件简述: 5 | 神龙辅助工具是个非常实用的键盘鼠标脚本录制工具,通过它你可以轻松地进行脚本录制,简单易用,不需要任何编程知识就能做出功能强大的脚本,只要你在电脑前用双手可以完成的动作,神龙辅助工具都可以替你完成。 6 | ## 功能说明: 7 | 1. 一款简单的物理辅助外挂,可实现对鼠标和键盘的操作记录,从而实现自动点击。 8 | 2. 可以自定义快捷键,自定义速度频率。 9 | 3. 可以导入脚本和导出脚本。 10 | 11 | 默认按键: 12 | 13 | F5 设置坐标点 14 | 15 | F6 开始播放脚本动作 16 | 17 | F7 停止播放 18 | 19 | ## 软件截图: 20 | ![logo.png](readme/logo.png) 21 | -------------------------------------------------------------------------------- /神龙辅助工具/obj/x86/Debug/传奇辅助.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\C#\传奇辅助\传奇辅助\bin\Debug\神龙辅助工具.exe 2 | E:\C#\传奇辅助\传奇辅助\bin\Debug\神龙辅助工具.pdb 3 | E:\C#\传奇辅助\传奇辅助\bin\Debug\Newtonsoft.Json.dll 4 | E:\C#\传奇辅助\传奇辅助\obj\x86\Debug\传奇辅助.Form1.resources 5 | E:\C#\传奇辅助\传奇辅助\obj\x86\Debug\神龙辅助工具.Properties.Resources.resources 6 | E:\C#\传奇辅助\传奇辅助\obj\x86\Debug\传奇辅助.csproj.GenerateResource.Cache 7 | E:\C#\传奇辅助\传奇辅助\obj\x86\Debug\神龙辅助工具.exe 8 | E:\C#\传奇辅助\传奇辅助\obj\x86\Debug\神龙辅助工具.pdb 9 | -------------------------------------------------------------------------------- /神龙辅助工具/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace 神龙辅助工具 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// 应用程序的主入口点。 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /神龙辅助工具/bin/Debug/神龙辅助工具.vshost.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/Controls/HookType.cs: -------------------------------------------------------------------------------- 1 | namespace MouseKeyboardActivityMonitor.Controls 2 | { 3 | /// 4 | /// Indicates which hooks to listen to application or global. 5 | /// 6 | public enum HookType 7 | { 8 | /// 9 | /// Only events inside the application are monitored and fired. 10 | /// 11 | Application, 12 | 13 | /// 14 | /// All events system wide are monitored and fired. 15 | /// 16 | Global 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /神龙辅助工具.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "神龙辅助工具", "神龙辅助工具\神龙辅助工具.csproj", "{BC0EA7AA-90E1-4F63-8334-57DB183D5735}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {BC0EA7AA-90E1-4F63-8334-57DB183D5735}.Debug|x86.ActiveCfg = Debug|x86 13 | {BC0EA7AA-90E1-4F63-8334-57DB183D5735}.Debug|x86.Build.0 = Debug|x86 14 | {BC0EA7AA-90E1-4F63-8334-57DB183D5735}.Release|x86.ActiveCfg = Release|x86 15 | {BC0EA7AA-90E1-4F63-8334-57DB183D5735}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/Mouse.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MouseKeyboardActivityMonitor.WinApi 4 | { 5 | internal class Mouse 6 | { 7 | /// 8 | /// The GetDoubleClickTime function retrieves the current double-click time for the mouse. A double-click is a series of two clicks of the 9 | /// mouse button, the second occurring within a specified time after the first. The double-click time is the maximum number of 10 | /// milliseconds that may occur between the first and second click of a double-click. 11 | /// 12 | /// 13 | /// The return value specifies the current double-click time, in milliseconds. 14 | /// 15 | /// 16 | /// http://msdn.microsoft.com/en-us/library/ms646258(VS.85).aspx 17 | /// 18 | [DllImport("user32")] 19 | internal static extern int GetDoubleClickTime(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace 神龙辅助工具 7 | { 8 | /// 9 | /// 文件操作辅助类 10 | /// 11 | static class FileHelper 12 | { 13 | /// 14 | /// 读文件 15 | /// 16 | /// 文件名 17 | /// 文件内容 18 | public static List ReadAllText(string fullName) 19 | { 20 | return System.IO.File.ReadLines(fullName, Encoding.Default).ToList(); 21 | } 22 | 23 | /// 24 | /// 写文件 25 | /// 26 | /// 文件名 27 | /// 待写内容 28 | public static void WriteAllText(string fullName, List content) 29 | { 30 | System.IO.File.WriteAllLines(fullName, content.ToArray(), Encoding.Default); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /神龙辅助工具/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace 神龙辅助工具.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /神龙辅助工具/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("神龙辅助工具")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("神龙辅助工具")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("0dce74d5-6279-401e-9b4c-8ed7972f81af")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/GlobalHooker.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace MouseKeyboardActivityMonitor.WinApi 4 | { 5 | /// 6 | /// Provides methods for subscription and unsubscription to global mouse and keyboard hooks. 7 | /// 8 | public class GlobalHooker : Hooker 9 | { 10 | internal override int Subscribe(int hookId, HookCallback hookCallback) 11 | { 12 | int hookHandle = SetWindowsHookEx( 13 | hookId, 14 | hookCallback, 15 | Process.GetCurrentProcess().MainModule.BaseAddress, 16 | 0); 17 | 18 | if (hookHandle == 0) 19 | { 20 | ThrowLastUnmanagedErrorAsException(); 21 | } 22 | 23 | return hookHandle; 24 | } 25 | 26 | internal override bool IsGlobal 27 | { 28 | get { return true; } 29 | } 30 | 31 | /// 32 | /// Windows NT/2000/XP/Vista/7: Installs a hook procedure that monitors low-level mouse input events. 33 | /// 34 | internal const int WH_MOUSE_LL = 14; 35 | 36 | /// 37 | /// Windows NT/2000/XP/Vista/7: Installs a hook procedure that monitors low-level keyboard input events. 38 | /// 39 | internal const int WH_KEYBOARD_LL = 13; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/KeyboardHookStruct.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MouseKeyboardActivityMonitor.WinApi 4 | { 5 | /// 6 | /// The KeyboardHookStruct structure contains information about a low-level keyboard input event. 7 | /// 8 | /// 9 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookstructures/cwpstruct.asp 10 | /// 11 | [StructLayout(LayoutKind.Sequential)] 12 | internal struct KeyboardHookStruct 13 | { 14 | /// 15 | /// Specifies a virtual-key code. The code must be a value in the range 1 to 254. 16 | /// 17 | public int VirtualKeyCode; 18 | /// 19 | /// Specifies a hardware scan code for the key. 20 | /// 21 | public int ScanCode; 22 | /// 23 | /// Specifies the extended-key flag, event-injected flag, context code, and transition-state flag. 24 | /// 25 | public int Flags; 26 | /// 27 | /// Specifies the Time stamp for this message. 28 | /// 29 | public int Time; 30 | /// 31 | /// Specifies extra information associated with the message. 32 | /// 33 | public int ExtraInfo; 34 | } 35 | } -------------------------------------------------------------------------------- /神龙辅助工具/Tools/FormPositionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Win32; 6 | 7 | namespace 神龙辅助工具 8 | { 9 | class FormPositionHelper 10 | { 11 | // 在HKEY_CURRENT_USER 设置注册表的路径 12 | public static string RegPath = @"Software\Tool\ShenLong"; 13 | public static void SaveSize(System.Windows.Forms.Form frm) 14 | { 15 | try 16 | { 17 | RegistryKey key; 18 | key = Registry.LocalMachine.CreateSubKey(RegPath + frm.Name); 19 | key.SetValue("Height", frm.Height); 20 | key.SetValue("Width", frm.Width); 21 | key.SetValue("Left", frm.Left); 22 | key.SetValue("Top", frm.Top); 23 | } 24 | catch (Exception) 25 | { 26 | } 27 | } 28 | public static void SetSize(System.Windows.Forms.Form frm) 29 | { 30 | //OpenSubKey第二个参数可以设置注册表的访问权限,如果需要项的写访问权限,请设置为True 31 | try 32 | { 33 | RegistryKey key; 34 | key = Registry.LocalMachine.OpenSubKey(RegPath + frm.Name, true); 35 | if (key != null) 36 | { 37 | frm.Height = (int)key.GetValue("Height"); 38 | frm.Width = (int)key.GetValue("Width"); 39 | frm.Left = (int)key.GetValue("Left"); 40 | frm.Top = (int)key.GetValue("Top"); 41 | } 42 | } 43 | catch (Exception) 44 | { 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/AppHooker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MouseKeyboardActivityMonitor.WinApi 5 | { 6 | /// 7 | /// Provides methods for subscription and unsubscription to application mouse and keyboard hooks. 8 | /// 9 | public class AppHooker : Hooker 10 | { 11 | /// 12 | /// Installs a hook procedure that monitors mouse messages. For more information, see the MouseProc hook procedure. 13 | /// 14 | internal const int WH_MOUSE = 7; 15 | 16 | /// 17 | /// Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure. 18 | /// 19 | internal const int WH_KEYBOARD = 2; 20 | 21 | internal override int Subscribe(int hookId, HookCallback hookCallback) 22 | { 23 | int hookHandle = SetWindowsHookEx( 24 | hookId, 25 | hookCallback, 26 | IntPtr.Zero, 27 | GetCurrentThreadId()); 28 | 29 | if (hookHandle == 0) 30 | { 31 | ThrowLastUnmanagedErrorAsException(); 32 | } 33 | 34 | return hookHandle; 35 | } 36 | 37 | internal override bool IsGlobal 38 | { 39 | get { return false; } 40 | } 41 | 42 | /// 43 | /// Retrieves the unmanaged thread identifier of the calling thread. 44 | /// 45 | /// 46 | [DllImport("kernel32")] 47 | private static extern int GetCurrentThreadId(); 48 | } 49 | } -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/Point.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace MouseKeyboardActivityMonitor.WinApi 4 | { 5 | /// 6 | /// The Point structure defines the X- and Y- coordinates of a point. 7 | /// 8 | /// 9 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/rectangl_0tiq.asp 10 | /// 11 | [StructLayout(LayoutKind.Sequential)] 12 | internal struct Point { 13 | /// 14 | /// Specifies the X-coordinate of the point. 15 | /// 16 | public int X; 17 | /// 18 | /// Specifies the Y-coordinate of the point. 19 | /// 20 | public int Y; 21 | 22 | public Point(int x, int y) 23 | { 24 | X = x; 25 | Y = y; 26 | } 27 | 28 | public static bool operator ==(Point a, Point b) 29 | { 30 | return a.X == b.X && a.Y == b.Y; 31 | } 32 | 33 | public static bool operator !=(Point a, Point b) 34 | { 35 | return !(a == b); 36 | } 37 | 38 | public bool Equals(Point other) 39 | { 40 | return other.X == X && other.Y == Y; 41 | } 42 | 43 | public override bool Equals(object obj) 44 | { 45 | if (ReferenceEquals(null, obj)) return false; 46 | if (obj.GetType() != typeof (Point)) return false; 47 | return Equals((Point) obj); 48 | } 49 | 50 | public override int GetHashCode() 51 | { 52 | unchecked 53 | { 54 | return (X*397) ^ Y; 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCReName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Diagnostics; 10 | using System.IO; 11 | 12 | namespace 神龙辅助工具 13 | { 14 | /// 15 | /// 用户控件:自定义程序名 16 | /// 17 | public partial class UCReName : UserControl 18 | { 19 | public UCReName() 20 | { 21 | InitializeComponent(); 22 | } 23 | 24 | private void btnSave_Click(object sender, EventArgs e) 25 | { 26 | string appName = txtAppName.Text.Trim(); 27 | if (appName == string.Empty) 28 | { 29 | MessageBox.Show("请输入程序名称"); 30 | return; 31 | } 32 | if (!appName.Contains(".exe")) 33 | appName += ".exe"; 34 | string newFilePath = Environment.CurrentDirectory + "//" + appName; 35 | //获取当前进程名称 36 | Process cur = Process.GetCurrentProcess(); 37 | string processName = cur.ProcessName; 38 | //正在运行的程序路径和文件名 39 | string oldFilePath = Application.ExecutablePath; 40 | string appBat = String.Format(@" 41 | @echo off 42 | taskkill /f /im {0} 43 | ren {0} {1} 44 | del /q /f {2} 45 | start {3}", processName + ".exe", appName, oldFilePath, newFilePath); 46 | BatUtils.writeBATFile(appBat, "修改进程名.bat"); 47 | //隐藏文件 48 | FileInfo fi = new FileInfo(Environment.CurrentDirectory + "\\修改进程名.bat"); 49 | fi.Attributes = fi.Attributes | FileAttributes.Hidden; 50 | if (File.Exists("修改进程名.bat")) 51 | { 52 | BatUtils.runBATFile(Environment.CurrentDirectory, "修改进程名.bat"); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /神龙辅助工具/AutoClickThread.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | 7 | namespace 神龙辅助工具 8 | { 9 | /// 10 | /// 自动点击线程类 11 | /// 12 | static class AutoClickThread 13 | { 14 | public static List ClickData; 15 | static CancellationTokenSource cts; 16 | 17 | //开始 18 | public static void Start(bool isRecycleRun) 19 | { 20 | if (ClickData.Count == 0) return; 21 | 22 | if (cts != null && !cts.IsCancellationRequested) return; 23 | cts = new CancellationTokenSource(); 24 | ThreadPool.QueueUserWorkItem(new WaitCallback(Run), isRecycleRun); 25 | } 26 | 27 | //停止 28 | public static void Stop() 29 | { 30 | if (cts != null) 31 | cts.Cancel(); 32 | } 33 | 34 | //执行 35 | static void Run(object isRecycleRun) 36 | { 37 | string[] stringArray; 38 | int x, y, sleepTime; 39 | 40 | do 41 | { 42 | foreach (string item in ClickData) 43 | { 44 | if (cts.Token.IsCancellationRequested) return; 45 | 46 | stringArray = item.Split('|'); 47 | x = int.Parse(stringArray[0]); 48 | y = int.Parse(stringArray[1]); 49 | sleepTime = int.Parse(stringArray[3]); 50 | 51 | switch (stringArray[2]) 52 | { 53 | case "左键单击": MouseHelper.LeftButtonClick(x, y); break; 54 | case "左键双击": MouseHelper.LeftButtonDoubleClick(x, y); break; 55 | case "右键单击": MouseHelper.RightButtonClick(x, y); break; 56 | case "右键双击": MouseHelper.RightButtonDoubleClick(x, y); break; 57 | } 58 | 59 | Thread.Sleep(sleepTime); 60 | } 61 | } 62 | while ((bool)isRecycleRun); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/HookCallback.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MouseKeyboardActivityMonitor.WinApi 4 | { 5 | /// 6 | /// The CallWndProc hook procedure is an application-defined or library-defined callback 7 | /// function used with the SetWindowsHookEx function. The HOOKPROC type defines a pointer 8 | /// to this callback function. CallWndProc is a placeholder for the application-defined 9 | /// or library-defined function name. 10 | /// 11 | /// 12 | /// [in] Specifies whether the hook procedure must process the message. 13 | /// If nCode is HC_ACTION, the hook procedure must process the message. 14 | /// If nCode is less than zero, the hook procedure must pass the message to the 15 | /// CallNextHookEx function without further processing and must return the 16 | /// value returned by CallNextHookEx. 17 | /// 18 | /// 19 | /// [in] Specifies whether the message was sent by the current thread. 20 | /// If the message was sent by the current thread, it is nonzero; otherwise, it is zero. 21 | /// 22 | /// 23 | /// [in] Pointer to a CWPSTRUCT structure that contains details about the message. 24 | /// 25 | /// 26 | /// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx. 27 | /// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx 28 | /// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC 29 | /// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook 30 | /// procedure does not call CallNextHookEx, the return value should be zero. 31 | /// 32 | /// 33 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/callwndproc.asp 34 | /// 35 | public delegate int HookCallback(int nCode, int wParam, IntPtr lParam); 36 | } -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCWindowAccount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Threading; 10 | 11 | namespace 神龙辅助工具 12 | { 13 | public partial class UCWindowAccount : UserControl 14 | { 15 | public UCWindowAccount() 16 | { 17 | InitializeComponent(); 18 | /*在多线程程序中: 19 | * 新创建的线程不能访问UI线程创建的窗口控件, 20 | * 如果需要访问窗口中的控件,可以在窗口构造函数中将CheckForIllegalCrossThreadCalls设置为false 21 | */ 22 | Control.CheckForIllegalCrossThreadCalls = false; 23 | } 24 | 25 | private void btnCreate_Click(object sender, EventArgs e) 26 | { 27 | if (this.btnCreate.Text == "创建用户") 28 | { 29 | string userName = textUserName.Text.Trim(); 30 | if (userName == string.Empty) 31 | { 32 | MessageBox.Show("请输入用户名"); 33 | return; 34 | } 35 | string password = textPassword.Text.Trim(); 36 | if (password == string.Empty) 37 | { 38 | MessageBox.Show("请输入登录密码"); 39 | return; 40 | } 41 | this.btnCreate.Text = "请稍候,正在创建..."; 42 | // 使用子线程去创建,防止界面卡顿。 43 | new Thread(new ThreadStart(this.PerformTask)) { IsBackground = true }.Start(); 44 | 45 | } 46 | } 47 | private void PerformTask() 48 | { 49 | try 50 | { 51 | string userName = textUserName.Text.Trim(); 52 | string password = textPassword.Text.Trim(); 53 | WindowUserHelper.AddUser(userName, password); 54 | MessageBox.Show("创建用户成功"); 55 | this.btnCreate.Text = "创建用户"; 56 | } 57 | catch (Exception ex) 58 | { 59 | MessageBox.Show(ex.Message); 60 | this.btnCreate.Text = "创建用户"; 61 | } 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /神龙辅助工具/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace 神龙辅助工具.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("神龙辅助工具.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// 查找 System.Byte[] 类型的本地化资源。 65 | /// 66 | internal static byte[] Newtonsoft_Json { 67 | get { 68 | object obj = ResourceManager.GetObject("Newtonsoft_Json", resourceCulture); 69 | return ((byte[])(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/XmlUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml; 6 | using System.IO; 7 | using System.Net; 8 | 9 | namespace 神龙辅助工具 10 | { 11 | class XmlUtils 12 | { 13 | public static string GetNodeValue(string xmlUrl, string noneNmae, string key) 14 | { 15 | string result = ""; 16 | using (XmlReader read = XmlReader.Create(xmlUrl)) 17 | { 18 | while (read.Read()) 19 | { 20 | if (read.Name == noneNmae) 21 | { 22 | result = read.GetAttribute(key); 23 | break; 24 | } 25 | } 26 | } 27 | return result; 28 | } 29 | /// 30 | /// 读取xml配置文件 31 | /// 32 | /// 33 | /// xml文件路径 34 | /// 35 | public static string GetValueByKey(string strKey, string xmlFileName) 36 | { 37 | string result = ""; 38 | XmlDocument doc = new XmlDocument(); 39 | //获得配置文件的全路径 40 | doc.Load(xmlFileName); 41 | //找出名称为“add”的所有元素 42 | XmlNodeList nodes = doc.GetElementsByTagName("add"); 43 | for (int i = 0; i < nodes.Count; i++) 44 | { 45 | //获得将当前元素的key属性 46 | XmlAttribute att = nodes[i].Attributes["key"]; 47 | //根据元素的第一个属性来判断当前的元素是不是目标元素 48 | if (att.Value == strKey) 49 | { 50 | //对目标元素中的第二个属性赋值 51 | XmlAttribute zf = nodes[i].Attributes["value"]; 52 | result = zf.Value; 53 | break; 54 | } 55 | } 56 | //返回Value的值 57 | return result.ToString(); 58 | } 59 | /// 60 | /// 保存xml配置文件 61 | /// 62 | /// 63 | /// 64 | /// xml文件路径 65 | public static void SaveValueToXml(string ConnenctionString, string strKey, string xmlFileName) 66 | { 67 | XmlDocument doc = new XmlDocument(); 68 | doc.Load(xmlFileName); 69 | //找出名称为“add”的所有元素 70 | XmlNodeList nodes = doc.GetElementsByTagName("add"); 71 | for (int i = 0; i < nodes.Count; i++) 72 | { 73 | //获得将当前元素的key属性 74 | XmlAttribute att = nodes[i].Attributes["key"]; 75 | //根据元素的第一个属性来判断当前的元素是不是目标元素 76 | if (att.Value == strKey) 77 | { 78 | //对目标元素中的第二个属性赋值 79 | att = nodes[i].Attributes["value"]; 80 | att.Value = ConnenctionString; 81 | break; 82 | } 83 | } 84 | //保存上面的修改 85 | doc.Save(xmlFileName); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/BatUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Diagnostics; 7 | 8 | namespace 神龙辅助工具 9 | { 10 | /// 11 | /// 批处理工具类 12 | /// 13 | class BatUtils 14 | { 15 | /// 16 | /// 写入bat文件 17 | /// 18 | /// 19 | /// 20 | public static void writeBATFile(string fileContent, string filePath) 21 | { 22 | FileStream fs1 = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);//创建写入文件 23 | StreamWriter sw = new StreamWriter(fs1, Encoding.GetEncoding("GB2312")); 24 | sw.WriteLine(fileContent);//开始写入值 25 | sw.Close(); 26 | fs1.Close(); 27 | } 28 | /// 29 | /// 执行bat文件 30 | /// 31 | /// 所在目录 32 | /// 文件名 33 | public static bool runBATFile(string filePath, string fileName) 34 | { 35 | bool flag = false; 36 | Process proc = null; 37 | try 38 | { 39 | string targetDir = string.Format(filePath); 40 | proc = new Process(); 41 | proc.StartInfo.WorkingDirectory = targetDir; 42 | proc.StartInfo.FileName = fileName; 43 | proc.StartInfo.Arguments = string.Format("10"); 44 | proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//这里设置DOS窗口不显示 45 | proc.Start(); 46 | proc.WaitForExit(); 47 | proc.Close(); 48 | flag = true; 49 | } 50 | catch (Exception ex) 51 | { 52 | flag = false; 53 | Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString()); 54 | } 55 | return flag; 56 | } 57 | /// 58 | /// 运行cmd命令 59 | /// 60 | /// 61 | public static void RunCmd(string command) 62 | { 63 | //不管命令是否成功均执行exit命令,否则当调用ReadToEnd()方法时,会处于假死状态 64 | //command = command.Trim().TrimEnd('&') + "&exit"; 65 | using (Process p = new Process()) 66 | { 67 | p.StartInfo.FileName = "cmd.exe"; 68 | //是否使用操作系统shell启动 69 | p.StartInfo.UseShellExecute = false; 70 | //接受来自调用程序的输入信息 71 | p.StartInfo.RedirectStandardInput = true; 72 | //输出信息 73 | p.StartInfo.RedirectStandardOutput = true; 74 | //输出错误 75 | p.StartInfo.RedirectStandardError = true; 76 | //不显示程序窗口 77 | p.StartInfo.CreateNoWindow = true; 78 | //启动程序 79 | p.Start(); 80 | //向cmd窗口发送输入信息 81 | p.StandardInput.AutoFlush = true; 82 | p.StandardInput.WriteLine(command); 83 | //获取cmd窗口的输出信息 84 | //string output = p.StandardOutput.ReadToEnd(); 85 | p.WaitForExit();//等待程序执行完退出进程 86 | p.Close(); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/MouseHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Threading; 4 | 5 | namespace 神龙辅助工具 6 | { 7 | /// 8 | /// 鼠标事件辅助类 9 | /// 10 | public sealed class MouseHelper 11 | { 12 | #region WinAPI 13 | 14 | /// 15 | /// 鼠标事件类型 16 | /// 17 | private enum MouseEventFlags //鼠标按键的ASCLL码 18 | { 19 | Move = 0x0001, 20 | LeftDown = 0x0002, 21 | LeftUp = 0x0004, 22 | RightDown = 0x0008, 23 | RightUp = 0x0010, 24 | MiddleDown = 0x0020, 25 | MiddleUp = 0x0040, 26 | Wheel = 0x0800, 27 | Absolute = 0x8000 28 | } 29 | 30 | [StructLayout(LayoutKind.Sequential)] 31 | public struct POINT 32 | { 33 | public int X; 34 | public int Y; 35 | } 36 | 37 | /// 38 | /// 鼠标事件 39 | /// 40 | /// 事件类型 41 | /// X坐标 42 | /// Y坐标 43 | /// 44 | /// 45 | [DllImport("User32")] 46 | private extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo); 47 | 48 | [DllImport("User32")] 49 | public extern static void SetCursorPos(int x, int y); 50 | 51 | [DllImport("User32")] 52 | public extern static bool GetCursorPos(out POINT p); 53 | 54 | #endregion 55 | 56 | /// 57 | /// 鼠标左键单击 58 | /// 59 | /// X 60 | /// Y 61 | public static void LeftButtonClick(int x = 0, int y = 0) 62 | { 63 | SetCursorPos(x, y); 64 | mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero); 65 | Thread.Sleep(100); 66 | mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero); 67 | } 68 | 69 | /// 70 | /// 鼠标右键单击 71 | /// 72 | /// X 73 | /// Y 74 | public static void RightButtonClick(int x = 0, int y = 0) 75 | { 76 | SetCursorPos(x, y); 77 | mouse_event((int)(MouseEventFlags.RightDown | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero); 78 | Thread.Sleep(100); 79 | mouse_event((int)(MouseEventFlags.RightUp | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero); 80 | } 81 | 82 | /// 83 | /// 鼠标左键双击 84 | /// 85 | /// X 86 | /// Y 87 | public static void LeftButtonDoubleClick(int x = 0, int y = 0) 88 | { 89 | LeftButtonClick(x, y); 90 | Thread.Sleep(200); 91 | LeftButtonClick(x, y); 92 | } 93 | 94 | /// 95 | /// 鼠标右键双击 96 | /// 97 | /// X 98 | /// Y 99 | public static void RightButtonDoubleClick(int x = 0, int y = 0) 100 | { 101 | RightButtonClick(x, y); 102 | Thread.Sleep(200); 103 | RightButtonClick(x, y); 104 | } 105 | 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/MouseStructures.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MouseKeyboardActivityMonitor.WinApi 5 | { 6 | 7 | /// 8 | /// The structure contains information about a mouse input event. 9 | /// 10 | /// 11 | /// See full documentation at http://globalmousekeyhook.codeplex.com/wikipage?title=MouseStruct 12 | /// 13 | [StructLayout(LayoutKind.Explicit)] 14 | internal struct MouseStruct 15 | { 16 | /// 17 | /// Specifies a Point structure that contains the X- and Y-coordinates of the cursor, in screen coordinates. 18 | /// 19 | [FieldOffset(0x00)] 20 | public Point Point; 21 | 22 | /// 23 | /// Specifies information associated with the message. 24 | /// 25 | /// 26 | /// The possible values are: 27 | /// 28 | /// 29 | /// 0 - No Information 30 | /// 31 | /// 32 | /// 1 - X-Button1 Click 33 | /// 34 | /// 35 | /// 2 - X-Button2 Click 36 | /// 37 | /// 38 | /// 120 - Mouse Scroll Away from User 39 | /// 40 | /// 41 | /// -120 - Mouse Scroll Toward User 42 | /// 43 | /// 44 | /// 45 | [FieldOffset(0x0A)] 46 | public Int16 MouseData; 47 | 48 | /// 49 | /// Returns a Timestamp associated with the input, in System Ticks. 50 | /// 51 | [FieldOffset(0x10)] 52 | public Int32 Timestamp; 53 | } 54 | 55 | /// 56 | /// The AppMouseStruct structure contains information about a application-level mouse input event. 57 | /// 58 | /// 59 | /// See full documentation at http://globalmousekeyhook.codeplex.com/wikipage?title=MouseStruct 60 | /// 61 | [StructLayout(LayoutKind.Explicit)] 62 | internal struct AppMouseStruct 63 | { 64 | 65 | /// 66 | /// Specifies a Point structure that contains the X- and Y-coordinates of the cursor, in screen coordinates. 67 | /// 68 | [FieldOffset(0x00)] 69 | public Point Point; 70 | 71 | /// 72 | /// Specifies information associated with the message. 73 | /// 74 | /// 75 | /// The possible values are: 76 | /// 77 | /// 78 | /// 0 - No Information 79 | /// 80 | /// 81 | /// 1 - X-Button1 Click 82 | /// 83 | /// 84 | /// 2 - X-Button2 Click 85 | /// 86 | /// 87 | /// 120 - Mouse Scroll Away from User 88 | /// 89 | /// 90 | /// -120 - Mouse Scroll Toward User 91 | /// 92 | /// 93 | /// 94 | #if IS_X64 95 | [FieldOffset(0x22)] 96 | #else 97 | [FieldOffset(0x16)] 98 | #endif 99 | public Int16 MouseData; 100 | 101 | /// 102 | /// Converts the current into a . 103 | /// 104 | /// 105 | /// 106 | /// The AppMouseStruct does not have a timestamp, thus one is generated at the time of this call. 107 | /// 108 | public MouseStruct ToMouseStruct() 109 | { 110 | MouseStruct tmp = new MouseStruct(); 111 | tmp.Point = this.Point; 112 | tmp.MouseData = this.MouseData; 113 | tmp.Timestamp = Environment.TickCount; 114 | return tmp; 115 | } 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/WindowUserHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.DirectoryServices; 6 | 7 | namespace 神龙辅助工具 8 | { 9 | /// 10 | /// 计算机用户和组操作辅助类 11 | /// 12 | class WindowUserHelper 13 | { 14 | private static readonly string PATH = "WinNT://" + Environment.MachineName; 15 | /// 16 | /// 添加windows用户 17 | /// 18 | /// 用户名 19 | /// 密码 20 | /// 所属组 21 | /// 描述 22 | public static void AddUser(string username, string password, string group ="Users", string description="新增管理员用户") 23 | { 24 | using (DirectoryEntry dir = new DirectoryEntry(PATH)) 25 | { 26 | using (DirectoryEntry user = dir.Children.Add(username, "User")) //增加用户名 27 | { 28 | user.Properties["FullName"].Add(username); //用户全称 29 | user.Invoke("SetPassword", password); //用户密码 30 | user.Invoke("Put", "Description", description);//用户详细描述 31 | //user.Invoke("Put","PasswordExpired",1); //用户下次登录需更改密码 32 | user.Invoke("Put", "UserFlags", 66049); //密码永不过期 33 | //user.Invoke("Put", "UserFlags", 0x0040);//用户不能更改密码s 34 | user.CommitChanges();//保存用户 35 | using (DirectoryEntry grp = dir.Children.Find(group, "group")) 36 | { 37 | if (grp.Name != "") 38 | { 39 | grp.Invoke("Add", user.Path.ToString());//将用户添加到某组 40 | } 41 | } 42 | } 43 | } 44 | } 45 | /// 46 | /// 更改windows用户密码 47 | /// 48 | /// 用户名 49 | /// 新密码 50 | public static void UpdateUserPassword(string username, string newpassword) 51 | { 52 | using (DirectoryEntry dir = new DirectoryEntry(PATH)) 53 | { 54 | using (DirectoryEntry user = dir.Children.Find(username, "user")) 55 | { 56 | user.Invoke("SetPassword", new object[] { newpassword }); 57 | user.CommitChanges(); 58 | } 59 | } 60 | } 61 | /// 62 | /// 删除windows用户 63 | /// 64 | /// 用户名 65 | public static void RemoveUser(string username) 66 | { 67 | using (DirectoryEntry dir = new DirectoryEntry(PATH)) 68 | { 69 | using (DirectoryEntry user = dir.Children.Find(username, "User")) 70 | { 71 | dir.Children.Remove(user); 72 | } 73 | } 74 | } 75 | /// 76 | /// 添加windows用户组 77 | /// 78 | /// 组名称 79 | /// 描述 80 | public static void AddGroup(string groupName, string description) 81 | { 82 | using (DirectoryEntry dir = new DirectoryEntry(PATH)) 83 | { 84 | using (DirectoryEntry group = dir.Children.Add(groupName, "group")) 85 | { 86 | group.Invoke("Put", new object[] { "Description", description }); 87 | group.CommitChanges(); 88 | } 89 | } 90 | } 91 | /// 92 | /// 删除windows用户组 93 | /// 94 | /// 组名称 95 | public static void RemoveGroup(string groupName) 96 | { 97 | using (DirectoryEntry dir = new DirectoryEntry(PATH)) 98 | { 99 | using (DirectoryEntry group = dir.Children.Find(groupName, "Group")) 100 | { 101 | dir.Children.Remove(group); 102 | } 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCReName.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace 神龙辅助工具 2 | { 3 | partial class UCReName 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region 组件设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.btnSave = new System.Windows.Forms.Button(); 34 | this.txtAppName = new System.Windows.Forms.TextBox(); 35 | this.groupBox1.SuspendLayout(); 36 | this.SuspendLayout(); 37 | // 38 | // groupBox1 39 | // 40 | this.groupBox1.Controls.Add(this.label1); 41 | this.groupBox1.Controls.Add(this.btnSave); 42 | this.groupBox1.Controls.Add(this.txtAppName); 43 | this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 44 | this.groupBox1.Location = new System.Drawing.Point(13, 12); 45 | this.groupBox1.Name = "groupBox1"; 46 | this.groupBox1.Size = new System.Drawing.Size(411, 335); 47 | this.groupBox1.TabIndex = 4; 48 | this.groupBox1.TabStop = false; 49 | this.groupBox1.Text = "自定义程序名"; 50 | // 51 | // label1 52 | // 53 | this.label1.AutoSize = true; 54 | this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 55 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 56 | this.label1.Location = new System.Drawing.Point(53, 80); 57 | this.label1.Name = "label1"; 58 | this.label1.Size = new System.Drawing.Size(104, 19); 59 | this.label1.TabIndex = 0; 60 | this.label1.Text = "程序名称:"; 61 | // 62 | // btnSave 63 | // 64 | this.btnSave.BackColor = System.Drawing.Color.Green; 65 | this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 66 | this.btnSave.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 67 | this.btnSave.ForeColor = System.Drawing.Color.White; 68 | this.btnSave.Location = new System.Drawing.Point(161, 131); 69 | this.btnSave.Name = "btnSave"; 70 | this.btnSave.Size = new System.Drawing.Size(197, 35); 71 | this.btnSave.TabIndex = 2; 72 | this.btnSave.Text = "保存修改"; 73 | this.btnSave.UseVisualStyleBackColor = false; 74 | this.btnSave.Click += new System.EventHandler(this.btnSave_Click); 75 | // 76 | // txtAppName 77 | // 78 | this.txtAppName.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 79 | this.txtAppName.Location = new System.Drawing.Point(161, 77); 80 | this.txtAppName.Name = "txtAppName"; 81 | this.txtAppName.Size = new System.Drawing.Size(197, 29); 82 | this.txtAppName.TabIndex = 1; 83 | // 84 | // UCReName 85 | // 86 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 87 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 88 | this.Controls.Add(this.groupBox1); 89 | this.Name = "UCReName"; 90 | this.Size = new System.Drawing.Size(437, 362); 91 | this.groupBox1.ResumeLayout(false); 92 | this.groupBox1.PerformLayout(); 93 | this.ResumeLayout(false); 94 | 95 | } 96 | 97 | #endregion 98 | 99 | private System.Windows.Forms.GroupBox groupBox1; 100 | private System.Windows.Forms.Label label1; 101 | private System.Windows.Forms.Button btnSave; 102 | private System.Windows.Forms.TextBox txtAppName; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/KeyboardHookListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using MouseKeyboardActivityMonitor.WinApi; 4 | 5 | namespace MouseKeyboardActivityMonitor 6 | { 7 | /// 8 | /// This class monitors all keyboard activities and provides appropriate events. 9 | /// 10 | public class KeyboardHookListener : BaseHookListener 11 | { 12 | /// 13 | /// Initializes a new instance of . 14 | /// 15 | /// Depending on this parameter the listener hooks either application or global keyboard events. 16 | /// Hooks are not active after instantiation. You need to use either property or call method. 17 | public KeyboardHookListener(Hooker hooker) 18 | : base(hooker) 19 | { 20 | } 21 | 22 | /// 23 | /// This method processes the data from the hook and initiates event firing. 24 | /// 25 | /// The first Windows Messages parameter. 26 | /// The second Windows Messages parameter. 27 | /// 28 | /// True - The hook will be passed along to other applications. 29 | /// 30 | /// False - The hook will not be given to other applications, effectively blocking input. 31 | /// 32 | /// 33 | protected override bool ProcessCallback(int wParam, IntPtr lParam) 34 | { 35 | KeyEventArgsExt e = KeyEventArgsExt.FromRawData(wParam, lParam, IsGlobal); 36 | 37 | InvokeKeyDown(e); 38 | InvokeKeyPress(wParam, lParam); 39 | InvokeKeyUp(e); 40 | 41 | return !e.Handled; 42 | } 43 | 44 | /// 45 | /// Returns the correct hook id to be used for call. 46 | /// 47 | /// WH_KEYBOARD (0x02) or WH_KEYBOARD_LL (0x13) constant. 48 | protected override int GetHookId() 49 | { 50 | return IsGlobal ? 51 | GlobalHooker.WH_KEYBOARD_LL : 52 | AppHooker.WH_KEYBOARD; 53 | } 54 | 55 | /// 56 | /// Occurs when a key is preseed. 57 | /// 58 | public event KeyEventHandler KeyDown; 59 | 60 | private void InvokeKeyDown(KeyEventArgsExt e) 61 | { 62 | KeyEventHandler handler = KeyDown; 63 | if (handler == null || e.Handled || !e.IsKeyDown) { return; } 64 | handler(this, e); 65 | } 66 | 67 | /// 68 | /// Occurs when a key is pressed. 69 | /// 70 | /// 71 | /// Key events occur in the following order: 72 | /// 73 | /// KeyDown 74 | /// KeyPress 75 | /// KeyUp 76 | /// 77 | ///The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events. 78 | ///Use the KeyChar property to sample keystrokes at run time and to consume or modify a subset of common keystrokes. 79 | ///To handle keyboard events only in your application and not enable other applications to receive keyboard events, 80 | ///set the property in your form's KeyPress event-handling method to true. 81 | /// 82 | public event KeyPressEventHandler KeyPress; 83 | 84 | private void InvokeKeyPress(int wParam, IntPtr lParam) 85 | { 86 | InvokeKeyPress(KeyPressEventArgsExt.FromRawData(wParam, lParam, IsGlobal)); 87 | } 88 | 89 | private void InvokeKeyPress(KeyPressEventArgsExt e) 90 | { 91 | KeyPressEventHandler handler = KeyPress; 92 | if (handler == null || e.Handled || e.IsNonChar) { return; } 93 | handler(this, e); 94 | } 95 | 96 | /// 97 | /// Occurs when a key is released. 98 | /// 99 | public event KeyEventHandler KeyUp; 100 | 101 | private void InvokeKeyUp(KeyEventArgsExt e) 102 | { 103 | KeyEventHandler handler = KeyUp; 104 | if (handler == null || e.Handled || !e.IsKeyUp) { return; } 105 | handler(this, e); 106 | } 107 | 108 | /// 109 | /// Release delegates, unsubscribes from hooks. 110 | /// 111 | /// 2 112 | public override void Dispose() 113 | { 114 | KeyPress = null; 115 | KeyDown = null; 116 | KeyUp = null; 117 | 118 | base.Dispose(); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/KeyEventArgsExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows.Forms; 4 | using MouseKeyboardActivityMonitor.WinApi; 5 | 6 | namespace MouseKeyboardActivityMonitor 7 | { 8 | /// 9 | /// Provides extended argument data for the or event. 10 | /// 11 | public class KeyEventArgsExt : KeyEventArgs 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// 17 | public KeyEventArgsExt(Keys keyData) : base(keyData) 18 | { 19 | } 20 | 21 | internal KeyEventArgsExt(Keys keyData, int timestamp, bool isKeyDown, bool isKeyUp) 22 | : this(keyData) 23 | { 24 | Timestamp = timestamp; 25 | IsKeyDown = isKeyDown; 26 | IsKeyUp = isKeyUp; 27 | } 28 | 29 | /// 30 | /// Creates from Windows Message parameters. 31 | /// 32 | /// The first Windows Message parameter. 33 | /// The second Windows Message parameter. 34 | /// Specifies if the hook is local or global. 35 | /// A new KeyEventArgsExt object. 36 | internal static KeyEventArgsExt FromRawData(int wParam, IntPtr lParam, bool isGlobal) 37 | { 38 | return isGlobal ? 39 | FromRawDataGlobal(wParam, lParam) : 40 | FromRawDataApp(wParam, lParam); 41 | } 42 | 43 | /// 44 | /// Creates from Windows Message parameters, based upon 45 | /// a local application hook. 46 | /// 47 | /// The first Windows Message parameter. 48 | /// The second Windows Message parameter. 49 | /// A new KeyEventArgsExt object. 50 | private static KeyEventArgsExt FromRawDataApp(int wParam, IntPtr lParam) 51 | { 52 | //http://msdn.microsoft.com/en-us/library/ms644984(v=VS.85).aspx 53 | 54 | const uint maskKeydown = 0x40000000; // for bit 30 55 | const uint maskKeyup = 0x80000000; // for bit 31 56 | 57 | int timestamp = Environment.TickCount; 58 | 59 | uint flags = 0u; 60 | #if IS_X64 61 | // both of these are ugly hacks. Is there a better way to convert a 64bit IntPtr to uint? 62 | 63 | // flags = uint.Parse(lParam.ToString()); 64 | flags = Convert.ToUInt32(lParam.ToInt64()); 65 | #else 66 | flags = (uint)lParam; 67 | #endif 68 | 69 | 70 | //bit 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up. 71 | bool wasKeyDown = (flags & maskKeydown) > 0; 72 | //bit 31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released. 73 | bool isKeyReleased = (flags & maskKeyup) > 0; 74 | 75 | Keys keyData = (Keys)wParam; 76 | 77 | bool isKeyDown = !wasKeyDown && !isKeyReleased; 78 | bool isKeyUp = wasKeyDown && isKeyReleased; 79 | 80 | return new KeyEventArgsExt(keyData, timestamp, isKeyDown, isKeyUp); 81 | } 82 | 83 | /// 84 | /// Creates from Windows Message parameters, based upon 85 | /// a system-wide hook. 86 | /// 87 | /// The first Windows Message parameter. 88 | /// The second Windows Message parameter. 89 | /// A new KeyEventArgsExt object. 90 | private static KeyEventArgsExt FromRawDataGlobal(int wParam, IntPtr lParam) 91 | { 92 | KeyboardHookStruct keyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); 93 | Keys keyData = (Keys)keyboardHookStruct.VirtualKeyCode; 94 | bool isKeyDown = (wParam == Messages.WM_KEYDOWN || wParam == Messages.WM_SYSKEYDOWN); 95 | bool isKeyUp = (wParam == Messages.WM_KEYUP || wParam == Messages.WM_SYSKEYUP); 96 | 97 | return new KeyEventArgsExt(keyData, keyboardHookStruct.Time, isKeyDown, isKeyUp); 98 | } 99 | 100 | /// 101 | /// The system tick count of when the event occured. 102 | /// 103 | public int Timestamp { get; private set; } 104 | 105 | /// 106 | /// True if event singnals key down.. 107 | /// 108 | public bool IsKeyDown { get; private set; } 109 | 110 | /// 111 | /// True if event singnals key up. 112 | /// 113 | public bool IsKeyUp { get; private set; } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/Messages.cs: -------------------------------------------------------------------------------- 1 | namespace MouseKeyboardActivityMonitor.WinApi 2 | { 3 | internal static class Messages 4 | { 5 | //values from Winuser.h in Microsoft SDK. 6 | 7 | /// 8 | /// The WM_MOUSEMOVE message is posted to a window when the cursor moves. 9 | /// 10 | public const int WM_MOUSEMOVE = 0x200; 11 | 12 | /// 13 | /// The WM_LBUTTONDOWN message is posted when the user presses the left mouse button 14 | /// 15 | public const int WM_LBUTTONDOWN = 0x201; 16 | 17 | /// 18 | /// The WM_RBUTTONDOWN message is posted when the user presses the right mouse button 19 | /// 20 | public const int WM_RBUTTONDOWN = 0x204; 21 | 22 | /// 23 | /// The WM_MBUTTONDOWN message is posted when the user presses the middle mouse button 24 | /// 25 | public const int WM_MBUTTONDOWN = 0x207; 26 | 27 | /// 28 | /// The WM_LBUTTONUP message is posted when the user releases the left mouse button 29 | /// 30 | public const int WM_LBUTTONUP = 0x202; 31 | 32 | /// 33 | /// The WM_RBUTTONUP message is posted when the user releases the right mouse button 34 | /// 35 | public const int WM_RBUTTONUP = 0x205; 36 | 37 | /// 38 | /// The WM_MBUTTONUP message is posted when the user releases the middle mouse button 39 | /// 40 | public const int WM_MBUTTONUP = 0x208; 41 | 42 | /// 43 | /// The WM_LBUTTONDBLCLK message is posted when the user double-clicks the left mouse button 44 | /// 45 | public const int WM_LBUTTONDBLCLK = 0x203; 46 | 47 | /// 48 | /// The WM_RBUTTONDBLCLK message is posted when the user double-clicks the right mouse button 49 | /// 50 | public const int WM_RBUTTONDBLCLK = 0x206; 51 | 52 | /// 53 | /// The WM_RBUTTONDOWN message is posted when the user presses the right mouse button 54 | /// 55 | public const int WM_MBUTTONDBLCLK = 0x209; 56 | 57 | /// 58 | /// The WM_MOUSEWHEEL message is posted when the user presses the mouse wheel. 59 | /// 60 | public const int WM_MOUSEWHEEL = 0x020A; 61 | 62 | /// 63 | /// The WM_XBUTTONDOWN message is posted when the user presses the first or second X mouse 64 | /// button. 65 | /// 66 | public const int WM_XBUTTONDOWN = 0x20B; 67 | 68 | /// 69 | /// The WM_XBUTTONUP message is posted when the user releases the first or second X mouse 70 | /// button. 71 | /// 72 | public const int WM_XBUTTONUP = 0x20C; 73 | 74 | /// 75 | /// The WM_XBUTTONDBLCLK message is posted when the user double-clicks the first or second 76 | /// X mouse button. 77 | /// 78 | /// Only windows that have the CS_DBLCLKS style can receive WM_XBUTTONDBLCLK messages. 79 | public const int WM_XBUTTONDBLCLK = 0x20D; 80 | 81 | /// 82 | /// The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem 83 | /// key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed. 84 | /// 85 | public const int WM_KEYDOWN = 0x100; 86 | 87 | /// 88 | /// The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem 89 | /// key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, 90 | /// or a keyboard key that is pressed when a window has the keyboard focus. 91 | /// 92 | public const int WM_KEYUP = 0x101; 93 | 94 | /// 95 | /// The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user 96 | /// presses the F10 key (which activates the menu bar) or holds down the ALT key and then 97 | /// presses another key. It also occurs when no window currently has the keyboard focus; 98 | /// in this case, the WM_SYSKEYDOWN message is sent to the active window. The window that 99 | /// receives the message can distinguish between these two contexts by checking the context 100 | /// code in the lParam parameter. 101 | /// 102 | public const int WM_SYSKEYDOWN = 0x104; 103 | 104 | /// 105 | /// The WM_SYSKEYUP message is posted to the window with the keyboard focus when the user 106 | /// releases a key that was pressed while the ALT key was held down. It also occurs when no 107 | /// window currently has the keyboard focus; in this case, the WM_SYSKEYUP message is sent 108 | /// to the active window. The window that receives the message can distinguish between 109 | /// these two contexts by checking the context code in the lParam parameter. 110 | /// 111 | public const int WM_SYSKEYUP = 0x105; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/HttpUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Net; 6 | using System.IO; 7 | using System.Reflection; 8 | using System.Collections.Specialized; 9 | 10 | namespace 神龙辅助工具 11 | { 12 | class HttpUtils 13 | { 14 | /// 15 | /// 指定Post地址使用Get 方式获取全部字符串 16 | /// 17 | /// 请求后台地址 18 | /// 19 | public string Post(string url, Dictionary dic) 20 | { 21 | string result = ""; 22 | HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); 23 | req.Method = "POST"; 24 | req.ContentType = "application/x-www-form-urlencoded"; 25 | #region 添加Post参数 26 | StringBuilder builder = new StringBuilder(); 27 | int i = 0; 28 | foreach (var item in dic) 29 | { 30 | if (i > 0) 31 | builder.Append("&"); 32 | builder.AppendFormat("{0}={1}", item.Key, item.Value); 33 | i++; 34 | } 35 | byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); 36 | req.ContentLength = data.Length; 37 | using (Stream reqStream = req.GetRequestStream()) 38 | { 39 | reqStream.Write(data, 0, data.Length); 40 | reqStream.Close(); 41 | } 42 | #endregion 43 | HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); 44 | Stream stream = resp.GetResponseStream(); 45 | //获取响应内容 46 | using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) 47 | { 48 | result = reader.ReadToEnd(); 49 | } 50 | return result; 51 | } 52 | /// 53 | /// 发送Get请求 54 | /// 55 | /// 地址 56 | /// 请求参数定义 57 | /// 58 | public string Get(string url, Dictionary dic) 59 | { 60 | string result = ""; 61 | StringBuilder builder = new StringBuilder(); 62 | builder.Append(url); 63 | if (dic.Count > 0) 64 | { 65 | builder.Append("?"); 66 | int i = 0; 67 | foreach (var item in dic) 68 | { 69 | if (i > 0) 70 | builder.Append("&"); 71 | builder.AppendFormat("{0}={1}", item.Key, item.Value); 72 | i++; 73 | } 74 | } 75 | HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString()); 76 | //添加参数 77 | HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); 78 | Stream stream = resp.GetResponseStream(); 79 | try 80 | { 81 | //获取内容 82 | using (StreamReader reader = new StreamReader(stream)) 83 | { 84 | result = reader.ReadToEnd(); 85 | } 86 | } 87 | finally 88 | { 89 | stream.Close(); 90 | } 91 | return result; 92 | } 93 | /// 94 | /// 带请求头的Get请求 95 | /// 96 | /// 97 | /// 98 | public string send(string url, string method = "GET") 99 | { 100 | HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(url); 101 | rq.Method = method; 102 | SetHeaderValue(rq.Headers, "Host", "www.taojinke.cn"); 103 | SetHeaderValue(rq.Headers, "Connection", "keep-alive"); 104 | SetHeaderValue(rq.Headers, "Accept", "application/json, text/javascript, */*; q=0.01"); 105 | SetHeaderValue(rq.Headers, "X-Requested-With", "XMLHttpRequest"); 106 | SetHeaderValue(rq.Headers, "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.901.400 QQBrowser/9.0.2524.400"); 107 | SetHeaderValue(rq.Headers, "Referer", url); 108 | SetHeaderValue(rq.Headers, "Accept-Encoding", "gzip, deflate"); 109 | SetHeaderValue(rq.Headers, "Accept-Language", " zh-CN,zh;q=0.8,en-us;q=0.6,en;q=0.5;q=0.4"); 110 | //SetHeaderValue(rq.Headers, "Cookie", "This is Cookie"); 111 | 112 | HttpWebResponse resp = (HttpWebResponse)rq.GetResponse(); 113 | 114 | string result = ""; 115 | using (Stream stream = resp.GetResponseStream()) 116 | { 117 | StreamReader reader = new StreamReader(stream, Encoding.UTF8); 118 | result = reader.ReadToEnd(); 119 | } 120 | 121 | return result; 122 | } 123 | 124 | //设置http请求头的值 125 | public void SetHeaderValue(WebHeaderCollection header, string name, string value) 126 | { 127 | var property = typeof(WebHeaderCollection).GetProperty("InnerCollection", BindingFlags.Instance | BindingFlags.NonPublic); 128 | if (property != null) 129 | { 130 | var collection = property.GetValue(header, null) as NameValueCollection; 131 | collection[name] = value; 132 | } 133 | } 134 | 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/KeyPressEventArgsExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows.Forms; 4 | using MouseKeyboardActivityMonitor.WinApi; 5 | 6 | namespace MouseKeyboardActivityMonitor 7 | { 8 | /// 9 | /// Provides extended data for the event. 10 | /// 11 | public class KeyPressEventArgsExt : KeyPressEventArgs 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// Character corresponding to the key pressed. 0 char if represens a system or functional non char key. 17 | public KeyPressEventArgsExt(char keyChar) 18 | : base(keyChar) 19 | { 20 | IsNonChar = false; 21 | Timestamp = Environment.TickCount; 22 | } 23 | 24 | private static KeyPressEventArgsExt CreateNonChar() 25 | { 26 | KeyPressEventArgsExt e = new KeyPressEventArgsExt((char)0x0); 27 | e.IsNonChar = true; 28 | e.Timestamp = Environment.TickCount; 29 | return e; 30 | } 31 | 32 | /// 33 | /// Creates from Windows Message parameters. 34 | /// 35 | /// The first Windows Message parameter. 36 | /// The second Windows Message parameter. 37 | /// Specifies if the hook is local or global. 38 | /// A new KeyPressEventArgsExt object. 39 | internal static KeyPressEventArgsExt FromRawData(int wParam, IntPtr lParam, bool isGlobal) 40 | { 41 | return isGlobal ? 42 | FromRawDataGlobal(wParam, lParam) : 43 | FromRawDataApp(wParam, lParam); 44 | } 45 | 46 | /// 47 | /// Creates from Windows Message parameters, 48 | /// based upon a local application hook. 49 | /// 50 | /// The first Windows Message parameter. 51 | /// The second Windows Message parameter. 52 | /// A new KeyPressEventArgsExt object. 53 | private static KeyPressEventArgsExt FromRawDataApp(int wParam, IntPtr lParam) 54 | { 55 | //http://msdn.microsoft.com/en-us/library/ms644984(v=VS.85).aspx 56 | 57 | const uint maskKeydown = 0x40000000; // for bit 30 58 | const uint maskKeyup = 0x80000000; // for bit 31 59 | const uint maskScanCode = 0xff0000; // for bit 23-16 60 | 61 | uint flags = 0u; 62 | #if IS_X64 63 | // both of these are ugly hacks. Is there a better way to convert a 64bit IntPtr to uint? 64 | 65 | // flags = uint.Parse(lParam.ToString()); 66 | flags = Convert.ToUInt32(lParam.ToInt64()); 67 | #else 68 | flags = (uint)lParam; 69 | #endif 70 | 71 | //bit 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up. 72 | bool wasKeyDown = (flags & maskKeydown) > 0; 73 | //bit 31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released. 74 | bool isKeyReleased = (flags & maskKeyup) > 0; 75 | 76 | if (!wasKeyDown && !isKeyReleased) 77 | { 78 | return CreateNonChar(); 79 | } 80 | 81 | int virtualKeyCode = wParam; 82 | int scanCode = checked((int)(flags & maskScanCode)); 83 | const int fuState = 0; 84 | 85 | char ch; 86 | bool isSuccessfull = Keyboard.TryGetCharFromKeyboardState(virtualKeyCode, scanCode, fuState, out ch); 87 | if (!isSuccessfull) 88 | { 89 | return CreateNonChar(); 90 | } 91 | 92 | return new KeyPressEventArgsExt(ch); 93 | 94 | } 95 | 96 | /// 97 | /// Creates from Windows Message parameters, 98 | /// based upon a system-wide hook. 99 | /// 100 | /// The first Windows Message parameter. 101 | /// The second Windows Message parameter. 102 | /// A new KeyPressEventArgsExt object. 103 | internal static KeyPressEventArgsExt FromRawDataGlobal(int wParam, IntPtr lParam) 104 | { 105 | if (wParam != Messages.WM_KEYDOWN) 106 | { 107 | return CreateNonChar(); 108 | } 109 | 110 | KeyboardHookStruct keyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); 111 | 112 | int virtualKeyCode = keyboardHookStruct.VirtualKeyCode; 113 | int scanCode = keyboardHookStruct.ScanCode; 114 | int fuState = keyboardHookStruct.Flags; 115 | 116 | char ch; 117 | bool isSuccessfull = Keyboard.TryGetCharFromKeyboardState(virtualKeyCode, scanCode, fuState, out ch); 118 | if (!isSuccessfull) 119 | { 120 | return CreateNonChar(); 121 | } 122 | 123 | KeyPressEventArgsExt e = new KeyPressEventArgsExt(ch); 124 | e.Timestamp = keyboardHookStruct.Time; // Update the timestamp to use the actual one from KeyboardHookStruct 125 | 126 | return e; 127 | } 128 | 129 | /// 130 | /// True if represents a system or functional non char key. 131 | /// 132 | public bool IsNonChar { get; private set; } 133 | 134 | /// 135 | /// The system tick count of when the event occured. 136 | /// 137 | public int Timestamp { get; private set; } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCMain.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCReName.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCWindowAccount.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /神龙辅助工具/Tools/IniHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.IO; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Collections; 7 | 8 | namespace 神龙辅助工具 9 | { 10 | /// 11 | /// Ini配置文件辅助类 12 | /// 13 | class IniHelper 14 | { 15 | public string FileName; 16 | 17 | public IniHelper(string AFileName) 18 | { 19 | FileInfo info = new FileInfo(AFileName); 20 | if (!info.Exists) 21 | { 22 | //Ini文件不存在,就创建一个 23 | string msg = @"[Setting] 24 | RecordHotKey=F5 25 | PlayHotKey=F6 26 | StopHotKey=F7 27 | Speed=500 28 | IsUseKey=true 29 | Keyboard=D2 30 | DelayTime=60"; 31 | byte[] bytes = System.Text.Encoding.UTF8.GetBytes(msg); 32 | FileStream fs = new FileStream(Environment.CurrentDirectory + @"\" + AFileName, FileMode.Create); 33 | fs.Write(bytes, 0, bytes.Length); 34 | fs.Close(); 35 | } 36 | this.FileName = info.FullName; 37 | } 38 | 39 | public void DeleteKey(string Section, string Ident) 40 | { 41 | WritePrivateProfileString(Section, Ident, null, this.FileName); 42 | } 43 | 44 | public void EraseSection(string Section) 45 | { 46 | if (!WritePrivateProfileString(Section, null, null, this.FileName)) 47 | { 48 | throw new ApplicationException("无法清除Ini文件中的Section"); 49 | } 50 | } 51 | 52 | ~IniHelper() 53 | { 54 | this.UpdateFile(); 55 | } 56 | 57 | [DllImport("kernel32")] 58 | private static extern int GetPrivateProfileString(string section, string key, string def, byte[] retVal, int size, string filePath); 59 | private void GetStringsFromBuffer(byte[] Buffer, int bufLen, StringCollection Strings) 60 | { 61 | Strings.Clear(); 62 | if (bufLen != 0) 63 | { 64 | int index = 0; 65 | for (int i = 0; i < bufLen; i++) 66 | { 67 | if ((Buffer[i] == 0) && ((i - index) > 0)) 68 | { 69 | string str = Encoding.GetEncoding(0).GetString(Buffer, index, i - index); 70 | Strings.Add(str); 71 | index = i + 1; 72 | } 73 | } 74 | } 75 | } 76 | 77 | public bool ReadBool(string Section, string Ident, bool Default) 78 | { 79 | try 80 | { 81 | return Convert.ToBoolean(this.ReadString(Section, Ident, Convert.ToString(Default))); 82 | } 83 | catch (Exception exception) 84 | { 85 | Console.WriteLine(exception.Message); 86 | return Default; 87 | } 88 | } 89 | 90 | public int ReadInteger(string Section, string Ident, int Default) 91 | { 92 | string str = this.ReadString(Section, Ident, Convert.ToString(Default)); 93 | try 94 | { 95 | return Convert.ToInt32(str); 96 | } 97 | catch (Exception exception) 98 | { 99 | Console.WriteLine(exception.Message); 100 | return Default; 101 | } 102 | } 103 | 104 | public void ReadSection(string Section, StringCollection Idents) 105 | { 106 | byte[] retVal = new byte[0x4000]; 107 | int bufLen = GetPrivateProfileString(Section, null, null, retVal, retVal.GetUpperBound(0), this.FileName); 108 | this.GetStringsFromBuffer(retVal, bufLen, Idents); 109 | } 110 | 111 | public void ReadSections(StringCollection SectionList) 112 | { 113 | byte[] retVal = new byte[0xffff]; 114 | int bufLen = 0; 115 | bufLen = GetPrivateProfileString(null, null, null, retVal, retVal.GetUpperBound(0), this.FileName); 116 | this.GetStringsFromBuffer(retVal, bufLen, SectionList); 117 | } 118 | 119 | public void ReadSectionValues(string Section, ArrayList Values) 120 | { 121 | StringCollection idents = new StringCollection(); 122 | this.ReadSection(Section, idents); 123 | Values.Clear(); 124 | foreach (string str in idents) 125 | { 126 | string value = this.ReadString(Section, str, ""); 127 | Values.Add(value); 128 | } 129 | } 130 | public string ReadString(string Section, string Ident, string Default) 131 | { 132 | byte[] retVal = new byte[0xffff]; 133 | int length = GetPrivateProfileString(Section, Ident, Default, retVal, retVal.GetUpperBound(0), this.FileName); 134 | return Encoding.GetEncoding(0).GetString(retVal).Substring(0, length).Trim(); 135 | } 136 | 137 | public void UpdateFile() 138 | { 139 | WritePrivateProfileString(null, null, null, this.FileName); 140 | } 141 | 142 | public bool ValueExists(string Section, string Ident) 143 | { 144 | StringCollection idents = new StringCollection(); 145 | this.ReadSection(Section, idents); 146 | return (idents.IndexOf(Ident) > -1); 147 | } 148 | 149 | public void WriteBool(string Section, string Ident, bool Value) 150 | { 151 | this.WriteString(Section, Ident, Convert.ToString(Value)); 152 | } 153 | 154 | public void WriteInteger(string Section, string Ident, int Value) 155 | { 156 | this.WriteString(Section, Ident, Value.ToString()); 157 | } 158 | 159 | [DllImport("kernel32")] 160 | private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath); 161 | public void WriteString(string Section, string Ident, string Value) 162 | { 163 | if (!WritePrivateProfileString(Section, Ident, Value, this.FileName)) 164 | { 165 | throw new ApplicationException("写入Ini文件出错"); 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/Hooker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace MouseKeyboardActivityMonitor.WinApi 6 | { 7 | /// 8 | /// Provides base implementation of methods for subscription and unsubscription to application and/or global mouse and keyboard hooks. 9 | /// 10 | public abstract class Hooker 11 | { 12 | internal abstract int Subscribe(int hookId, HookCallback hookCallback); 13 | 14 | internal void Unsubscribe(int handle) 15 | { 16 | int result = UnhookWindowsHookEx(handle); 17 | 18 | if (result == 0) 19 | { 20 | ThrowLastUnmanagedErrorAsException(); 21 | } 22 | } 23 | 24 | internal abstract bool IsGlobal { get; } 25 | 26 | /// 27 | /// The CallNextHookEx function passes the hook information to the next hook procedure in the current hook chain. 28 | /// A hook procedure can call this function either before or after processing the hook information. 29 | /// 30 | /// Ignored. 31 | /// [in] Specifies the hook code passed to the current hook procedure. 32 | /// [in] Specifies the wParam value passed to the current hook procedure. 33 | /// [in] Specifies the lParam value passed to the current hook procedure. 34 | /// This value is returned by the next hook procedure in the chain. 35 | /// 36 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp 37 | /// 38 | [DllImport("user32.dll", CharSet = CharSet.Auto, 39 | CallingConvention = CallingConvention.StdCall)] 40 | internal static extern int CallNextHookEx( 41 | int idHook, 42 | int nCode, 43 | int wParam, 44 | IntPtr lParam); 45 | 46 | /// 47 | /// The SetWindowsHookEx function installs an application-defined hook procedure into a hook chain. 48 | /// You would install a hook procedure to monitor the system for certain types of events. These events 49 | /// are associated either with a specific thread or with all threads in the same desktop as the calling thread. 50 | /// 51 | /// 52 | /// [in] Specifies the type of hook procedure to be installed. This parameter can be one of the following values. 53 | /// 54 | /// 55 | /// [in] Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a 56 | /// thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link 57 | /// library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process. 58 | /// 59 | /// 60 | /// [in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. 61 | /// The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by 62 | /// the current process and if the hook procedure is within the code associated with the current process. 63 | /// 64 | /// 65 | /// [in] Specifies the identifier of the thread with which the hook procedure is to be associated. 66 | /// If this parameter is zero, the hook procedure is associated with all existing threads running in the 67 | /// same desktop as the calling thread. 68 | /// 69 | /// 70 | /// If the function succeeds, the return value is the handle to the hook procedure. 71 | /// If the function fails, the return value is NULL. To get extended error information, call GetLastError. 72 | /// 73 | /// 74 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp 75 | /// 76 | [DllImport("user32.dll", CharSet = CharSet.Auto, 77 | CallingConvention = CallingConvention.StdCall, SetLastError = true)] 78 | internal static extern int SetWindowsHookEx( 79 | int idHook, 80 | HookCallback lpfn, 81 | IntPtr hMod, 82 | int dwThreadId); 83 | 84 | /// 85 | /// The UnhookWindowsHookEx function removes a hook procedure installed in a hook chain by the SetWindowsHookEx function. 86 | /// 87 | /// 88 | /// [in] Handle to the hook to be removed. This parameter is a hook handle obtained by a previous call to SetWindowsHookEx. 89 | /// 90 | /// 91 | /// If the function succeeds, the return value is nonzero. 92 | /// If the function fails, the return value is zero. To get extended error information, call GetLastError. 93 | /// 94 | /// 95 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp 96 | /// 97 | [DllImport("user32.dll", CharSet = CharSet.Auto, 98 | CallingConvention = CallingConvention.StdCall, SetLastError = true)] 99 | internal static extern int UnhookWindowsHookEx(int idHook); 100 | 101 | internal static void ThrowLastUnmanagedErrorAsException() 102 | { 103 | //Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set. 104 | int errorCode = Marshal.GetLastWin32Error(); 105 | //Initializes and throws a new instance of the Win32Exception class with the specified error. 106 | throw new Win32Exception(errorCode); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCWindowAccount.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace 神龙辅助工具 2 | { 3 | partial class UCWindowAccount 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region 组件设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 32 | this.btnCreate = new System.Windows.Forms.Button(); 33 | this.textPassword = new System.Windows.Forms.TextBox(); 34 | this.textUserName = new System.Windows.Forms.TextBox(); 35 | this.label2 = new System.Windows.Forms.Label(); 36 | this.label1 = new System.Windows.Forms.Label(); 37 | this.groupBox1.SuspendLayout(); 38 | this.SuspendLayout(); 39 | // 40 | // groupBox1 41 | // 42 | this.groupBox1.Controls.Add(this.btnCreate); 43 | this.groupBox1.Controls.Add(this.textPassword); 44 | this.groupBox1.Controls.Add(this.textUserName); 45 | this.groupBox1.Controls.Add(this.label2); 46 | this.groupBox1.Controls.Add(this.label1); 47 | this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 48 | this.groupBox1.Location = new System.Drawing.Point(13, 12); 49 | this.groupBox1.Name = "groupBox1"; 50 | this.groupBox1.Size = new System.Drawing.Size(411, 335); 51 | this.groupBox1.TabIndex = 0; 52 | this.groupBox1.TabStop = false; 53 | this.groupBox1.Text = "创建计算机用户"; 54 | // 55 | // btnCreate 56 | // 57 | this.btnCreate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0))))); 58 | this.btnCreate.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 59 | this.btnCreate.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 60 | this.btnCreate.ForeColor = System.Drawing.Color.White; 61 | this.btnCreate.Location = new System.Drawing.Point(146, 155); 62 | this.btnCreate.Name = "btnCreate"; 63 | this.btnCreate.Size = new System.Drawing.Size(197, 35); 64 | this.btnCreate.TabIndex = 2; 65 | this.btnCreate.Text = "创建用户"; 66 | this.btnCreate.UseVisualStyleBackColor = false; 67 | this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); 68 | // 69 | // textPassword 70 | // 71 | this.textPassword.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 72 | this.textPassword.Location = new System.Drawing.Point(146, 111); 73 | this.textPassword.Name = "textPassword"; 74 | this.textPassword.Size = new System.Drawing.Size(197, 29); 75 | this.textPassword.TabIndex = 1; 76 | // 77 | // textUserName 78 | // 79 | this.textUserName.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 80 | this.textUserName.Location = new System.Drawing.Point(146, 60); 81 | this.textUserName.Name = "textUserName"; 82 | this.textUserName.Size = new System.Drawing.Size(197, 29); 83 | this.textUserName.TabIndex = 1; 84 | // 85 | // label2 86 | // 87 | this.label2.AutoSize = true; 88 | this.label2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 89 | this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 90 | this.label2.Location = new System.Drawing.Point(68, 114); 91 | this.label2.Name = "label2"; 92 | this.label2.Size = new System.Drawing.Size(77, 19); 93 | this.label2.TabIndex = 0; 94 | this.label2.Text = "密 码:"; 95 | // 96 | // label1 97 | // 98 | this.label1.AutoSize = true; 99 | this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 100 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 101 | this.label1.Location = new System.Drawing.Point(68, 66); 102 | this.label1.Name = "label1"; 103 | this.label1.Size = new System.Drawing.Size(76, 19); 104 | this.label1.TabIndex = 0; 105 | this.label1.Text = "用户名:"; 106 | // 107 | // UCWindowAccount 108 | // 109 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 110 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 111 | this.Controls.Add(this.groupBox1); 112 | this.Name = "UCWindowAccount"; 113 | this.Size = new System.Drawing.Size(437, 362); 114 | this.groupBox1.ResumeLayout(false); 115 | this.groupBox1.PerformLayout(); 116 | this.ResumeLayout(false); 117 | 118 | } 119 | 120 | #endregion 121 | 122 | private System.Windows.Forms.GroupBox groupBox1; 123 | private System.Windows.Forms.Label label2; 124 | private System.Windows.Forms.Label label1; 125 | private System.Windows.Forms.TextBox textPassword; 126 | private System.Windows.Forms.TextBox textUserName; 127 | private System.Windows.Forms.Button btnCreate; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /神龙辅助工具/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\Newtonsoft.Json.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 123 | 124 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/WinApi/Keyboard.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace MouseKeyboardActivityMonitor.WinApi 5 | { 6 | internal static class Keyboard 7 | { 8 | //values from Winuser.h in Microsoft SDK. 9 | public const byte VK_SHIFT = 0x10; 10 | public const byte VK_CAPITAL = 0x14; 11 | public const byte VK_NUMLOCK = 0x90; 12 | 13 | internal static bool TryGetCharFromKeyboardState(int virtualKeyCode, int scanCode, int fuState, out char ch) 14 | { 15 | bool isDownShift = ((GetKeyState(VK_SHIFT) & 0x80) == 0x80 ? true : false); 16 | bool isDownCapslock = (GetKeyState(VK_CAPITAL) != 0 ? true : false); 17 | 18 | byte[] keyState = new byte[256]; 19 | GetKeyboardState(keyState); 20 | byte[] inBuffer = new byte[2]; 21 | 22 | bool isSuccesfullyConverted = ToAscii(virtualKeyCode, 23 | scanCode, 24 | keyState, 25 | inBuffer, 26 | fuState) == 1; 27 | if (!isSuccesfullyConverted) 28 | { 29 | ch = (char)0; 30 | return false; 31 | } 32 | 33 | ch = (char)inBuffer[0]; 34 | if ((isDownCapslock ^ isDownShift) && Char.IsLetter(ch)) 35 | { 36 | ch = Char.ToUpper(ch); 37 | } 38 | return true; 39 | } 40 | 41 | 42 | /// 43 | /// The ToAscii function translates the specified virtual-key code and keyboard 44 | /// state to the corresponding character or characters. The function translates the code 45 | /// using the input language and physical keyboard layout identified by the keyboard layout handle. 46 | /// 47 | /// 48 | /// [in] Specifies the virtual-key code to be translated. 49 | /// 50 | /// 51 | /// [in] Specifies the hardware scan code of the key to be translated. 52 | /// The high-order bit of this value is set if the key is up (not pressed). 53 | /// 54 | /// 55 | /// [in] Pointer to a 256-byte array that contains the current keyboard state. 56 | /// Each element (byte) in the array contains the state of one key. 57 | /// If the high-order bit of a byte is set, the key is down (pressed). 58 | /// The low bit, if set, indicates that the key is toggled on. In this function, 59 | /// only the toggle bit of the CAPS LOCK key is relevant. The toggle state 60 | /// of the NUM LOCK and SCROLL LOCK keys is ignored. 61 | /// 62 | /// 63 | /// [out] Pointer to the buffer that receives the translated character or characters. 64 | /// 65 | /// 66 | /// [in] Specifies whether a menu is active. This parameter must be 1 if a menu is active, or 0 otherwise. 67 | /// 68 | /// 69 | /// If the specified key is a dead key, the return value is negative. Otherwise, it is one of the following values. 70 | /// Value Meaning 71 | /// 0 The specified virtual key has no translation for the current state of the keyboard. 72 | /// 1 One character was copied to the buffer. 73 | /// 2 Two characters were copied to the buffer. This usually happens when a dead-key character 74 | /// (accent or diacritic) stored in the keyboard layout cannot be composed with the specified 75 | /// virtual key to form a single character. 76 | /// 77 | /// 78 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp 79 | /// 80 | [DllImport("user32")] 81 | public static extern int ToAscii( 82 | int uVirtKey, 83 | int uScanCode, 84 | byte[] lpbKeyState, 85 | byte[] lpwTransKey, 86 | int fuState); 87 | 88 | /// 89 | /// The GetKeyboardState function copies the status of the 256 virtual keys to the 90 | /// specified buffer. 91 | /// 92 | /// 93 | /// [in] Pointer to a 256-byte array that contains keyboard key states. 94 | /// 95 | /// 96 | /// If the function succeeds, the return value is nonzero. 97 | /// If the function fails, the return value is zero. To get extended error information, call GetLastError. 98 | /// 99 | /// 100 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp 101 | /// 102 | [DllImport("user32")] 103 | public static extern int GetKeyboardState(byte[] pbKeyState); 104 | 105 | /// 106 | /// The GetKeyState function retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled 107 | /// (on, off—alternating each time the key is pressed). 108 | /// 109 | /// 110 | /// [in] Specifies a virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be a virtual-key code. 111 | /// 112 | /// 113 | /// The return value specifies the status of the specified virtual key, as follows: 114 | ///If the high-order bit is 1, the key is down; otherwise, it is up. 115 | ///If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled. 116 | /// 117 | /// http://msdn.microsoft.com/en-us/library/ms646301.aspx 118 | [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 119 | public static extern short GetKeyState(int vKey); 120 | } 121 | } -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/BaseHookListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MouseKeyboardActivityMonitor.WinApi; 3 | 4 | namespace MouseKeyboardActivityMonitor 5 | { 6 | /// 7 | /// Base class used to implement mouse or keybord hook listeners. 8 | /// It provides base methods to subscribe and unsubscribe to hooks. 9 | /// Common processing, error handling and cleanup logic. 10 | /// 11 | public abstract class BaseHookListener : IDisposable 12 | { 13 | private Hooker m_Hooker; 14 | 15 | /// 16 | /// Base constructor of 17 | /// 18 | /// Depending on this parameter the listener hooks either application or global keyboard events. 19 | /// 20 | /// Hooks are not active after instantiation. You need to use either property or call method. 21 | /// 22 | protected BaseHookListener(Hooker hooker) 23 | { 24 | if (hooker == null) 25 | { 26 | throw new ArgumentNullException("hooker"); 27 | } 28 | m_Hooker = hooker; 29 | } 30 | 31 | /// 32 | /// Stores the handle to the Keyboard or Mouse hook procedure. 33 | /// 34 | protected int HookHandle { get; set; } 35 | 36 | /// 37 | /// Keeps the reference to prevent garbage collection of delegate. See: CallbackOnCollectedDelegate http://msdn.microsoft.com/en-us/library/43yky316(v=VS.100).aspx 38 | /// 39 | protected HookCallback HookCallbackReferenceKeeper { get; set; } 40 | 41 | internal bool IsGlobal 42 | { 43 | get 44 | { 45 | return m_Hooker.IsGlobal; 46 | } 47 | } 48 | 49 | /// 50 | /// Override this method to modify logic of firing events. 51 | /// 52 | protected abstract bool ProcessCallback(int wParam, IntPtr lParam); 53 | 54 | /// 55 | /// A callback function which will be called every time a keyboard or mouse activity detected. 56 | /// 57 | /// 58 | protected int HookCallback(int nCode, Int32 wParam, IntPtr lParam) 59 | { 60 | if (nCode == 0) 61 | { 62 | bool shouldProcess = ProcessCallback(wParam, lParam); 63 | 64 | if (!shouldProcess) 65 | { 66 | return -1; 67 | } 68 | } 69 | 70 | return CallNextHook(nCode, wParam, lParam); 71 | } 72 | 73 | private int CallNextHook(int nCode, int wParam, IntPtr lParam) 74 | { 75 | return Hooker.CallNextHookEx(HookHandle, nCode, wParam, lParam); 76 | } 77 | 78 | /// 79 | /// Subscribes to the hook and starts firing events. 80 | /// 81 | /// 82 | public void Start() 83 | { 84 | if (Enabled) 85 | { 86 | throw new InvalidOperationException("Hook listener is already started. Call Stop() method firts or use Enabled property."); 87 | } 88 | 89 | HookCallbackReferenceKeeper = new HookCallback(HookCallback); 90 | try 91 | { 92 | HookHandle = m_Hooker.Subscribe(GetHookId(), HookCallbackReferenceKeeper); 93 | } 94 | catch(Exception) 95 | { 96 | HookCallbackReferenceKeeper = null; 97 | HookHandle = 0; 98 | throw; 99 | } 100 | } 101 | 102 | /// 103 | /// Unsubscribes from the hook and stops firing events. 104 | /// 105 | /// 106 | public void Stop() 107 | { 108 | try 109 | { 110 | m_Hooker.Unsubscribe(HookHandle); 111 | } 112 | finally 113 | { 114 | HookCallbackReferenceKeeper = null; 115 | HookHandle = 0; 116 | } 117 | } 118 | 119 | /// 120 | /// Enables you to switch from application hooks to global hooks and vice versa on the fly 121 | /// without unsubscribing from events. Component remains enabled or disabled state after this call as it was before. 122 | /// 123 | /// An AppHooker or GlobalHooker object. 124 | public void Replace(Hooker hooker) 125 | { 126 | bool rememberEnabled = Enabled; 127 | Enabled = false; 128 | m_Hooker = hooker; 129 | Enabled = rememberEnabled; 130 | } 131 | 132 | /// 133 | /// Override to deliver correct id to be used for call. 134 | /// 135 | /// 136 | protected abstract int GetHookId(); 137 | 138 | /// 139 | /// Gets or Sets the enabled status of the Hook. 140 | /// 141 | /// 142 | /// True - The Hook is presently installed, activated, and will fire events. 143 | /// 144 | /// False - The Hook is not part of the hook chain, and will not fire events. 145 | /// 146 | /// 147 | public bool Enabled 148 | { 149 | get { return HookHandle != 0; } 150 | set 151 | { 152 | bool mustEnable = value; 153 | if (mustEnable) 154 | { 155 | if (!Enabled) 156 | { 157 | Start(); 158 | } 159 | } 160 | else 161 | { 162 | if (Enabled) 163 | { 164 | Stop(); 165 | } 166 | } 167 | } 168 | } 169 | 170 | /// 171 | /// Release delegates, unsubscribes from hooks. 172 | /// 173 | /// 2 174 | public virtual void Dispose() 175 | { 176 | Stop(); 177 | } 178 | 179 | /// 180 | /// Unsubscribes from global hooks skiping error handling. 181 | /// 182 | ~BaseHookListener() 183 | { 184 | if (HookHandle != 0) 185 | { 186 | Hooker.UnhookWindowsHookEx(HookHandle); 187 | } 188 | } 189 | } 190 | } -------------------------------------------------------------------------------- /神龙辅助工具/神龙辅助工具.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {BC0EA7AA-90E1-4F63-8334-57DB183D5735} 9 | WinExe 10 | Properties 11 | 神龙辅助工具 12 | 神龙辅助工具 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | x86 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | x86 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | shenlong.ico 38 | 39 | 40 | 41 | Resources\Newtonsoft.Json.dll 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Form 61 | 62 | 63 | Form1.cs 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | Component 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | UserControl 94 | 95 | 96 | UCMain.cs 97 | 98 | 99 | UserControl 100 | 101 | 102 | UCReName.cs 103 | 104 | 105 | UserControl 106 | 107 | 108 | UCWindowAccount.cs 109 | 110 | 111 | 112 | Form1.cs 113 | 114 | 115 | ResXFileCodeGenerator 116 | Resources.Designer.cs 117 | Designer 118 | 119 | 120 | True 121 | Resources.resx 122 | True 123 | 124 | 125 | UCMain.cs 126 | 127 | 128 | UCReName.cs 129 | 130 | 131 | UCWindowAccount.cs 132 | 133 | 134 | SettingsSingleFileGenerator 135 | Settings.Designer.cs 136 | 137 | 138 | True 139 | Settings.settings 140 | True 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 158 | -------------------------------------------------------------------------------- /神龙辅助工具/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Diagnostics; 10 | using System.IO; 11 | using System.Runtime.InteropServices; 12 | using MouseKeyboardActivityMonitor; 13 | using System.Threading; 14 | 15 | namespace 神龙辅助工具 16 | { 17 | public partial class Form1 : Form 18 | { 19 | private string processName;//当前程序进程名 20 | Point mouseOff;//鼠标移动位置变量 21 | bool leftFlag; //标记是否为左键 22 | 23 | //底部文字滚动显示 24 | private int mPostionX, mPostionY; 25 | private int mHeight, mWidth; 26 | private Label mLabel = new Label(); 27 | 28 | public Form1() 29 | { 30 | //加载嵌入资源(添加程序集解析事件) 31 | AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); 32 | InitializeComponent(); 33 | /*在多线程程序中: 34 | * 新创建的线程不能访问UI线程创建的窗口控件, 35 | * 如果需要访问窗口中的控件,可以在窗口构造函数中将CheckForIllegalCrossThreadCalls设置为false 36 | */ 37 | Control.CheckForIllegalCrossThreadCalls = false; 38 | /* 39 | //右下角显示【注意:代码要放到InitializeComponent()后面】 40 | int x = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Width - this.Width; 41 | int y = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size.Height - this.Height; 42 | Point p = new Point(x, y); 43 | this.PointToScreen(p); 44 | this.Location = p; 45 | */ 46 | } 47 | //切换计算机用户 48 | [DllImport("Wtsapi32.dll", SetLastError = true)] 49 | extern static bool WTSDisconnectSession(IntPtr hServer, int sessionId, [MarshalAs(UnmanagedType.Bool)] bool bWait); 50 | 51 | #region 加载嵌入资源中的全部dll文件 52 | private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) 53 | { 54 | string dllName = args.Name.Contains(",") ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll", ""); 55 | dllName = dllName.Replace(".", "_"); 56 | if (dllName.EndsWith("_resources")) return null; 57 | System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly()); 58 | byte[] bytes = (byte[])rm.GetObject(dllName); 59 | return System.Reflection.Assembly.Load(bytes); 60 | } 61 | #endregion 62 | 63 | private void Form1_MouseDown(object sender, MouseEventArgs e) 64 | { 65 | if (e.Button == MouseButtons.Left) 66 | { 67 | mouseOff = new Point(-e.X, -e.Y); //得到变量的值 68 | leftFlag = true; //点击左键按下时标注为true 69 | } 70 | } 71 | 72 | private void Form1_MouseMove(object sender, MouseEventArgs e) 73 | { 74 | if (leftFlag) 75 | { 76 | Point mouseSet = Control.MousePosition; 77 | mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置 78 | Location = mouseSet; 79 | } 80 | } 81 | 82 | private void Form1_MouseUp(object sender, MouseEventArgs e) 83 | { 84 | if (leftFlag) 85 | { 86 | leftFlag = false;//释放鼠标后标注为false 87 | } 88 | } 89 | 90 | private void Form1_Load(object sender, EventArgs e) 91 | { 92 | //获取当前进程名称 93 | Process cur = Process.GetCurrentProcess(); 94 | processName = cur.ProcessName; 95 | this.Text = processName; 96 | FormPositionHelper.SetSize(this); 97 | //加载主面板 98 | ShowMain(); 99 | //显示底部滚动信息 100 | InitScrollShow(); 101 | } 102 | 103 | private void ShowMain() 104 | { 105 | panelMain.Controls.Clear(); 106 | UCMain uc = new UCMain(); 107 | //设置样式是否填充整个panel 108 | uc.Dock = System.Windows.Forms.DockStyle.Fill; 109 | panelMain.Controls.Add(uc); 110 | } 111 | 112 | private void Form1_FormClosing(object sender, FormClosingEventArgs e) 113 | { 114 | //必须加上这个判断,否则窗体最小化后无法恢复和还原了 115 | if (this.WindowState != FormWindowState.Minimized) 116 | FormPositionHelper.SaveSize(this); 117 | } 118 | 119 | // 初始化label显示 120 | private void InitScrollShow() 121 | { 122 | mHeight = panelScreen.Height; ; 123 | mWidth = panelScreen.Width; 124 | mLabel.Font = new Font("宋体", 9); 125 | //label显示需要减去本身的高度 126 | mHeight -= mLabel.Font.Height; 127 | mPostionX = mWidth; 128 | mPostionY = mHeight; 129 | mLabel.Location = new Point(mPostionX, mPostionY); 130 | mLabel.Text = "提示:使用鼠标选中脚本项,按Delete键可直接删除该脚本。 开发团队:美奇软件开发工作室 联系QQ:15577969"; 131 | mLabel.ForeColor = Color.OrangeRed; 132 | mLabel.AutoSize = true; 133 | panelScreen.Controls.Add(mLabel); 134 | mLabel.Visible = true; 135 | } 136 | 137 | // 设置底栏从右向左滚动显示 138 | private void ScrollShow() 139 | { 140 | mPostionX = mPostionX - 3; 141 | mLabel.Location = new Point(mPostionX, mPostionY); 142 | if (mPostionX <= -mLabel.Size.Width) 143 | { 144 | mPostionX = mWidth; 145 | } 146 | mLabel.Visible = true; 147 | } 148 | 149 | private void timerMsg_Tick(object sender, EventArgs e) 150 | { 151 | ScrollShow(); 152 | } 153 | 154 | private void tspSetAppName_Click(object sender, EventArgs e) 155 | { 156 | panelMain.Controls.Clear(); 157 | UCReName uc = new UCReName(); 158 | //设置样式是否填充整个panel 159 | uc.Dock = System.Windows.Forms.DockStyle.Fill; 160 | panelMain.Controls.Add(uc); 161 | } 162 | 163 | private void tspMain_Click(object sender, EventArgs e) 164 | { 165 | ShowMain(); 166 | } 167 | 168 | private void tspCreateWindowUser_Click(object sender, EventArgs e) 169 | { 170 | panelMain.Controls.Clear(); 171 | UCWindowAccount uc = new UCWindowAccount(); 172 | //设置样式是否填充整个panel 173 | uc.Dock = System.Windows.Forms.DockStyle.Fill; 174 | panelMain.Controls.Add(uc); 175 | } 176 | 177 | private void tspChangeUser_Click(object sender, EventArgs e) 178 | { 179 | if (MessageBox.Show("确定要切换到其他用户吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) 180 | 181 | { 182 | //使用子线程去切换,防止电脑卡顿。 183 | new Thread(new ThreadStart(this.ChangeWindowUser)) { IsBackground = true }.Start(); 184 | } 185 | 186 | } 187 | private void ChangeWindowUser() 188 | { 189 | IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero; 190 | int WTS_CURRENT_SESSION = -1; 191 | 192 | if (!WTSDisconnectSession(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, false)) 193 | { 194 | MessageBox.Show("WTSDisconnectSession Failed: " + Marshal.GetLastWin32Error()); 195 | } 196 | } 197 | 198 | private void tspQQ_Click(object sender, EventArgs e) 199 | { 200 | try 201 | { 202 | Process.Start("tencent://message/?uin=15577969&Menu=yes"); 203 | } 204 | catch (Exception) 205 | { 206 | Process.Start("https://wpa.qq.com/msgrd?v=3&uin=15577969&site=qqq&menu=yes"); 207 | } 208 | } 209 | 210 | private void tspUrl_Click(object sender, EventArgs e) 211 | { 212 | Process.Start("http://www.zy13.net"); 213 | } 214 | 215 | private void tspCSDN_Click(object sender, EventArgs e) 216 | { 217 | Process.Start("https://blog.csdn.net/qq15577969"); 218 | } 219 | 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/MouseEventExtArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows.Forms; 4 | using MouseKeyboardActivityMonitor.WinApi; 5 | 6 | namespace MouseKeyboardActivityMonitor 7 | { 8 | /// 9 | /// Provides extended data for the MouseClickExt and MouseMoveExt events. 10 | /// 11 | public class MouseEventExtArgs : MouseEventArgs 12 | { 13 | /// 14 | /// Creates from Windows Message parameters. 15 | /// 16 | /// The first Windows Message parameter. 17 | /// The second Windows Message parameter. 18 | /// Specifies if the hook is local or global. 19 | /// A new MouseEventExtArgs object. 20 | internal static MouseEventExtArgs FromRawData(int wParam, IntPtr lParam, bool isGlobal) 21 | { 22 | return isGlobal ? 23 | FromRawDataGlobal(wParam, lParam) : 24 | FromRawDataApp(wParam, lParam); 25 | } 26 | 27 | /// 28 | /// Creates from Windows Message parameters, 29 | /// based upon a local application hook. 30 | /// 31 | /// The first Windows Message parameter. 32 | /// The second Windows Message parameter. 33 | /// A new MouseEventExtArgs object. 34 | private static MouseEventExtArgs FromRawDataApp(int wParam, IntPtr lParam) 35 | { 36 | AppMouseStruct marshalledMouseStruct = (AppMouseStruct)Marshal.PtrToStructure(lParam, typeof(AppMouseStruct)); 37 | return FromRawDataUniversal(wParam, marshalledMouseStruct.ToMouseStruct()); 38 | } 39 | 40 | /// 41 | /// Creates from Windows Message parameters, 42 | /// based upon a system-wide global hook. 43 | /// 44 | /// The first Windows Message parameter. 45 | /// The second Windows Message parameter. 46 | /// A new MouseEventExtArgs object. 47 | internal static MouseEventExtArgs FromRawDataGlobal(int wParam, IntPtr lParam) 48 | { 49 | MouseStruct marshalledMouseStruct = (MouseStruct)Marshal.PtrToStructure(lParam, typeof(MouseStruct)); 50 | return FromRawDataUniversal(wParam, marshalledMouseStruct); 51 | } 52 | 53 | /// 54 | /// Creates from relevant mouse data. 55 | /// 56 | /// First Windows Message parameter. 57 | /// A MouseStruct containing information from which to contruct MouseEventExtArgs. 58 | /// A new MouseEventExtArgs object. 59 | private static MouseEventExtArgs FromRawDataUniversal(int wParam, MouseStruct mouseInfo) 60 | { 61 | MouseButtons button = MouseButtons.None; 62 | short mouseDelta = 0; 63 | int clickCount = 0; 64 | 65 | bool isMouseKeyDown = false; 66 | bool isMouseKeyUp = false; 67 | 68 | 69 | switch (wParam) 70 | { 71 | case Messages.WM_LBUTTONDOWN: 72 | isMouseKeyDown = true; 73 | button = MouseButtons.Left; 74 | clickCount = 1; 75 | break; 76 | case Messages.WM_LBUTTONUP: 77 | isMouseKeyUp = true; 78 | button = MouseButtons.Left; 79 | clickCount = 1; 80 | break; 81 | case Messages.WM_LBUTTONDBLCLK: 82 | isMouseKeyDown = true; 83 | button = MouseButtons.Left; 84 | clickCount = 2; 85 | break; 86 | case Messages.WM_RBUTTONDOWN: 87 | isMouseKeyDown = true; 88 | button = MouseButtons.Right; 89 | clickCount = 1; 90 | break; 91 | case Messages.WM_RBUTTONUP: 92 | isMouseKeyUp = true; 93 | button = MouseButtons.Right; 94 | clickCount = 1; 95 | break; 96 | case Messages.WM_RBUTTONDBLCLK: 97 | isMouseKeyDown = true; 98 | button = MouseButtons.Right; 99 | clickCount = 2; 100 | break; 101 | case Messages.WM_MBUTTONDOWN: 102 | isMouseKeyDown = true; 103 | button = MouseButtons.Middle; 104 | clickCount = 1; 105 | break; 106 | case Messages.WM_MBUTTONUP: 107 | isMouseKeyUp = true; 108 | button = MouseButtons.Middle; 109 | clickCount = 1; 110 | break; 111 | case Messages.WM_MBUTTONDBLCLK: 112 | isMouseKeyDown = true; 113 | button = MouseButtons.Middle; 114 | clickCount = 2; 115 | break; 116 | case Messages.WM_MOUSEWHEEL: 117 | mouseDelta = mouseInfo.MouseData; 118 | break; 119 | case Messages.WM_XBUTTONDOWN: 120 | button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 : 121 | MouseButtons.XButton2; 122 | isMouseKeyDown = true; 123 | clickCount = 1; 124 | break; 125 | 126 | case Messages.WM_XBUTTONUP: 127 | button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 : 128 | MouseButtons.XButton2; 129 | isMouseKeyUp = true; 130 | clickCount = 1; 131 | break; 132 | 133 | case Messages.WM_XBUTTONDBLCLK: 134 | isMouseKeyDown = true; 135 | button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 : 136 | MouseButtons.XButton2; 137 | clickCount = 2; 138 | break; 139 | } 140 | 141 | var e = new MouseEventExtArgs( 142 | button, 143 | clickCount, 144 | mouseInfo.Point, 145 | mouseDelta, 146 | mouseInfo.Timestamp, 147 | isMouseKeyDown, 148 | isMouseKeyUp); 149 | 150 | return e; 151 | } 152 | 153 | /// 154 | /// Initializes a new instance of the class. 155 | /// 156 | /// One of the MouseButtons values indicating which mouse button was pressed. 157 | /// The number of times a mouse button was pressed. 158 | /// The x and y -coordinate of a mouse click, in pixels. 159 | /// A signed count of the number of detents the wheel has rotated. 160 | /// The system tick count when the event occured. 161 | /// True if event singnals mouse button down. 162 | /// True if event singnals mouse button up. 163 | internal MouseEventExtArgs(MouseButtons buttons, int clicks, Point point, int delta, int timestamp, bool isMouseKeyDown, bool isMouseKeyUp) 164 | : base(buttons, clicks, point.X, point.Y, delta) 165 | { 166 | IsMouseKeyDown = isMouseKeyDown; 167 | IsMouseKeyUp = isMouseKeyUp; 168 | Timestamp = timestamp; 169 | } 170 | 171 | internal MouseEventExtArgs ToDoubleClickEventArgs() 172 | { 173 | return new MouseEventExtArgs(Button, 2, Point, Delta, Timestamp, IsMouseKeyDown, IsMouseKeyUp); 174 | } 175 | 176 | /// 177 | /// Set this property to true inside your event handler to prevent further processing of the event in other applications. 178 | /// 179 | public bool Handled { get; set; } 180 | 181 | /// 182 | /// True if event contains information about wheel scroll. 183 | /// 184 | public bool WheelScrolled 185 | { 186 | get { return Delta != 0; } 187 | } 188 | 189 | /// 190 | /// True if event signals a click. False if it was only a move or wheel scroll. 191 | /// 192 | public bool Clicked 193 | { 194 | get { return Clicks > 0; } 195 | } 196 | 197 | /// 198 | /// True if event singnals mouse button down. 199 | /// 200 | public bool IsMouseKeyDown 201 | { 202 | get; 203 | private set; 204 | } 205 | 206 | /// 207 | /// True if event singnals mouse button up. 208 | /// 209 | public bool IsMouseKeyUp 210 | { 211 | get; 212 | private set; 213 | } 214 | 215 | /// 216 | /// The system tick count of when the event occured. 217 | /// 218 | public int Timestamp 219 | { 220 | get; 221 | private set; 222 | } 223 | 224 | /// 225 | /// 226 | /// 227 | internal Point Point { 228 | get 229 | { 230 | return new Point(X, Y); 231 | } 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/MouseHookListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using MouseKeyboardActivityMonitor.WinApi; 4 | 5 | namespace MouseKeyboardActivityMonitor 6 | { 7 | /// 8 | /// This class monitors all mouse activities and provides appropriate events. 9 | /// 10 | public class MouseHookListener : BaseHookListener 11 | { 12 | 13 | private Point m_PreviousPosition; 14 | private int m_PreviousClickedTime; 15 | private MouseButtons m_PreviousClicked; 16 | private MouseButtons m_DownButtonsWaitingForMouseUp; 17 | private MouseButtons m_SuppressButtonUpFlags; 18 | private int m_SystemDoubleClickTime; 19 | 20 | /// 21 | /// Initializes a new instance of . 22 | /// 23 | /// Depending on this parameter the listener hooks either application or global mouse events. 24 | /// 25 | /// Hooks are not active after installation. You need to use either property or call method. 26 | /// 27 | public MouseHookListener(Hooker hooker) 28 | : base(hooker) 29 | { 30 | m_PreviousPosition = new Point(-1, -1); 31 | m_PreviousClickedTime = 0; 32 | m_DownButtonsWaitingForMouseUp = MouseButtons.None; 33 | m_SuppressButtonUpFlags = MouseButtons.None; 34 | m_PreviousClicked = MouseButtons.None; 35 | m_SystemDoubleClickTime = Mouse.GetDoubleClickTime(); 36 | } 37 | 38 | //################################################################## 39 | #region ProcessCallback and related subroutines 40 | 41 | /// 42 | /// This method processes the data from the hook and initiates event firing. 43 | /// 44 | /// The first Windows Messages parameter. 45 | /// The second Windows Messages parameter. 46 | /// 47 | /// True - The hook will be passed along to other applications. 48 | /// 49 | /// False - The hook will not be given to other applications, effectively blocking input. 50 | /// 51 | /// 52 | protected override bool ProcessCallback(int wParam, IntPtr lParam) 53 | { 54 | MouseEventExtArgs e = MouseEventExtArgs.FromRawData(wParam, lParam, IsGlobal); 55 | 56 | if (e.IsMouseKeyDown) 57 | { 58 | ProcessMouseDown(ref e); 59 | } 60 | 61 | if (e.Clicks == 1 && e.IsMouseKeyUp && !e.Handled) 62 | { 63 | ProcessMouseClick(ref e); 64 | } 65 | 66 | if (e.Clicks == 2 && !e.Handled) 67 | { 68 | InvokeMouseEventHandler(MouseDoubleClick, e); 69 | } 70 | 71 | if (e.IsMouseKeyUp) 72 | { 73 | ProcessMouseUp(ref e); 74 | } 75 | 76 | if (e.WheelScrolled) 77 | { 78 | InvokeMouseEventHandler(MouseWheel, e); 79 | } 80 | 81 | if (HasMoved(e.Point)) 82 | { 83 | ProcessMouseMove(ref e); 84 | } 85 | 86 | return !e.Handled; 87 | } 88 | 89 | private void ProcessMouseDown(ref MouseEventExtArgs e) 90 | { 91 | if (IsGlobal) 92 | { 93 | ProcessPossibleDoubleClick(ref e); 94 | } 95 | else 96 | { 97 | // These are only used for global. No need for them in AppHooks 98 | m_DownButtonsWaitingForMouseUp = MouseButtons.None; 99 | m_PreviousClicked = MouseButtons.None; 100 | m_PreviousClickedTime = 0; 101 | } 102 | 103 | 104 | InvokeMouseEventHandler(MouseDown, e); 105 | InvokeMouseEventHandlerExt(MouseDownExt, e); 106 | if (e.Handled) 107 | { 108 | SetSupressButtonUpFlag(e.Button); 109 | e.Handled = true; 110 | } 111 | } 112 | 113 | private void ProcessPossibleDoubleClick(ref MouseEventExtArgs e) 114 | { 115 | if (IsDoubleClick(e.Button, e.Timestamp)) 116 | { 117 | e = e.ToDoubleClickEventArgs(); 118 | m_DownButtonsWaitingForMouseUp = MouseButtons.None; 119 | m_PreviousClicked = MouseButtons.None; 120 | m_PreviousClickedTime = 0; 121 | } 122 | else 123 | { 124 | m_DownButtonsWaitingForMouseUp |= e.Button; 125 | m_PreviousClickedTime = e.Timestamp; 126 | } 127 | } 128 | 129 | private void ProcessMouseClick(ref MouseEventExtArgs e) 130 | { 131 | if ((m_DownButtonsWaitingForMouseUp & e.Button) != MouseButtons.None) 132 | { 133 | m_PreviousClicked = e.Button; 134 | m_DownButtonsWaitingForMouseUp = MouseButtons.None; 135 | InvokeMouseEventHandler(MouseClick, e); 136 | InvokeMouseEventHandlerExt(MouseClickExt, e); 137 | } 138 | } 139 | 140 | private void ProcessMouseUp(ref MouseEventExtArgs e) 141 | { 142 | if (!HasSupressButtonUpFlag(e.Button)) 143 | { 144 | InvokeMouseEventHandler(MouseUp, e); 145 | } 146 | else 147 | { 148 | RemoveSupressButtonUpFlag(e.Button); 149 | e.Handled = true; 150 | } 151 | } 152 | 153 | private void ProcessMouseMove(ref MouseEventExtArgs e) 154 | { 155 | m_PreviousPosition = e.Point; 156 | 157 | InvokeMouseEventHandler(MouseMove, e); 158 | InvokeMouseEventHandlerExt(MouseMoveExt, e); 159 | } 160 | 161 | #endregion 162 | 163 | private void RemoveSupressButtonUpFlag(MouseButtons button) 164 | { 165 | m_SuppressButtonUpFlags = m_SuppressButtonUpFlags ^ button; 166 | } 167 | 168 | private bool HasSupressButtonUpFlag(MouseButtons button) 169 | { 170 | return (m_SuppressButtonUpFlags & button) != 0; 171 | } 172 | 173 | private void SetSupressButtonUpFlag(MouseButtons button) 174 | { 175 | m_SuppressButtonUpFlags = m_SuppressButtonUpFlags | button; 176 | } 177 | 178 | /// 179 | /// Returns the correct hook id to be used for call. 180 | /// 181 | /// WH_MOUSE (0x07) or WH_MOUSE_LL (0x14) constant. 182 | protected override int GetHookId() 183 | { 184 | return IsGlobal ? 185 | GlobalHooker.WH_MOUSE_LL : 186 | AppHooker.WH_MOUSE; 187 | } 188 | 189 | private bool HasMoved(Point actualPoint) 190 | { 191 | return m_PreviousPosition != actualPoint; 192 | } 193 | 194 | private bool IsDoubleClick(MouseButtons button, int timestamp) 195 | { 196 | return 197 | button == m_PreviousClicked && 198 | timestamp - m_PreviousClickedTime <= m_SystemDoubleClickTime; // Mouse.GetDoubleClickTime(); 199 | } 200 | 201 | private void InvokeMouseEventHandler(MouseEventHandler handler, MouseEventArgs e) 202 | { 203 | if (handler != null) 204 | { 205 | handler(this, e); 206 | } 207 | } 208 | 209 | 210 | private void InvokeMouseEventHandlerExt(EventHandler handler, MouseEventExtArgs e) 211 | { 212 | if (handler != null) 213 | { 214 | handler(this, e); 215 | } 216 | } 217 | 218 | /// 219 | /// Occurs when the mouse pointer is moved. 220 | /// 221 | public event MouseEventHandler MouseMove; 222 | 223 | /// 224 | /// Occurs when the mouse pointer is moved. 225 | /// 226 | /// 227 | /// This event provides extended arguments of type enabling you to 228 | /// supress further processing of mouse movement in other applications. 229 | /// 230 | public event EventHandler MouseMoveExt; 231 | 232 | /// 233 | /// Occurs when a click was performed by the mouse. 234 | /// 235 | public event MouseEventHandler MouseClick; 236 | 237 | /// 238 | /// Occurs when a click was performed by the mouse. 239 | /// 240 | /// 241 | /// This event provides extended arguments of type enabling you to 242 | /// supress further processing of mouse click in other applications. 243 | /// 244 | [Obsolete("To supress mouse clicks use MouseDownExt event instead.")] 245 | public event EventHandler MouseClickExt; 246 | 247 | /// 248 | /// Occurs when the mouse a mouse button is pressed. 249 | /// 250 | public event MouseEventHandler MouseDown; 251 | 252 | /// 253 | /// Occurs when the mouse a mouse button is pressed. 254 | /// 255 | /// 256 | /// This event provides extended arguments of type enabling you to 257 | /// supress further processing of mouse click in other applications. 258 | /// 259 | public event EventHandler MouseDownExt; 260 | 261 | /// 262 | /// Occurs when a mouse button is released. 263 | /// 264 | public event MouseEventHandler MouseUp; 265 | 266 | /// 267 | /// Occurs when the mouse wheel moves. 268 | /// 269 | public event MouseEventHandler MouseWheel; 270 | 271 | /// 272 | /// Occurs when a mouse button is double-clicked. 273 | /// 274 | public event MouseEventHandler MouseDoubleClick; 275 | 276 | /// 277 | /// Release delegates, unsubscribes from hooks. 278 | /// 279 | /// 2 280 | public override void Dispose() 281 | { 282 | MouseClick = null; 283 | MouseClickExt = null; 284 | MouseDown = null; 285 | MouseDownExt = null; 286 | MouseMove = null; 287 | MouseMoveExt = null; 288 | MouseUp = null; 289 | MouseWheel = null; 290 | MouseDoubleClick = null; 291 | base.Dispose(); 292 | } 293 | } 294 | } -------------------------------------------------------------------------------- /神龙辅助工具/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace 神龙辅助工具 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows 窗体设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); 33 | this.timerMsg = new System.Windows.Forms.Timer(this.components); 34 | this.panelScreen = new System.Windows.Forms.Panel(); 35 | this.toolStrip1 = new System.Windows.Forms.ToolStrip(); 36 | this.tspMain = new System.Windows.Forms.ToolStripButton(); 37 | this.tspSetAppName = new System.Windows.Forms.ToolStripButton(); 38 | this.tspUrl = new System.Windows.Forms.ToolStripButton(); 39 | this.tspCSDN = new System.Windows.Forms.ToolStripButton(); 40 | this.tspQQ = new System.Windows.Forms.ToolStripButton(); 41 | this.tspCreateWindowUser = new System.Windows.Forms.ToolStripButton(); 42 | this.tspChangeUser = new System.Windows.Forms.ToolStripButton(); 43 | this.panelMain = new System.Windows.Forms.Panel(); 44 | this.toolStrip1.SuspendLayout(); 45 | this.SuspendLayout(); 46 | // 47 | // timerMsg 48 | // 49 | this.timerMsg.Enabled = true; 50 | this.timerMsg.Tick += new System.EventHandler(this.timerMsg_Tick); 51 | // 52 | // panelScreen 53 | // 54 | this.panelScreen.ForeColor = System.Drawing.SystemColors.GrayText; 55 | this.panelScreen.Location = new System.Drawing.Point(5, 397); 56 | this.panelScreen.Name = "panelScreen"; 57 | this.panelScreen.Size = new System.Drawing.Size(441, 21); 58 | this.panelScreen.TabIndex = 30; 59 | // 60 | // toolStrip1 61 | // 62 | this.toolStrip1.AutoSize = false; 63 | this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); 64 | this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 65 | this.tspMain, 66 | this.tspSetAppName, 67 | this.tspUrl, 68 | this.tspCSDN, 69 | this.tspQQ, 70 | this.tspCreateWindowUser, 71 | this.tspChangeUser}); 72 | this.toolStrip1.Location = new System.Drawing.Point(0, 0); 73 | this.toolStrip1.Name = "toolStrip1"; 74 | this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; 75 | this.toolStrip1.Size = new System.Drawing.Size(450, 30); 76 | this.toolStrip1.TabIndex = 31; 77 | this.toolStrip1.Text = "toolStrip1"; 78 | // 79 | // tspMain 80 | // 81 | this.tspMain.Image = ((System.Drawing.Image)(resources.GetObject("tspMain.Image"))); 82 | this.tspMain.ImageTransparentColor = System.Drawing.Color.Magenta; 83 | this.tspMain.Name = "tspMain"; 84 | this.tspMain.Size = new System.Drawing.Size(68, 27); 85 | this.tspMain.Text = "主界面"; 86 | this.tspMain.Click += new System.EventHandler(this.tspMain_Click); 87 | // 88 | // tspSetAppName 89 | // 90 | this.tspSetAppName.Image = ((System.Drawing.Image)(resources.GetObject("tspSetAppName.Image"))); 91 | this.tspSetAppName.ImageTransparentColor = System.Drawing.Color.Magenta; 92 | this.tspSetAppName.Name = "tspSetAppName"; 93 | this.tspSetAppName.Size = new System.Drawing.Size(92, 27); 94 | this.tspSetAppName.Text = "程序重命名"; 95 | this.tspSetAppName.Click += new System.EventHandler(this.tspSetAppName_Click); 96 | // 97 | // tspUrl 98 | // 99 | this.tspUrl.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; 100 | this.tspUrl.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 101 | this.tspUrl.Image = ((System.Drawing.Image)(resources.GetObject("tspUrl.Image"))); 102 | this.tspUrl.ImageTransparentColor = System.Drawing.Color.Magenta; 103 | this.tspUrl.Name = "tspUrl"; 104 | this.tspUrl.Size = new System.Drawing.Size(24, 27); 105 | this.tspUrl.Text = "官方网站"; 106 | this.tspUrl.Click += new System.EventHandler(this.tspUrl_Click); 107 | // 108 | // tspCSDN 109 | // 110 | this.tspCSDN.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; 111 | this.tspCSDN.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 112 | this.tspCSDN.Image = ((System.Drawing.Image)(resources.GetObject("tspCSDN.Image"))); 113 | this.tspCSDN.ImageTransparentColor = System.Drawing.Color.Magenta; 114 | this.tspCSDN.Name = "tspCSDN"; 115 | this.tspCSDN.Size = new System.Drawing.Size(24, 27); 116 | this.tspCSDN.Text = "CSDN博客"; 117 | this.tspCSDN.Click += new System.EventHandler(this.tspCSDN_Click); 118 | // 119 | // tspQQ 120 | // 121 | this.tspQQ.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; 122 | this.tspQQ.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 123 | this.tspQQ.Image = ((System.Drawing.Image)(resources.GetObject("tspQQ.Image"))); 124 | this.tspQQ.ImageTransparentColor = System.Drawing.Color.Magenta; 125 | this.tspQQ.Name = "tspQQ"; 126 | this.tspQQ.Size = new System.Drawing.Size(24, 27); 127 | this.tspQQ.Text = "技术QQ"; 128 | this.tspQQ.Click += new System.EventHandler(this.tspQQ_Click); 129 | // 130 | // tspCreateWindowUser 131 | // 132 | this.tspCreateWindowUser.Image = ((System.Drawing.Image)(resources.GetObject("tspCreateWindowUser.Image"))); 133 | this.tspCreateWindowUser.ImageTransparentColor = System.Drawing.Color.Magenta; 134 | this.tspCreateWindowUser.Name = "tspCreateWindowUser"; 135 | this.tspCreateWindowUser.Size = new System.Drawing.Size(80, 27); 136 | this.tspCreateWindowUser.Text = "创建用户"; 137 | this.tspCreateWindowUser.Visible = false; 138 | this.tspCreateWindowUser.Click += new System.EventHandler(this.tspCreateWindowUser_Click); 139 | // 140 | // tspChangeUser 141 | // 142 | this.tspChangeUser.Image = ((System.Drawing.Image)(resources.GetObject("tspChangeUser.Image"))); 143 | this.tspChangeUser.ImageTransparentColor = System.Drawing.Color.Magenta; 144 | this.tspChangeUser.Name = "tspChangeUser"; 145 | this.tspChangeUser.Size = new System.Drawing.Size(80, 27); 146 | this.tspChangeUser.Text = "切换用户"; 147 | this.tspChangeUser.Visible = false; 148 | this.tspChangeUser.Click += new System.EventHandler(this.tspChangeUser_Click); 149 | // 150 | // panelMain 151 | // 152 | this.panelMain.Location = new System.Drawing.Point(5, 33); 153 | this.panelMain.Name = "panelMain"; 154 | this.panelMain.Size = new System.Drawing.Size(441, 364); 155 | this.panelMain.TabIndex = 32; 156 | // 157 | // Form1 158 | // 159 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 160 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 161 | this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange; 162 | this.ClientSize = new System.Drawing.Size(450, 427); 163 | this.Controls.Add(this.panelMain); 164 | this.Controls.Add(this.toolStrip1); 165 | this.Controls.Add(this.panelScreen); 166 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 167 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 168 | this.MaximizeBox = false; 169 | this.Name = "Form1"; 170 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 171 | this.Text = "神龙辅助工具"; 172 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); 173 | this.Load += new System.EventHandler(this.Form1_Load); 174 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 175 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); 176 | this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp); 177 | this.toolStrip1.ResumeLayout(false); 178 | this.toolStrip1.PerformLayout(); 179 | this.ResumeLayout(false); 180 | 181 | } 182 | 183 | #endregion 184 | 185 | private System.Windows.Forms.Timer timerMsg; 186 | private System.Windows.Forms.Panel panelScreen; 187 | private System.Windows.Forms.ToolStrip toolStrip1; 188 | private System.Windows.Forms.ToolStripButton tspSetAppName; 189 | private System.Windows.Forms.ToolStripButton tspCreateWindowUser; 190 | private System.Windows.Forms.ToolStripButton tspUrl; 191 | private System.Windows.Forms.Panel panelMain; 192 | private System.Windows.Forms.ToolStripButton tspMain; 193 | private System.Windows.Forms.ToolStripButton tspChangeUser; 194 | private System.Windows.Forms.ToolStripButton tspQQ; 195 | private System.Windows.Forms.ToolStripButton tspCSDN; 196 | } 197 | } 198 | 199 | -------------------------------------------------------------------------------- /神龙辅助工具/UserControlGroup/UCMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using MouseKeyboardActivityMonitor; 10 | using System.Threading; 11 | using System.Runtime.InteropServices; 12 | 13 | namespace 神龙辅助工具 14 | { 15 | public partial class UCMain : UserControl 16 | { 17 | private int speed = 500; 18 | 19 | //Ini文件辅助类 20 | private IniHelper ini = null; 21 | 22 | //默认键 23 | Keys keyRecord = Keys.F5; 24 | Keys keyPlay = Keys.F6; 25 | Keys keyStop = Keys.F7; 26 | TypeConverter converter = TypeDescriptor.GetConverter(typeof(Keys)); 27 | 28 | readonly KeyboardHookListener khl; 29 | readonly MouseHookListener mhl; 30 | 31 | //是否启用键 32 | bool IsUseKey = true; 33 | 34 | //默认键 35 | Keys keyItem = Keys.D2; 36 | //延迟时间 37 | int delayTime = 60; 38 | 39 | private Thread threadRandom; 40 | 41 | //操作键盘 42 | [DllImport("user32.dll", EntryPoint = "keybd_event", SetLastError = true)] 43 | public static extern void keybd_event(Keys bVk, byte bScan, uint dwFlags, uint dwExtraInfo); 44 | 45 | public UCMain() 46 | { 47 | InitializeComponent(); 48 | //加载config.ini配置文件 49 | LoadIniConfig(); 50 | //设置鼠标勾子 51 | mhl = new MouseHookListener(new MouseKeyboardActivityMonitor.WinApi.GlobalHooker()); 52 | mhl.MouseMove += new MouseEventHandler(mhl_MouseMove); 53 | mhl.Enabled = true; 54 | 55 | //设置键盘勾子 56 | khl = new KeyboardHookListener(new MouseKeyboardActivityMonitor.WinApi.GlobalHooker()); 57 | khl.KeyDown += new KeyEventHandler(khl_KeyDown); 58 | khl.Enabled = true; 59 | } 60 | 61 | //实时显示鼠标坐标 62 | void mhl_MouseMove(object sender, MouseEventArgs e) 63 | { 64 | labXY.Text = e.X + "," + e.Y; 65 | } 66 | //判断按键 67 | void khl_KeyDown(object sender, KeyEventArgs e) 68 | { 69 | if (e.KeyCode == keyRecord) //设置坐标点 70 | { 71 | string action = string.Empty; 72 | 73 | if (rbtnLeftClick.Checked) action = rbtnLeftClick.Text; //左键单击 74 | else if (rbtnLeftDoubleClick.Checked) action = rbtnLeftDoubleClick.Text; //左键双击 75 | else if (rbtnRightClick.Checked) action = rbtnRightClick.Text; //右键单击 76 | else if (rbtnRightDoubleClick.Checked) action = rbtnRightDoubleClick.Text; //右键双击 77 | string[] stringArray = labXY.Text.Trim().Split(','); 78 | listBox1.Items.Add(string.Format("{0}|{1}|{2}|{3}", stringArray[0], stringArray[1], action, speed)); 79 | } 80 | else if (e.KeyCode == keyPlay) //开始播放 81 | { 82 | if (listBox1.Items.Count == 0) return; 83 | AutoClickThread.ClickData = listBox1.Items.Cast().ToList(); 84 | AutoClickThread.Start(checkBoxLoopRun.Checked); 85 | //开始随机 86 | StartRandom(); 87 | } 88 | else if (e.KeyCode == keyStop) //停止播放 89 | { 90 | AutoClickThread.Stop(); 91 | //停止随机 92 | StopRandom(); 93 | } 94 | } 95 | 96 | /// 97 | /// 加载ini配置文件 98 | /// 99 | private void LoadIniConfig() 100 | { 101 | this.ini = new IniHelper("config.ini"); 102 | string iniRecord = this.ini.ReadString("Setting", "RecordHotKey", "F5"); 103 | this.keyRecord = (Keys)converter.ConvertFromString(iniRecord); 104 | this.textRecord.Text = iniRecord; 105 | this.labRecord.Text = iniRecord + " 设置坐标点"; 106 | 107 | string iniPlay = this.ini.ReadString("Setting", "PlayHotKey", "F6"); 108 | this.keyPlay = (Keys)converter.ConvertFromString(iniPlay); 109 | this.textPlay.Text = iniPlay; 110 | this.labPlay.Text = iniPlay + " 开始播放脚本动作"; 111 | 112 | string iniStop = this.ini.ReadString("Setting", "StopHotKey", "F7"); 113 | this.keyStop = (Keys)converter.ConvertFromString(iniStop); 114 | this.textStop.Text = iniStop; 115 | this.labStop.Text = iniStop + " 停止播放"; 116 | 117 | //速率显示 118 | this.speed = this.ini.ReadInteger("Setting", "Speed", 500); 119 | this.trackBarSpeed.Value = speed / 100; 120 | showTrackBar(); 121 | 122 | //是否启用键 123 | this.IsUseKey = this.ini.ReadBool("Setting", "IsUseKey", true); 124 | this.cbIsUseKey.Checked = this.IsUseKey; 125 | //获取键名 126 | string textKey = this.ini.ReadString("Setting", "Keyboard", "D2"); 127 | this.keyItem = (Keys)converter.ConvertFromString(textKey); 128 | this.textKey.Text = textKey; 129 | this.labKey.Text = textKey+"键"; 130 | //随机时间 131 | this.delayTime = this.ini.ReadInteger("Setting", "DelayTime", 60); 132 | this.numbeSeconds.Value = this.delayTime; 133 | } 134 | 135 | private void checkBoxHotKeys_CheckedChanged(object sender, EventArgs e) 136 | { 137 | if (checkBoxHotKeys.Checked) 138 | { 139 | groupBox3.Show(); 140 | groupBox4.Hide(); 141 | } 142 | else 143 | { 144 | groupBox3.Hide(); 145 | groupBox4.Show(); 146 | } 147 | } 148 | 149 | private void trackBarSpeed_ValueChanged(object sender, EventArgs e) 150 | { 151 | speed = this.trackBarSpeed.Value * 100; 152 | this.ini.WriteString("Setting", "Speed", speed.ToString()); 153 | showTrackBar(); 154 | } 155 | 156 | private void showTrackBar() 157 | { 158 | float f = speed * 1.0f / 1000; 159 | this.lbTigs.Text = "当前速率" + f + "秒"; 160 | } 161 | 162 | private void listBox1_KeyUp(object sender, KeyEventArgs e) 163 | { 164 | //点击Delete删除键 165 | if (listBox1.SelectedIndex >= 0 && e.KeyCode == Keys.Delete) 166 | { 167 | listBox1.Items.RemoveAt(listBox1.SelectedIndex); 168 | } 169 | //ctrl+s保存快捷键 170 | if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.S) 171 | { 172 | SaveFileDialog sfd = new SaveFileDialog(); 173 | sfd.AddExtension = true; 174 | sfd.Filter = "文本文件(*.txt)|*.txt"; 175 | sfd.DefaultExt = "txt"; 176 | if (sfd.ShowDialog() == DialogResult.OK) 177 | { 178 | FileHelper.WriteAllText(sfd.FileName, listBox1.Items.Cast().ToList()); 179 | } 180 | } 181 | } 182 | 183 | private void labReSet_Click(object sender, EventArgs e) 184 | { 185 | listBox1.Items.Clear(); 186 | } 187 | 188 | private void btnImport_Click(object sender, EventArgs e) 189 | { 190 | OpenFileDialog ofd = new OpenFileDialog(); 191 | ofd.Filter = "文本文件(*.txt)|*.txt"; 192 | 193 | if (ofd.ShowDialog() == DialogResult.OK) 194 | { 195 | List fileContent = FileHelper.ReadAllText(ofd.FileName); 196 | listBox1.Items.AddRange(fileContent.ToArray()); 197 | } 198 | } 199 | 200 | private void btnExport_Click(object sender, EventArgs e) 201 | { 202 | SaveFileDialog sfd = new SaveFileDialog(); 203 | sfd.AddExtension = true; 204 | sfd.Filter = "文本文件(*.txt)|*.txt"; 205 | sfd.DefaultExt = "txt"; 206 | if (sfd.ShowDialog() == DialogResult.OK) 207 | { 208 | FileHelper.WriteAllText(sfd.FileName, listBox1.Items.Cast().ToList()); 209 | } 210 | } 211 | 212 | private void btnRecordSet_Click(object sender, EventArgs e) 213 | { 214 | string textRecord = this.textRecord.Text.Trim(); 215 | keyRecord = (Keys)converter.ConvertFromString(textRecord); 216 | labRecord.Text = textRecord + " 设置坐标点"; 217 | this.ini.WriteString("Setting", "RecordHotKey", textRecord); 218 | MessageBox.Show("录制键设置成功"); 219 | } 220 | 221 | private void btnPlaySet_Click(object sender, EventArgs e) 222 | { 223 | string textPlay = this.textPlay.Text.Trim(); 224 | keyPlay = (Keys)converter.ConvertFromString(textPlay); 225 | labPlay.Text = textPlay + " 开始播放脚本动作"; 226 | this.ini.WriteString("Setting", "PlayHotKey", textPlay); 227 | MessageBox.Show("播放键设置成功"); 228 | } 229 | 230 | private void btnStopSet_Click(object sender, EventArgs e) 231 | { 232 | string textStop = this.textStop.Text.Trim(); 233 | keyStop = (Keys)converter.ConvertFromString(textStop); 234 | labStop.Text = textStop + " 停止播放"; 235 | this.ini.WriteString("Setting", "StopHotKey", textStop); 236 | MessageBox.Show("停止键设置成功"); 237 | } 238 | 239 | private void textRecord_KeyUp(object sender, KeyEventArgs e) 240 | { 241 | this.textRecord.Text = e.KeyCode.ToString(); 242 | } 243 | 244 | private void textPlay_KeyUp(object sender, KeyEventArgs e) 245 | { 246 | this.textPlay.Text = e.KeyCode.ToString(); 247 | } 248 | 249 | private void textStop_KeyUp(object sender, KeyEventArgs e) 250 | { 251 | this.textStop.Text = e.KeyCode.ToString(); 252 | } 253 | 254 | private void btnSave_Click(object sender, EventArgs e) 255 | { 256 | try 257 | { 258 | //是否启用键 259 | this.IsUseKey = this.cbIsUseKey.Checked; 260 | this.ini.WriteBool("Setting", "IsUseKey", this.IsUseKey); 261 | //设置键名 262 | string textKey = this.textKey.Text.Trim(); 263 | keyItem = (Keys)converter.ConvertFromString(textKey); 264 | this.ini.WriteString("Setting", "Keyboard", textKey); 265 | this.labKey.Text = textKey + "键"; 266 | //随机时间 267 | this.delayTime = Convert.ToInt32(numbeSeconds.Value) > 0 ? Convert.ToInt32(numbeSeconds.Value) : 60; 268 | this.ini.WriteInteger("Setting", "DelayTime", this.delayTime); 269 | MessageBox.Show("保存设置成功"); 270 | } 271 | catch (Exception) 272 | { 273 | MessageBox.Show("保存设置失败"); 274 | } 275 | } 276 | 277 | private void textKey_KeyUp(object sender, KeyEventArgs e) 278 | { 279 | this.textKey.Text = e.KeyCode.ToString(); 280 | } 281 | 282 | /// 283 | /// 开始随机 284 | /// 285 | public void StartRandom() 286 | { 287 | if (threadRandom == null) 288 | threadRandom = new Thread(new ThreadStart(KeyProcess)); 289 | threadRandom.Start(); 290 | } 291 | /// 292 | /// 停止随机 293 | /// 294 | public void StopRandom() 295 | { 296 | if (threadRandom != null) 297 | { 298 | threadRandom.Abort(); 299 | threadRandom = null; 300 | } 301 | } 302 | private void KeyProcess() 303 | { 304 | while (true) 305 | { 306 | try 307 | { 308 | //线程延迟 309 | Thread.Sleep(delayTime * 1000); 310 | if (IsUseKey) 311 | keybd_event(this.keyItem, 0, 0, 0); 312 | } 313 | catch (Exception) 314 | { 315 | } 316 | } 317 | } 318 | } 319 | } 320 | -------------------------------------------------------------------------------- /神龙辅助工具/MouseKeyboardActivityMonitor/Controls/MouseKeyEventProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows.Forms; 4 | using MouseKeyboardActivityMonitor.WinApi; 5 | 6 | namespace MouseKeyboardActivityMonitor.Controls 7 | { 8 | /// 9 | /// This component monitors Application or Global input, depending on 10 | /// and provides appropriate 11 | /// events. 12 | /// 13 | public class MouseKeyEventProvider : Component 14 | { 15 | private readonly KeyboardHookListener m_KeyboardHookManager; 16 | private readonly MouseHookListener m_MouseHookManager; 17 | 18 | /// 19 | /// Initializes a new instance of 20 | /// 21 | public MouseKeyEventProvider() 22 | { 23 | m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker()); 24 | m_MouseHookManager = new MouseHookListener(new GlobalHooker()); 25 | } 26 | 27 | /// 28 | /// Gets or Sets the enabled status of the component. 29 | /// 30 | /// 31 | /// True - The component is presently activated and will fire events. 32 | /// 33 | /// False - The component is not active and will not fire events. 34 | /// 35 | /// 36 | public bool Enabled 37 | { 38 | get 39 | { 40 | return DesignMode 41 | ? DesignTimeEnabled 42 | : RunTimeEnabled; 43 | } 44 | set 45 | { 46 | if (DesignMode) 47 | { 48 | DesignTimeEnabled = value; 49 | } 50 | else 51 | { 52 | RunTimeEnabled = value; 53 | } 54 | } 55 | } 56 | 57 | private bool DesignTimeEnabled 58 | { 59 | get; set; 60 | } 61 | 62 | private bool RunTimeEnabled 63 | { 64 | get 65 | { 66 | return m_MouseHookManager.Enabled && m_KeyboardHookManager.Enabled; 67 | } 68 | set 69 | { 70 | m_MouseHookManager.Enabled = value; 71 | m_KeyboardHookManager.Enabled = value; 72 | } 73 | } 74 | 75 | 76 | /// 77 | /// Indicates which hooks to listen to application or global. 78 | /// 79 | public HookType HookType 80 | { 81 | get 82 | { 83 | return m_MouseHookManager.IsGlobal 84 | ? HookType.Global 85 | : HookType.Application; 86 | } 87 | set 88 | { 89 | Hooker hooker; 90 | switch (value) 91 | { 92 | case HookType.Global: 93 | hooker = new GlobalHooker(); 94 | break; 95 | 96 | case HookType.Application: 97 | hooker = new AppHooker(); 98 | break; 99 | 100 | default: 101 | return; 102 | } 103 | 104 | m_MouseHookManager.Replace(hooker); 105 | m_KeyboardHookManager.Replace(hooker); 106 | } 107 | } 108 | 109 | /// 110 | /// This component raises events. The value is always true. 111 | /// 112 | protected override bool CanRaiseEvents 113 | { 114 | get 115 | { 116 | return true; 117 | } 118 | } 119 | 120 | /// 121 | /// 122 | /// 123 | /// 124 | /// 125 | /// 126 | /// Modified from http://stackoverflow.com/questions/1698889/raise-events-in-net-on-the-main-ui-thread 127 | /// 128 | private void RaiseEventOnUIThread(Delegate inputEvent, EventArgs e) 129 | { 130 | object sender = this; 131 | foreach (Delegate d in inputEvent.GetInvocationList()) 132 | { 133 | ISynchronizeInvoke syncer = d.Target as ISynchronizeInvoke; 134 | 135 | if (syncer == null) 136 | { 137 | d.DynamicInvoke(new[] { sender, e }); 138 | } 139 | else 140 | { 141 | // I don't know if ASyncronous is really the way to go. 142 | // If the programmer wants to suppress input, 143 | // will asyncronous make that happen consistently? 144 | 145 | //syncer.EndInvoke(syncer.BeginInvoke(inputEvent, new[] { sender, e })); 146 | syncer.Invoke(inputEvent, new[] { sender, e }); 147 | } 148 | } 149 | } 150 | 151 | //################################################################ 152 | #region Mouse events 153 | 154 | private event MouseEventHandler m_MouseMove; 155 | /// 156 | /// Activated when the user moves the mouse. 157 | /// 158 | public event MouseEventHandler MouseMove 159 | { 160 | add 161 | { 162 | if (m_MouseMove == null) 163 | { 164 | m_MouseHookManager.MouseMove += HookManager_MouseMove; 165 | } 166 | m_MouseMove += value; 167 | } 168 | 169 | remove 170 | { 171 | m_MouseMove -= value; 172 | if (m_MouseMove == null) 173 | { 174 | m_MouseHookManager.MouseMove -= HookManager_MouseMove; 175 | } 176 | } 177 | } 178 | 179 | void HookManager_MouseMove(object sender, MouseEventArgs e) 180 | { 181 | if (m_MouseMove != null) 182 | { 183 | RaiseEventOnUIThread(m_MouseMove, e); 184 | } 185 | } 186 | 187 | private event MouseEventHandler m_MouseClick; 188 | /// 189 | /// Activated upon a single click of the mouse. 190 | /// 191 | public event MouseEventHandler MouseClick 192 | { 193 | add 194 | { 195 | if (m_MouseClick == null) 196 | { 197 | m_MouseHookManager.MouseClick += HookManager_MouseClick; 198 | } 199 | m_MouseClick += value; 200 | } 201 | 202 | remove 203 | { 204 | m_MouseClick -= value; 205 | if (m_MouseClick == null) 206 | { 207 | m_MouseHookManager.MouseClick -= HookManager_MouseClick; 208 | } 209 | } 210 | } 211 | 212 | void HookManager_MouseClick(object sender, MouseEventArgs e) 213 | { 214 | if (m_MouseClick != null) 215 | { 216 | RaiseEventOnUIThread(m_MouseClick, e); 217 | } 218 | } 219 | 220 | private event MouseEventHandler m_MouseDown; 221 | 222 | /// 223 | /// Activated when the user presses a mouse button. 224 | /// 225 | public event MouseEventHandler MouseDown 226 | { 227 | add 228 | { 229 | if (m_MouseDown == null) 230 | { 231 | m_MouseHookManager.MouseDown += HookManager_MouseDown; 232 | } 233 | m_MouseDown += value; 234 | } 235 | 236 | remove 237 | { 238 | m_MouseDown -= value; 239 | if (m_MouseDown == null) 240 | { 241 | m_MouseHookManager.MouseDown -= HookManager_MouseDown; 242 | } 243 | } 244 | } 245 | 246 | void HookManager_MouseDown(object sender, MouseEventArgs e) 247 | { 248 | if (m_MouseDown != null) 249 | { 250 | RaiseEventOnUIThread(m_MouseDown, e); 251 | } 252 | } 253 | 254 | 255 | private event MouseEventHandler m_MouseUp; 256 | 257 | /// 258 | /// Activated when the user releases a mouse button. 259 | /// 260 | public event MouseEventHandler MouseUp 261 | { 262 | add 263 | { 264 | if (m_MouseUp == null) 265 | { 266 | m_MouseHookManager.MouseUp += HookManager_MouseUp; 267 | } 268 | m_MouseUp += value; 269 | } 270 | 271 | remove 272 | { 273 | m_MouseUp -= value; 274 | if (m_MouseUp == null) 275 | { 276 | m_MouseHookManager.MouseUp -= HookManager_MouseUp; 277 | } 278 | } 279 | } 280 | 281 | void HookManager_MouseUp(object sender, MouseEventArgs e) 282 | { 283 | if (m_MouseUp != null) 284 | { 285 | RaiseEventOnUIThread(m_MouseUp, e); 286 | } 287 | } 288 | 289 | private event MouseEventHandler m_MouseDoubleClick; 290 | 291 | /// 292 | /// Activated when the user double-clicks with the mouse. 293 | /// 294 | public event MouseEventHandler MouseDoubleClick 295 | { 296 | add 297 | { 298 | if (m_MouseDoubleClick == null) 299 | { 300 | m_MouseHookManager.MouseDoubleClick += HookManager_MouseDoubleClick; 301 | } 302 | m_MouseDoubleClick += value; 303 | } 304 | 305 | remove 306 | { 307 | m_MouseDoubleClick -= value; 308 | if (m_MouseDoubleClick == null) 309 | { 310 | m_MouseHookManager.MouseDoubleClick -= HookManager_MouseDoubleClick; 311 | } 312 | } 313 | } 314 | 315 | void HookManager_MouseDoubleClick(object sender, MouseEventArgs e) 316 | { 317 | if (m_MouseDoubleClick != null) 318 | { 319 | RaiseEventOnUIThread(m_MouseDoubleClick, e); 320 | } 321 | } 322 | 323 | 324 | private event EventHandler m_MouseMoveExt; 325 | 326 | /// 327 | /// Activated when the user moves the mouse. 328 | /// 329 | /// 330 | /// This event provides extended arguments of type enabling you to 331 | /// supress further processing of mouse movement in other applications. 332 | /// 333 | public event EventHandler MouseMoveExt 334 | { 335 | add 336 | { 337 | if (m_MouseMoveExt == null) 338 | { 339 | m_MouseHookManager.MouseMoveExt += HookManager_MouseMoveExt; 340 | } 341 | m_MouseMoveExt += value; 342 | } 343 | 344 | remove 345 | { 346 | m_MouseMoveExt -= value; 347 | if (m_MouseMoveExt == null) 348 | { 349 | m_MouseHookManager.MouseMoveExt -= HookManager_MouseMoveExt; 350 | } 351 | } 352 | } 353 | 354 | void HookManager_MouseMoveExt(object sender, MouseEventExtArgs e) 355 | { 356 | if (m_MouseMoveExt != null) 357 | { 358 | RaiseEventOnUIThread(m_MouseMoveExt, e); 359 | } 360 | } 361 | 362 | private event EventHandler m_MouseClickExt; 363 | /// 364 | /// Activated upon a single click of the mouse. 365 | /// 366 | /// 367 | /// This event provides extended arguments of type enabling you to 368 | /// supress further processing of mouse click in other applications. 369 | /// 370 | public event EventHandler MouseClickExt 371 | { 372 | add 373 | { 374 | // Disable warning that MouseClickExt is obsolete 375 | #pragma warning disable 618 376 | if (m_MouseClickExt == null) 377 | { 378 | m_MouseHookManager.MouseClickExt += HookManager_MouseClickExt; 379 | } 380 | m_MouseClickExt += value; 381 | } 382 | 383 | remove 384 | { 385 | m_MouseClickExt -= value; 386 | if (m_MouseClickExt == null) 387 | { 388 | m_MouseHookManager.MouseClickExt -= HookManager_MouseClickExt; 389 | } 390 | #pragma warning restore 618 391 | } 392 | } 393 | 394 | void HookManager_MouseClickExt(object sender, MouseEventExtArgs e) 395 | { 396 | if (m_MouseClickExt != null) 397 | { 398 | RaiseEventOnUIThread(m_MouseClickExt, e); 399 | } 400 | } 401 | 402 | private event EventHandler m_MouseDownExt; 403 | 404 | /// 405 | /// Activated when the user presses a mouse button. 406 | /// 407 | /// 408 | /// This event provides extended arguments of type enabling you to 409 | /// supress further processing of mouse down in other applications. 410 | /// 411 | public event EventHandler MouseDownExt 412 | { 413 | add 414 | { 415 | if (m_MouseDownExt == null) 416 | { 417 | m_MouseHookManager.MouseDownExt += HookManager_MouseDownExt; 418 | } 419 | m_MouseDownExt += value; 420 | } 421 | 422 | remove 423 | { 424 | m_MouseDownExt -= value; 425 | if (m_MouseDownExt == null) 426 | { 427 | m_MouseHookManager.MouseDownExt -= HookManager_MouseDownExt; 428 | } 429 | } 430 | } 431 | 432 | void HookManager_MouseDownExt(object sender, MouseEventExtArgs e) 433 | { 434 | if (m_MouseDownExt != null) 435 | { 436 | RaiseEventOnUIThread(m_MouseDownExt, e); 437 | } 438 | } 439 | 440 | private event EventHandler m_MouseWheel; 441 | /// 442 | /// Activated upon mouse scrolling. 443 | /// 444 | public event EventHandler MouseWheel 445 | { 446 | add 447 | { 448 | if (m_MouseWheel == null) 449 | { 450 | m_MouseHookManager.MouseWheel += HookManager_MouseWheel; 451 | } 452 | m_MouseWheel += value; 453 | } 454 | 455 | remove 456 | { 457 | m_MouseWheel -= value; 458 | if (m_MouseWheel == null) 459 | { 460 | m_MouseHookManager.MouseWheel -= HookManager_MouseWheel; 461 | } 462 | } 463 | } 464 | 465 | void HookManager_MouseWheel(object sender, MouseEventArgs e) 466 | { 467 | if (m_MouseWheel != null) 468 | { 469 | RaiseEventOnUIThread(m_MouseWheel, e); 470 | } 471 | } 472 | 473 | 474 | #endregion 475 | 476 | //################################################################ 477 | #region Keyboard events 478 | 479 | private event KeyPressEventHandler m_KeyPress; 480 | 481 | /// 482 | /// Activated when the user presses a key. 483 | /// 484 | /// 485 | /// Key events occur in the following order: 486 | /// 487 | /// KeyDown 488 | /// KeyPress 489 | /// KeyUp 490 | /// 491 | ///The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events. 492 | ///Use the KeyChar property to sample keystrokes at run time and to consume or modify a subset of common keystrokes. 493 | ///To handle keyboard events only in your application and not enable other applications to receive keyboard events, 494 | /// set the KeyPressEventArgs.Handled property in your form's KeyPress event-handling method to true. 495 | /// 496 | public event KeyPressEventHandler KeyPress 497 | { 498 | add 499 | { 500 | if (m_KeyPress == null) 501 | { 502 | m_KeyboardHookManager.KeyPress += HookManager_KeyPress; 503 | } 504 | m_KeyPress += value; 505 | } 506 | remove 507 | { 508 | m_KeyPress -= value; 509 | if (m_KeyPress == null) 510 | { 511 | m_KeyboardHookManager.KeyPress -= HookManager_KeyPress; 512 | } 513 | } 514 | } 515 | 516 | void HookManager_KeyPress(object sender, KeyPressEventArgs e) 517 | { 518 | if (m_KeyPress != null) 519 | { 520 | RaiseEventOnUIThread(m_KeyPress, e); 521 | } 522 | } 523 | 524 | private event KeyEventHandler m_KeyUp; 525 | 526 | /// 527 | /// Activated upon the release of a key. 528 | /// 529 | public event KeyEventHandler KeyUp 530 | { 531 | add 532 | { 533 | if (m_KeyUp == null) 534 | { 535 | m_KeyboardHookManager.KeyUp += HookManager_KeyUp; 536 | } 537 | m_KeyUp += value; 538 | } 539 | remove 540 | { 541 | m_KeyUp -= value; 542 | if (m_KeyUp == null) 543 | { 544 | m_KeyboardHookManager.KeyUp -= HookManager_KeyUp; 545 | } 546 | } 547 | } 548 | 549 | private void HookManager_KeyUp(object sender, KeyEventArgs e) 550 | { 551 | if (m_KeyUp != null) 552 | { 553 | RaiseEventOnUIThread(m_KeyUp, e); 554 | } 555 | } 556 | 557 | private event KeyEventHandler m_KeyDown; 558 | 559 | /// 560 | /// Activated when a key is pushed. 561 | /// 562 | public event KeyEventHandler KeyDown 563 | { 564 | add 565 | { 566 | if (m_KeyDown == null) 567 | { 568 | m_KeyboardHookManager.KeyDown += HookManager_KeyDown; 569 | } 570 | m_KeyDown += value; 571 | } 572 | remove 573 | { 574 | m_KeyDown -= value; 575 | if (m_KeyDown == null) 576 | { 577 | m_KeyboardHookManager.KeyDown -= HookManager_KeyDown; 578 | } 579 | } 580 | } 581 | 582 | private void HookManager_KeyDown(object sender, KeyEventArgs e) 583 | { 584 | RaiseEventOnUIThread(m_KeyDown, e); 585 | } 586 | 587 | #endregion 588 | 589 | 590 | } 591 | } 592 | --------------------------------------------------------------------------------