├── .gitignore ├── README.md └── src ├── ADBHelper.cs ├── AutoClient.cs ├── AutoControl.cs ├── CaptureHelper.cs ├── EnumHelper.cs ├── ImageScanOpenCV.cs ├── KAutoHelper.csproj ├── KAutoHelper.sln ├── LDPlayer.cs ├── License-LGPL.txt ├── MemoryHelper.cs ├── ProcessHelper.cs ├── ThamKhao.cs ├── apk ├── app-release.apk └── clipper.apk ├── app.config ├── autorunReg.reg ├── command adb.txt └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KAutoHelper 2 | A library helps to control Phone, Phone simulator by ADB. Control windows process by Handle(IntPtr). Find image in image use OpenCV. Simulate real Keyboard and Mouse. 3 | Discord server: https://discord.gg/wXGHRTep 4 | -------------------------------------------------------------------------------- /src/ADBHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Text.RegularExpressions; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | using System.Windows; 12 | using System.Windows.Media.Imaging; 13 | 14 | namespace KAutoHelper 15 | { 16 | public class ADBHelper 17 | { 18 | #region commands query 19 | static string LIST_DEVICES = "adb devices"; 20 | static string TAP_DEVICES = "adb -s {0} shell input tap {1} {2}"; 21 | static string SWIPE_DEVICES = "adb -s {0} shell input swipe {1} {2} {3} {4} {5}"; 22 | static string KEY_DEVICES = "adb -s {0} shell input keyevent {1}"; 23 | static string INPUT_TEXT_DEVICES = "adb -s {0} shell input text \"{1}\""; 24 | static string CAPTURE_SCREEN_TO_DEVICES = "adb -s {0} shell screencap -p \"{1}\""; 25 | static string PULL_SCREEN_FROM_DEVICES = "adb -s {0} pull \"{1}\""; 26 | static string REMOVE_SCREEN_FROM_DEVICES = "adb -s {0} shell rm -f \"{1}\""; 27 | static string GET_SCREEN_RESOLUTION = "adb -s {0} shell dumpsys display | Find \"mCurrentDisplayRect\""; 28 | const int DEFAULT_SWIPE_DURATION = 100; 29 | 30 | #endregion 31 | 32 | 33 | static string ADB_FOLDER_PATH = ""; 34 | static string ADB_PATH = ""; 35 | public static string SetADBFolderPath(string folderPath) 36 | { 37 | ADB_FOLDER_PATH = folderPath; 38 | ADB_PATH = folderPath + "\\adb.exe"; 39 | 40 | if (!File.Exists(ADB_PATH)) 41 | { 42 | return "ADB Path not Exits!!!"; 43 | } 44 | return "OK"; 45 | } 46 | public void SetTextFromClipboard(string deviceID, string text) 47 | { 48 | var temp = text.Split(new string[] { "\r\n" }, StringSplitOptions.None); 49 | int count = 0; 50 | foreach (var item in temp) 51 | { 52 | var res = ADBHelper.ExecuteCMDBat(deviceID, $"adb -s {deviceID} shell am broadcast -a clipper.set -e text \"\\\"" + item + "\\\"\""); 53 | ADBHelper.ExecuteCMD($"adb -s {deviceID} shell input keyevent 279"); 54 | count++; 55 | if (count < temp.Length) 56 | { 57 | ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_ENTER); 58 | } 59 | } 60 | } 61 | void Note(string deviceID) 62 | { 63 | /* 64 | cài app cliper hỗ trợ copy páste 65 | adb install C:\images\clipper.apk 66 | 67 | */ 68 | 69 | 70 | // stop zalo đang chạy 71 | ADBHelper.ExecuteCMD($"adb -s {deviceID} shell am force-stop com.zing.zalo"); 72 | 73 | // delete images 74 | var res = ADBHelper.ExecuteCMD($"adb -s {deviceID} shell rm -f /sdcard/Pictures/Images/*"); 75 | 76 | // tạo folder 77 | res = ADBHelper.ExecuteCMD($"adb -s {deviceID} shell mkdir /sdcard/Pictures/Images"); 78 | 79 | // push hình vào phone 80 | var imgDir = new DirectoryInfo(@"C:\images"); 81 | var files = imgDir.GetFiles().Select(x => x.FullName); 82 | 83 | foreach (var item in files) 84 | { 85 | ADBHelper.ExecuteCMD($"adb -s {deviceID} push {item} sdcard/Pictures/Images"); 86 | } 87 | } 88 | 89 | public static string ExecuteCMD(string cmdCommand) 90 | { 91 | try 92 | { 93 | Process cmd = new Process(); 94 | 95 | ProcessStartInfo startInfo = new ProcessStartInfo(); 96 | startInfo.WorkingDirectory = ADB_FOLDER_PATH; 97 | startInfo.FileName = "cmd.exe"; 98 | startInfo.CreateNoWindow = true; 99 | startInfo.UseShellExecute = false; 100 | startInfo.WindowStyle = ProcessWindowStyle.Hidden; 101 | startInfo.RedirectStandardInput = true; 102 | startInfo.RedirectStandardOutput = true; 103 | startInfo.Verb = "runas"; 104 | 105 | cmd.StartInfo = startInfo; 106 | cmd.Start(); 107 | 108 | cmd.StandardInput.WriteLine(cmdCommand); 109 | cmd.StandardInput.Flush(); 110 | cmd.StandardInput.Close(); 111 | cmd.WaitForExit(); 112 | 113 | string result = cmd.StandardOutput.ReadToEnd(); 114 | return result; 115 | } 116 | catch 117 | { 118 | return null; 119 | } 120 | } 121 | public static string ExecuteCMDBat(string deviceID, string cmdCommand) 122 | { 123 | try 124 | { 125 | string batName = $"bat_{deviceID}.bat"; 126 | File.WriteAllText(batName, cmdCommand); 127 | 128 | Process cmd = new Process(); 129 | ProcessStartInfo startInfo = new ProcessStartInfo(); 130 | startInfo.WorkingDirectory = ADB_FOLDER_PATH; 131 | startInfo.FileName = batName; 132 | startInfo.CreateNoWindow = true; 133 | startInfo.UseShellExecute = false; 134 | startInfo.WindowStyle = ProcessWindowStyle.Hidden; 135 | startInfo.RedirectStandardInput = true; 136 | startInfo.RedirectStandardOutput = true; 137 | startInfo.Verb = "runas"; 138 | 139 | cmd.StartInfo = startInfo; 140 | cmd.Start(); 141 | 142 | 143 | cmd.StandardInput.WriteLine(cmdCommand); 144 | cmd.StandardInput.Flush(); 145 | cmd.StandardInput.Close(); 146 | cmd.WaitForExit(); 147 | 148 | string result = cmd.StandardOutput.ReadToEnd(); 149 | return result; 150 | } 151 | catch 152 | { 153 | return null; 154 | } 155 | } 156 | public static List GetDevices() 157 | { 158 | List ListDevices = new List(); 159 | string input = KAutoHelper.ADBHelper.ExecuteCMD("adb devices"); 160 | 161 | string pattern = @"(?<=List of devices attached)([^\n]*\n+)+"; 162 | 163 | MatchCollection matchCollection = Regex.Matches(input, pattern, RegexOptions.Singleline); 164 | 165 | if (matchCollection.Count > 0) 166 | { 167 | string AllDevices = matchCollection[0].Groups[0].Value; 168 | string[] lines = Regex.Split(AllDevices, "\r\n"); 169 | 170 | foreach (var device in lines) 171 | { 172 | if (!string.IsNullOrEmpty(device) && device != " ") 173 | { 174 | var temp = device.Trim().Split('\t'); 175 | 176 | string devices = temp[0]; 177 | string state = ""; 178 | 179 | try 180 | { 181 | state = temp[1]; 182 | if(state != "device") 183 | { 184 | continue; 185 | } 186 | } 187 | catch { } 188 | ListDevices.Add(devices.Trim()); 189 | } 190 | } 191 | } 192 | 193 | return ListDevices; 194 | } 195 | 196 | //public static List GetDevices() 197 | //{ 198 | // List devices = new List(); 199 | 200 | // string result = ExecuteCMD(LIST_DEVICES); 201 | 202 | // string path = Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory); 203 | // path = path.Replace("\\", ""); 204 | // string pattern = @"(?<=List of devices attached ).*?(?=" + path + ")"; 205 | // var mathces = Regex.Matches(result, pattern, RegexOptions.Singleline); 206 | 207 | // if (mathces != null && mathces.Count > 0) 208 | // { 209 | // foreach (var item in mathces) 210 | // { 211 | // string temp = item.ToString(); 212 | 213 | // var temp2 = temp.Split(new string[] { "device" }, StringSplitOptions.None); 214 | 215 | // for (int i = 0; i < temp2.Length - 1; i++) 216 | // { 217 | // var item2 = temp2[i]; 218 | // var temp3 = item2.Replace("\r", "").Replace("\n", "").Replace("\t", ""); 219 | 220 | // devices.Add(temp3); 221 | // } 222 | // } 223 | // } 224 | 225 | // return devices; 226 | //} 227 | 228 | public static string GetDeviceName(string deviceID) 229 | { 230 | string name = ""; 231 | 232 | string cmd = ""; 233 | var res = ExecuteCMD(cmd); 234 | 235 | return name; 236 | } 237 | 238 | public static void TapByPercent(string deviceID, double x, double y, int count = 1) 239 | { 240 | var resolution = GetScreenResolution(deviceID); 241 | 242 | int X = (int)(x *( resolution.X*1.0/100)); 243 | int Y = (int)(y * (resolution.Y*1.0/100)); 244 | 245 | if(X < 0 || Y < 0) 246 | { 247 | Console.WriteLine($"Out of resolutions {X},{Y}"); 248 | return; 249 | } 250 | 251 | string cmdCommand = string.Format(TAP_DEVICES, deviceID, X, Y); 252 | 253 | for (int i = 1; i < count; i++) 254 | { 255 | cmdCommand += " && " + string.Format(TAP_DEVICES, deviceID, x, y); 256 | } 257 | 258 | string result = ExecuteCMD(cmdCommand); 259 | } 260 | 261 | public static void Tap(string deviceID, int x, int y, int count = 1) 262 | { 263 | string cmdCommand = string.Format(TAP_DEVICES, deviceID, x, y); 264 | 265 | for (int i = 1; i < count; i++) 266 | { 267 | cmdCommand += " && "+ string.Format(TAP_DEVICES, deviceID, x, y); 268 | } 269 | 270 | string result = ExecuteCMD(cmdCommand); 271 | } 272 | 273 | public static void Key(string deviceID, ADBKeyEvent key) 274 | { 275 | string cmdCommand = string.Format(KEY_DEVICES, deviceID, key); 276 | string result = ExecuteCMD(cmdCommand); 277 | } 278 | 279 | public static void InputText(string deviceID, string text) 280 | { 281 | string cmdCommand = string.Format(INPUT_TEXT_DEVICES, deviceID, text/*.Replace(" ", "%s")*/.Replace("&","\\&").Replace("<", "\\<").Replace(">", "\\>").Replace("?", "\\?").Replace(":", "\\:").Replace("{", "\\{").Replace("}", "\\}").Replace("[", "\\[").Replace("]", "\\]").Replace("|", "\\|")); 282 | string result = ExecuteCMD(cmdCommand); 283 | } 284 | 285 | public static void SwipeByPercent(string deviceID, double x1, double y1, double x2, double y2, int duration = DEFAULT_SWIPE_DURATION) 286 | { 287 | var resolution = GetScreenResolution(deviceID); 288 | 289 | int X1 = (int)(x1 * (resolution.X * 1.0 / 100)); 290 | int Y1 = (int)(y1 * (resolution.Y * 1.0 / 100)); 291 | int X2 = (int)(x2 * (resolution.X * 1.0 / 100)); 292 | int Y2 = (int)(y2 * (resolution.Y * 1.0 / 100)); 293 | 294 | string cmdCommand = string.Format(SWIPE_DEVICES, deviceID, X1, Y1, X2, Y2, duration); 295 | string result = ExecuteCMD(cmdCommand); 296 | } 297 | 298 | public static void Swipe(string deviceID, int x1, int y1, int x2, int y2, int duration = DEFAULT_SWIPE_DURATION) 299 | { 300 | string cmdCommand = string.Format(SWIPE_DEVICES, deviceID, x1, y1, x2, y2, duration); 301 | string result = ExecuteCMD(cmdCommand); 302 | } 303 | 304 | public static void LongPress(string deviceID, int x, int y, int duration = DEFAULT_SWIPE_DURATION) 305 | { 306 | string cmdCommand = string.Format(SWIPE_DEVICES, deviceID, x, y, x, y, duration); 307 | string result = ExecuteCMD(cmdCommand); 308 | } 309 | 310 | public static System.Drawing.Point GetScreenResolution(string deviceID) 311 | { 312 | string cmdCommand = string.Format(GET_SCREEN_RESOLUTION, deviceID); 313 | string result = ExecuteCMD(cmdCommand); 314 | 315 | result = result.Substring(result.IndexOf("- ")); 316 | result = result.Substring(result.IndexOf(' '), result.IndexOf(')') - result.IndexOf(' ')); 317 | string[] temp = result.Split(','); 318 | 319 | int x =Convert.ToInt32(temp[0].Trim()); 320 | int y = Convert.ToInt32(temp[1].Trim()); 321 | 322 | return new System.Drawing.Point(x,y); 323 | } 324 | 325 | /// 326 | /// Mặc định capture thiết bị đầu tiên nếu k truyền vào deviceID 327 | /// return null nếu không có thiết bị hoặc chụp lỗi 328 | /// 329 | /// 330 | /// 331 | /// 332 | public static Bitmap ScreenShoot(string deviceID = null, bool isDeleteImageAfterCapture = true, string fileName = "screenShoot.png") 333 | { 334 | bool flag = string.IsNullOrEmpty(deviceID); 335 | if (flag) 336 | { 337 | List listDevice = KAutoHelper.ADBHelper.GetDevices(); 338 | bool flag2 = listDevice != null && listDevice.Count > 0; 339 | if (!flag2) 340 | { 341 | return null; 342 | } 343 | deviceID = listDevice.First(); 344 | } 345 | string screenShotCount = deviceID; 346 | try 347 | { 348 | screenShotCount = deviceID.Split(new char[] 349 | { 350 | ':' 351 | })[1]; 352 | } 353 | catch 354 | { 355 | } 356 | string nameToSave = Path.GetFileNameWithoutExtension(fileName) + screenShotCount + Path.GetExtension(fileName); 357 | for (; ; ) 358 | { 359 | bool flag3 = File.Exists(nameToSave); 360 | if (!flag3) 361 | { 362 | break; 363 | } 364 | try 365 | { 366 | File.Delete(nameToSave); 367 | break; 368 | } 369 | catch (Exception ex) 370 | { 371 | break; 372 | } 373 | } 374 | string Current = Directory.GetCurrentDirectory() + "\\" + nameToSave; 375 | string CurrentPath = Directory.GetCurrentDirectory().Replace(@"\\", @"\"); 376 | CurrentPath = "\"" + CurrentPath + "\""; 377 | 378 | string cmdCommand1 = string.Format("adb -s {0} shell screencap -p \"{1}\"", deviceID, "/sdcard/" + nameToSave); 379 | string cmdCommand2 = string.Format("adb -s " + deviceID + " pull " + "/sdcard/" + nameToSave + " " + CurrentPath); 380 | string result1 = KAutoHelper.ADBHelper.ExecuteCMD(cmdCommand1); 381 | string result2 = KAutoHelper.ADBHelper.ExecuteCMD(cmdCommand2); 382 | 383 | Bitmap result = null; 384 | try 385 | { 386 | using (Bitmap bitmap = new Bitmap(Current)) 387 | { 388 | result = new Bitmap(bitmap); 389 | } 390 | } 391 | catch { } 392 | if (isDeleteImageAfterCapture) 393 | { 394 | try 395 | { 396 | File.Delete(nameToSave); 397 | } 398 | catch 399 | { 400 | } 401 | try 402 | { 403 | string cmdCommand3 = string.Format("adb -s " + deviceID + " shell \"rm " + "/sdcard/" + nameToSave + "\""); 404 | string result3 = KAutoHelper.ADBHelper.ExecuteCMD(cmdCommand3); 405 | } 406 | catch { } 407 | } 408 | return result; 409 | } 410 | //public static System.Drawing.Bitmap ScreenShoot(string deviceID = null, bool isDeleteImageAfterCapture = true, string fileName = "screenShoot.png") 411 | //{ 412 | // if (string.IsNullOrEmpty(deviceID)) 413 | // { 414 | // var listDevice = GetDevices(); 415 | // if (listDevice != null && listDevice.Count > 0) 416 | // { 417 | // deviceID = listDevice.First(); 418 | // } 419 | // else 420 | // { 421 | // return null; 422 | // } 423 | // } 424 | 425 | // string screenShotCount = deviceID; 426 | // try 427 | // { 428 | // screenShotCount = deviceID.Split(':')[1]; 429 | // } 430 | // catch { } 431 | 432 | 433 | // string nameToSave = Path.GetFileNameWithoutExtension(fileName) + screenShotCount + Path.GetExtension(fileName); 434 | // while (true) 435 | // { 436 | // if (File.Exists(nameToSave)) 437 | // { 438 | // try 439 | // { 440 | // File.Delete(nameToSave); 441 | // break; 442 | // } 443 | // catch 444 | // { 445 | 446 | // } 447 | // } 448 | // else 449 | // { 450 | // break; 451 | // } 452 | // } 453 | 454 | 455 | // string cmdCommand = string.Format(CAPTURE_SCREEN_TO_DEVICES, deviceID, "/sdcard/" + nameToSave); 456 | 457 | // cmdCommand += Environment.NewLine + string.Format(PULL_SCREEN_FROM_DEVICES, deviceID, "/sdcard/" + nameToSave); 458 | // cmdCommand += Environment.NewLine + string.Format(REMOVE_SCREEN_FROM_DEVICES, deviceID, "/sdcard/" + nameToSave) + Environment.NewLine; 459 | // string result = ExecuteCMD(cmdCommand); 460 | // Bitmap cloneBMP; 461 | 462 | // using (System.Drawing.Bitmap bmp = new Bitmap(nameToSave)) 463 | // { 464 | // cloneBMP = new Bitmap(bmp); 465 | // } 466 | 467 | // if (isDeleteImageAfterCapture) 468 | // { 469 | // try 470 | // { 471 | // File.Delete(nameToSave); 472 | // } 473 | // catch 474 | // { 475 | // } 476 | // } 477 | 478 | // return cloneBMP; 479 | //} 480 | 481 | 482 | 483 | public static void ConnectNox(int count = 1) 484 | { 485 | //ADBHelper.ExecuteCMD("adb shell su -c \"/dir > /dev/null 2> /dev/null < /dev/null &\""); 486 | 487 | string connectNoxCMD = ""; 488 | int noxPort = 62000; 489 | 490 | if (count <= 1) 491 | { 492 | connectNoxCMD += "adb connect 127.0.0.1:" + (noxPort + 1); 493 | } 494 | else 495 | { 496 | connectNoxCMD += "adb connect 127.0.0.1:" + (noxPort + 1); 497 | for (int i = 25; i < count + 24; i++) 498 | { 499 | connectNoxCMD += Environment.NewLine + "adb connect 127.0.0.1:" + (noxPort + i); 500 | } 501 | } 502 | 503 | 504 | ADBHelper.ExecuteCMD(connectNoxCMD); 505 | //Delay(2000); 506 | } 507 | 508 | public static void PlanModeON(string deviceID, CancellationToken cancellationToken) 509 | { 510 | if (cancellationToken.IsCancellationRequested) 511 | { 512 | return; 513 | } 514 | // //adb shell settings put global airplane_mode_on 1 515 | string cmdClearShoppe = "adb -s " + deviceID + " settings put global airplane_mode_on 1"; 516 | cmdClearShoppe += Environment.NewLine + "adb -s " + deviceID + " am broadcast -a android.intent.action.AIRPLANE_MODE"; 517 | ADBHelper.ExecuteCMD(cmdClearShoppe); 518 | } 519 | 520 | public static void PlanModeOFF(string deviceID, CancellationToken cancellationToken) 521 | { 522 | if (cancellationToken.IsCancellationRequested) 523 | { 524 | return; 525 | } 526 | 527 | string cmdClearShoppe = "adb -s " + deviceID + " settings put global airplane_mode_on 0"; 528 | cmdClearShoppe += Environment.NewLine + "adb -s " + deviceID + " am broadcast -a android.intent.action.AIRPLANE_MODE"; 529 | ADBHelper.ExecuteCMD(cmdClearShoppe); 530 | } 531 | 532 | public static void Delay(double delayTime) 533 | { 534 | double count = 0; 535 | while (count < delayTime) 536 | { 537 | Thread.Sleep(TimeSpan.FromMilliseconds(100)); 538 | count += 100; 539 | } 540 | } 541 | 542 | /// 543 | /// Tìm hình trong hình 544 | /// thử 3 lần liên tục 545 | /// Nếu không tìm thấy trả về null 546 | /// 547 | /// 548 | /// 549 | /// 550 | /// 551 | /// 552 | public static System.Drawing.Point? FindImage(string deviceID, string ImagePath, int delayPerCheck = 2000, int count = 5) 553 | { 554 | 555 | DirectoryInfo dir = new DirectoryInfo(ImagePath); 556 | var icons = dir.GetFiles(); 557 | do 558 | { 559 | Bitmap screen = null; 560 | int countScreenShot = 3; 561 | do 562 | { 563 | try 564 | { 565 | screen = KAutoHelper.ADBHelper.ScreenShoot(deviceID); 566 | break; 567 | } 568 | catch (Exception ex) 569 | { 570 | //Utilities.WriteLogFile(ex.Message); 571 | countScreenShot--; 572 | Delay(1000); 573 | } 574 | } 575 | while (countScreenShot > 0); 576 | 577 | if (screen == null) 578 | { 579 | return null; 580 | } 581 | 582 | System.Drawing.Point? point = null; 583 | foreach (var item in icons) 584 | { 585 | Bitmap icon = (Bitmap)Bitmap.FromFile(item.FullName); 586 | point = KAutoHelper.ImageScanOpenCV.FindOutPoint(screen, icon); 587 | if (point != null) 588 | break; 589 | } 590 | 591 | if (point != null) 592 | { 593 | return point; 594 | } 595 | else 596 | { 597 | Delay(2000); 598 | } 599 | 600 | count--; 601 | } 602 | while (count > 0); 603 | 604 | return null; 605 | } 606 | 607 | /// 608 | /// Tìm và click vào hình theo tọa độ hình đã tìm được 609 | /// Nếu không tìm thấy thì thôi 610 | /// Thử 3 lần liên tục 611 | /// 612 | /// 613 | /// 614 | /// 615 | /// 616 | /// 617 | public static bool FindImageAndClick(string deviceID, string ImagePath, int delayPerCheck = 2000, int count = 5) 618 | { 619 | DirectoryInfo dir = new DirectoryInfo(ImagePath); 620 | var icons = dir.GetFiles(); 621 | do 622 | { 623 | Bitmap screen = null; 624 | int countScreenShot = 3; 625 | do 626 | { 627 | try 628 | { 629 | screen = KAutoHelper.ADBHelper.ScreenShoot(deviceID); 630 | break; 631 | } 632 | catch (Exception ex) 633 | { 634 | //Utilities.WriteLogFile(ex.Message); 635 | countScreenShot--; 636 | Delay(1000); 637 | } 638 | } 639 | while (countScreenShot > 0); 640 | 641 | if (screen == null) 642 | { 643 | return false; 644 | } 645 | 646 | System.Drawing.Point? point = null; 647 | foreach (var item in icons) 648 | { 649 | Bitmap icon = (Bitmap)Bitmap.FromFile(item.FullName); 650 | point = KAutoHelper.ImageScanOpenCV.FindOutPoint(screen, icon); 651 | if (point != null) 652 | break; 653 | } 654 | 655 | if (point != null) 656 | { 657 | KAutoHelper.ADBHelper.Tap(deviceID, point.Value.X, point.Value.Y); 658 | return true; 659 | } 660 | else 661 | { 662 | Delay(delayPerCheck); 663 | } 664 | 665 | count--; 666 | } 667 | while (count > 0); 668 | 669 | return false; 670 | } 671 | } 672 | 673 | 674 | public static class BitmapConversion 675 | { 676 | public static BitmapSource BitmapToBitmapSource(Bitmap source) 677 | { 678 | if (source == null) 679 | return null; 680 | return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( 681 | source.GetHbitmap(), 682 | IntPtr.Zero, 683 | Int32Rect.Empty, 684 | BitmapSizeOptions.FromEmptyOptions()); 685 | } 686 | } 687 | 688 | public enum ADBKeyEvent : int 689 | { 690 | KEYCODE_0 = 0, 691 | KEYCODE_SOFT_LEFT, 692 | KEYCODE_SOFT_RIGHT, 693 | KEYCODE_HOME, 694 | KEYCODE_BACK, 695 | KEYCODE_CALL, 696 | KEYCODE_ENDCALL, 697 | KEYCODE_0_, 698 | KEYCODE_1, 699 | KEYCODE_2, 700 | KEYCODE_3, 701 | KEYCODE_4, 702 | KEYCODE_5, 703 | KEYCODE_6, 704 | KEYCODE_7, 705 | KEYCODE_8, 706 | KEYCODE_9, 707 | KEYCODE_STAR, 708 | KEYCODE_POUND, 709 | KEYCODE_DPAD_UP, 710 | KEYCODE_DPAD_DOWN, 711 | KEYCODE_DPAD_LEFT, 712 | KEYCODE_DPAD_RIGHT, 713 | KEYCODE_DPAD_CENTER, 714 | KEYCODE_VOLUME_UP, 715 | KEYCODE_VOLUME_DOWN, 716 | KEYCODE_POWER, 717 | KEYCODE_CAMERA, 718 | KEYCODE_CLEAR, 719 | KEYCODE_A, 720 | KEYCODE_B, 721 | KEYCODE_C, 722 | KEYCODE_D, 723 | KEYCODE_E, 724 | KEYCODE_F, 725 | KEYCODE_G, 726 | KEYCODE_H, 727 | KEYCODE_I, 728 | KEYCODE_J, 729 | KEYCODE_K, 730 | KEYCODE_L, 731 | KEYCODE_M, 732 | KEYCODE_N, 733 | KEYCODE_O, 734 | KEYCODE_P, 735 | KEYCODE_Q, 736 | KEYCODE_R, 737 | KEYCODE_S, 738 | KEYCODE_T, 739 | KEYCODE_U, 740 | KEYCODE_V, 741 | KEYCODE_W, 742 | KEYCODE_X, 743 | KEYCODE_Y, 744 | KEYCODE_Z, 745 | KEYCODE_COMMA, 746 | KEYCODE_PERIOD, 747 | KEYCODE_ALT_LEFT, 748 | KEYCODE_ALT_RIGHT, 749 | KEYCODE_SHIFT_LEFT, 750 | KEYCODE_SHIFT_RIGHT, 751 | KEYCODE_TAB, 752 | KEYCODE_SPACE, 753 | KEYCODE_SYM, 754 | KEYCODE_EXPLORER, 755 | KEYCODE_ENVELOPE, 756 | KEYCODE_ENTER, 757 | KEYCODE_DEL, 758 | KEYCODE_GRAVE, 759 | KEYCODE_MINUS, 760 | KEYCODE_EQUALS, 761 | KEYCODE_LEFT_BRACKET, 762 | KEYCODE_RIGHT_BRACKET, 763 | KEYCODE_BACKSLASH, 764 | KEYCODE_SEMICOLON, 765 | KEYCODE_APOSTROPHE, 766 | KEYCODE_SLASH, 767 | KEYCODE_AT, 768 | KEYCODE_NUM, 769 | KEYCODE_HEADSETHOOK, 770 | KEYCODE_FOCUS, 771 | KEYCODE_PLUS, 772 | KEYCODE_MENU, 773 | KEYCODE_NOTIFICATION, 774 | KEYCODE_APP_SWITCH = 187 775 | } 776 | 777 | 778 | public class NoxMultiIni 779 | { 780 | public int pid { get; set; } 781 | public int vmpid { get; set; } 782 | private static List Ports { get; set; } 783 | 784 | public static List GetNoxMultiIni() 785 | { 786 | List multi = new List(); 787 | 788 | string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName; 789 | 790 | var data = File.ReadAllLines(path + "\\Local\\Nox\\multi.ini"); 791 | 792 | for (int i = 0; i < data.Length; i += 4) 793 | { 794 | NoxMultiIni nox = new NoxMultiIni(); 795 | nox.pid = Convert.ToInt32(data[i + 1].Split('=')[1]); 796 | nox.vmpid = Convert.ToInt32(data[i + 2].Split('=')[1]); 797 | multi.Add(nox); 798 | } 799 | 800 | return multi; 801 | } 802 | 803 | public static string GetNoxTitleFromADBPort(string port) 804 | { 805 | Ports = ProcessHelper.GetNetStatPorts(); 806 | var multiNox = NoxMultiIni.GetNoxMultiIni(); 807 | var abc = Ports.Where(p => p.port_number == port).FirstOrDefault(); 808 | var pid = multiNox.Where(p => p.vmpid == abc.pid).FirstOrDefault(); 809 | var nox = Process.GetProcessById(pid.pid); 810 | return nox.MainWindowTitle; 811 | } 812 | } 813 | } 814 | -------------------------------------------------------------------------------- /src/AutoClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace KAutoHelper 9 | { 10 | public class AutoClient 11 | { 12 | public static int cmd_start = 1000; 13 | public static int cmd_end = 1001; 14 | public static int cmd_push = 1002; 15 | public const int cmd_sendchar = 1003; 16 | 17 | public IntPtr WindowHwnd; 18 | public uint processId; 19 | public uint HookMsg; 20 | public void Attach(IntPtr hwnd) 21 | { 22 | this.WindowHwnd = hwnd; 23 | MemoryHelper.GetWindowThreadProcessId(WindowHwnd, out processId); 24 | MemoryHelper.OpenProcess(processId); 25 | } 26 | 27 | // Thủ tục định nghĩa chưa Inject hook 28 | private bool _isInjected = false; 29 | 30 | // Thủ tục định nghĩa chưa Inject hook 31 | public bool isInjected 32 | { 33 | get { return _isInjected; } 34 | } 35 | 36 | // Thủ tục Inject hook 37 | public int Inject() 38 | { 39 | var result = HookGame.InjectDll(WindowHwnd); 40 | if (result == 1) 41 | { 42 | _isInjected = true; 43 | this.HookMsg = HookGame.GetMsg(); 44 | } 45 | return result; 46 | } 47 | 48 | // Thủ tục DeInject hook 49 | public int DeInject() 50 | { 51 | var result = HookGame.UnmapDll(WindowHwnd); 52 | _isInjected = false; 53 | return result; 54 | } 55 | } 56 | 57 | public static class HookGame 58 | { 59 | [DllImport("khook.dll", SetLastError = true)] 60 | public static extern Int32 InjectDll(IntPtr gameHwnd); 61 | [DllImport("khook.dll", SetLastError = true)] 62 | public static extern Int32 UnmapDll(IntPtr gameHwnd); 63 | [DllImport("khook.dll", SetLastError = true)] 64 | public static extern UInt32 GetMsg(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/CaptureHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Drawing.Imaging; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace KAutoHelper 11 | { 12 | public class CaptureHelper 13 | { 14 | /// 15 | /// Creates an Image object containing a screen shot of the entire desktop 16 | /// 17 | /// 18 | public static Image CaptureScreen() 19 | { 20 | return CaptureWindow(User32.GetDesktopWindow()); 21 | } 22 | /// 23 | /// Creates an Image object containing a screen shot of a specific window 24 | /// 25 | /// The handle to the window. (In windows forms, this is obtained by the Handle property) 26 | /// 27 | public static Image CaptureWindow(IntPtr handle) 28 | { 29 | // get te hDC of the target window 30 | IntPtr hdcSrc = User32.GetWindowDC(handle); 31 | // get the size 32 | User32.RECT windowRect = new User32.RECT(); 33 | User32.GetWindowRect(handle, ref windowRect); 34 | int width = windowRect.right - windowRect.left; 35 | int height = windowRect.bottom - windowRect.top; 36 | // create a device context we can copy to 37 | IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc); 38 | // create a bitmap we can copy it to, 39 | // using GetDeviceCaps to get the width/height 40 | IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height); 41 | // select the bitmap object 42 | IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap); 43 | // bitblt over 44 | GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY); 45 | // restore selection 46 | GDI32.SelectObject(hdcDest, hOld); 47 | // clean up 48 | GDI32.DeleteDC(hdcDest); 49 | User32.ReleaseDC(handle, hdcSrc); 50 | // get a .NET image object for it 51 | Image img = Image.FromHbitmap(hBitmap); 52 | // free up the Bitmap object 53 | GDI32.DeleteObject(hBitmap); 54 | return img; 55 | } 56 | 57 | 58 | /// 59 | /// Phóng to thu nhỏ hình theo zoomin 60 | /// 61 | /// 62 | /// 63 | /// 64 | public static System.Drawing.Bitmap ScaleImage(System.Drawing.Image a, double zoomin) 65 | { 66 | double scale = zoomin; 67 | try 68 | { 69 | var b = ResizeImage(a, a.Size.Width + (int)(a.Size.Width * scale), a.Size.Height + (int)(a.Size.Height * scale)); 70 | //b.Save("ab2.png"); 71 | return b; 72 | } 73 | catch (Exception ee) 74 | { 75 | return null; 76 | } 77 | } 78 | 79 | public static System.Drawing.Bitmap ResizeImage(System.Drawing.Image image, int width, int height) 80 | { 81 | var destRect = new System.Drawing.Rectangle(0, 0, width, height); 82 | var destImage = new System.Drawing.Bitmap(width, height); 83 | 84 | destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); 85 | 86 | using (var graphics = System.Drawing.Graphics.FromImage(destImage)) 87 | { 88 | graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; 89 | graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; 90 | graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; 91 | graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; 92 | graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; 93 | 94 | using (var wrapMode = new System.Drawing.Imaging.ImageAttributes()) 95 | { 96 | wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY); 97 | graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, System.Drawing.GraphicsUnit.Pixel, wrapMode); 98 | } 99 | } 100 | 101 | return destImage; 102 | } 103 | 104 | /// 105 | /// Captures a screen shot of a specific window, and saves it to a file 106 | /// 107 | /// 108 | /// 109 | /// 110 | public static void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format) 111 | { 112 | Image img = CaptureWindow(handle); 113 | img.Save(filename, format); 114 | } 115 | /// 116 | /// Captures a screen shot of the entire desktop, and saves it to a file 117 | /// 118 | /// 119 | /// 120 | public static void CaptureScreenToFile(string filename, ImageFormat format) 121 | { 122 | Image img = CaptureScreen(); 123 | img.Save(filename, format); 124 | } 125 | 126 | public static int X = 0; 127 | public static int Y = 0; 128 | public static Bitmap CaptureImage(System.Drawing.Size size, System.Drawing.Point position) 129 | { 130 | try 131 | { 132 | //Create a new bitmap. 133 | var bmpScreenshot = new Bitmap(size.Width, 134 | size.Height, 135 | System.Drawing.Imaging.PixelFormat.Format32bppRgb); 136 | 137 | // Create a graphics object from the bitmap. 138 | var gfxScreenshot = Graphics.FromImage(bmpScreenshot); 139 | 140 | // Take the screenshot from the upper left corner to the right bottom corner. 141 | gfxScreenshot.CopyFromScreen(position.X + X, position.Y + Y, 0, 0, 142 | size, 143 | CopyPixelOperation.SourceCopy); 144 | 145 | return bmpScreenshot; 146 | } 147 | catch 148 | { 149 | return null; 150 | } 151 | } 152 | 153 | /// 154 | /// Helper class containing Gdi32 API functions 155 | /// 156 | private class GDI32 157 | { 158 | 159 | public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter 160 | [DllImport("gdi32.dll")] 161 | public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, 162 | int nWidth, int nHeight, IntPtr hObjectSource, 163 | int nXSrc, int nYSrc, int dwRop); 164 | [DllImport("gdi32.dll")] 165 | public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, 166 | int nHeight); 167 | [DllImport("gdi32.dll")] 168 | public static extern IntPtr CreateCompatibleDC(IntPtr hDC); 169 | [DllImport("gdi32.dll")] 170 | public static extern bool DeleteDC(IntPtr hDC); 171 | [DllImport("gdi32.dll")] 172 | public static extern bool DeleteObject(IntPtr hObject); 173 | [DllImport("gdi32.dll")] 174 | public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); 175 | } 176 | 177 | /// 178 | /// Helper class containing User32 API functions 179 | /// 180 | private class User32 181 | { 182 | [StructLayout(LayoutKind.Sequential)] 183 | public struct RECT 184 | { 185 | public int left; 186 | public int top; 187 | public int right; 188 | public int bottom; 189 | } 190 | [DllImport("user32.dll")] 191 | public static extern IntPtr GetDesktopWindow(); 192 | [DllImport("user32.dll")] 193 | public static extern IntPtr GetWindowDC(IntPtr hWnd); 194 | [DllImport("user32.dll")] 195 | public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC); 196 | [DllImport("user32.dll")] 197 | public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect); 198 | } 199 | 200 | [DllImport("gdi32.dll", EntryPoint = "DeleteObject")] 201 | [return: MarshalAs(UnmanagedType.Bool)] 202 | public static extern bool DeleteObject([In] IntPtr hObject); 203 | 204 | public static Bitmap CropImage(Image img, Rectangle cropRect) 205 | { 206 | Bitmap src = img as Bitmap; 207 | Bitmap target = new Bitmap(cropRect.Width, cropRect.Height); 208 | 209 | using (Graphics g = Graphics.FromImage(target)) 210 | { 211 | g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), 212 | cropRect, 213 | GraphicsUnit.Pixel); 214 | } 215 | 216 | return target; 217 | } 218 | 219 | public static Bitmap CropImage(Bitmap img, Rectangle cropRect) 220 | { 221 | Bitmap src = img; 222 | Bitmap target = new Bitmap(cropRect.Width, cropRect.Height); 223 | 224 | using (Graphics g = Graphics.FromImage(target)) 225 | { 226 | g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), 227 | cropRect, 228 | GraphicsUnit.Pixel); 229 | } 230 | 231 | return target; 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /src/EnumHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace KAutoHelper 9 | { 10 | ///summary> 11 | /// Virtual Messages 12 | /// 13 | public enum WMessages : int 14 | { 15 | WM_LBUTTONDOWN = 0x201, //Left mousebutton down 16 | WM_LBUTTONUP = 0x202, //Left mousebutton up 17 | WM_LBUTTONDBLCLK = 0x203, //Left mousebutton doubleclick 18 | WM_RBUTTONDOWN = 0x204, //Right mousebutton down 19 | WM_RBUTTONUP = 0x205, //Right mousebutton up 20 | WM_RBUTTONDBLCLK = 0x206, //Right mousebutton doubleclick 21 | WM_KEYDOWN = 0x100, //Key down 22 | WM_KEYUP = 0x101, //Key up 23 | BN_CLICKED = 0, // click mouse button 24 | WM_COMMAND = 0x0111, //command to handle 25 | WM_SETTEXT = 0x000c, 26 | WM_CHAR = 0x0102, 27 | BM_CLICK = 0x00F5, 28 | WM_SYSKEYDOWN = 0x0104, 29 | WM_SYSKEYUP = 0x0105, 30 | WM_MOUSEMOVE = 0x0200, 31 | WM_ACTIVATE = 0x0006 32 | } 33 | 34 | /// 35 | /// Virtual Keys 36 | /// 37 | public enum VKeys : int 38 | { 39 | VK_A_Cong = 0x40, 40 | VK_LBUTTON = 0x01, //Left mouse button 41 | VK_RBUTTON = 0x02, //Right mouse button 42 | VK_CANCEL = 0x03, //Control-break processing 43 | VK_MBUTTON = 0x04, //Middle mouse button (three-button mouse) 44 | VK_BACK = 0x08, //BACKSPACE key 45 | VK_TAB = 0x09, //TAB key 46 | VK_CLEAR = 0x0C, //CLEAR key 47 | VK_RETURN = 0x0D, //ENTER key 48 | VK_SHIFT = 0x10, //SHIFT key 49 | VK_CONTROL = 0x11, //CTRL key 50 | VK_MENU = 0x12, //ALT key 51 | VK_PAUSE = 0x13, //PAUSE key 52 | VK_CAPITAL = 0x14, //CAPS LOCK key 53 | VK_ESCAPE = 0x1B, //ESC key 54 | VK_SPACE = 0x20, //SPACEBAR 55 | VK_PRIOR = 0x21, //PAGE UP key 56 | VK_NEXT = 0x22, //PAGE DOWN key 57 | VK_END = 0x23, //END key 58 | VK_HOME = 0x24, //HOME key 59 | VK_LEFT = 0x25, //LEFT ARROW key 60 | VK_UP = 0x26, //UP ARROW key 61 | VK_RIGHT = 0x27, //RIGHT ARROW key 62 | VK_DOWN = 0x28, //DOWN ARROW key 63 | VK_SELECT = 0x29, //SELECT key 64 | VK_PRINT = 0x2A, //PRINT key 65 | VK_EXECUTE = 0x2B, //EXECUTE key 66 | VK_SNAPSHOT = 0x2C, //PRINT SCREEN key 67 | VK_INSERT = 0x2D, //INS key 68 | VK_DELETE = 0x2E, //DEL key 69 | VK_HELP = 0x2F, //HELP key 70 | VK_0 = 0x30, //0 key 71 | VK_1 = 0x31, //1 key 72 | VK_2 = 0x32, //2 key 73 | VK_3 = 0x33, //3 key 74 | VK_4 = 0x34, //4 key 75 | VK_5 = 0x35, //5 key 76 | VK_6 = 0x36, //6 key 77 | VK_7 = 0x37, //7 key 78 | VK_8 = 0x38, //8 key 79 | VK_9 = 0x39, //9 key 80 | VK_A = 0x41, //A key 81 | VK_B = 0x42, //B key 82 | VK_C = 0x43, //C key 83 | VK_D = 0x44, //D key 84 | VK_E = 0x45, //E key 85 | VK_F = 0x46, //F key 86 | VK_G = 0x47, //G key 87 | VK_H = 0x48, //H key 88 | VK_I = 0x49, //I key 89 | VK_J = 0x4A, //J key 90 | VK_K = 0x4B, //K key 91 | VK_L = 0x4C, //L key 92 | VK_M = 0x4D, //M key 93 | VK_N = 0x4E, //N key 94 | VK_O = 0x4F, //O key 95 | VK_P = 0x50, //P key 96 | VK_Q = 0x51, //Q key 97 | VK_R = 0x52, //R key 98 | VK_S = 0x53, //S key 99 | VK_T = 0x54, //T key 100 | VK_U = 0x55, //U key 101 | VK_V = 0x56, //V key 102 | VK_W = 0x57, //W key 103 | VK_X = 0x58, //X key 104 | VK_Y = 0x59, //Y key 105 | VK_Z = 0x5A, //Z key 106 | VK_NUMPAD0 = 0x60, //Numeric keypad 0 key 107 | VK_NUMPAD1 = 0x61, //Numeric keypad 1 key 108 | VK_NUMPAD2 = 0x62, //Numeric keypad 2 key 109 | VK_NUMPAD3 = 0x63, //Numeric keypad 3 key 110 | VK_NUMPAD4 = 0x64, //Numeric keypad 4 key 111 | VK_NUMPAD5 = 0x65, //Numeric keypad 5 key 112 | VK_NUMPAD6 = 0x66, //Numeric keypad 6 key 113 | VK_NUMPAD7 = 0x67, //Numeric keypad 7 key 114 | VK_NUMPAD8 = 0x68, //Numeric keypad 8 key 115 | VK_NUMPAD9 = 0x69, //Numeric keypad 9 key 116 | VK_SEPARATOR = 0x6C, //Separator key 117 | VK_SUBTRACT = 0x6D, //Subtract key 118 | VK_DECIMAL = 0x6E, //Decimal key 119 | VK_DIVIDE = 0x6F, //Divide key 120 | VK_F1 = 0x70, //F1 key 121 | VK_F2 = 0x71, //F2 key 122 | VK_F3 = 0x72, //F3 key 123 | VK_F4 = 0x73, //F4 key 124 | VK_F5 = 0x74, //F5 key 125 | VK_F6 = 0x75, //F6 key 126 | VK_F7 = 0x76, //F7 key 127 | VK_F8 = 0x77, //F8 key 128 | VK_F9 = 0x78, //F9 key 129 | VK_F10 = 0x79, //F10 key 130 | VK_F11 = 0x7A, //F11 key 131 | VK_F12 = 0x7B, //F12 key 132 | VK_SCROLL = 0x91, //SCROLL LOCK key 133 | VK_LSHIFT = 0xA0, //Left SHIFT key 134 | VK_RSHIFT = 0xA1, //Right SHIFT key 135 | VK_LCONTROL = 0xA2, //Left CONTROL key 136 | VK_RCONTROL = 0xA3, //Right CONTROL key 137 | VK_LMENU = 0xA4, //Left MENU key 138 | VK_RMENU = 0xA5, //Right MENU key 139 | VK_PLAY = 0xFA, //Play key 140 | VK_ZOOM = 0xFB, //Zoom key 141 | BM_CLICK = 0x00F5, // click 142 | VK_OEM_1 = 0xBA, // ;: 143 | VK_OEM_PLUS = 0xBB, // + 144 | VK_OEM_COMMA = 0xBC, // , 145 | VK_OEM_MINUS = 0xBD, // - 146 | VK_OEM_PERIOD = 0xBE, // . 147 | VK_OEM_2 = 0xBF, // /? 148 | VK_OEM_3 = 0xC0, // `~ 149 | VK_OEM_4 = 0xDB, // [{ 150 | VK_OEM_5 = 0xDC, // \| 151 | VK_OEM_6 = 0xDD, // ]} 152 | VK_OEM_7 = 0xDE, // '" 153 | VK_OEM_8 = 0xDF, // § ! 154 | 155 | } 156 | 157 | public enum EMouseKey 158 | { 159 | LEFT, 160 | RIGHT, 161 | DOUBLE_LEFT, 162 | DOUBLE_RIGHT 163 | } 164 | 165 | [StructLayout(LayoutKind.Sequential)] 166 | public struct RECT 167 | { 168 | public int Left; 169 | public int Top; 170 | public int Right; 171 | public int Bottom; 172 | } 173 | 174 | /// 175 | /// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx 176 | /// 177 | [StructLayout(LayoutKind.Sequential)] 178 | public struct INPUT 179 | { 180 | public uint Type; 181 | public MOUSEKEYBDHARDWAREINPUT Data; 182 | } 183 | 184 | /// 185 | /// http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/f0e82d6e-4999-4d22-b3d3-32b25f61fb2a 186 | /// 187 | [StructLayout(LayoutKind.Explicit)] 188 | public struct MOUSEKEYBDHARDWAREINPUT 189 | { 190 | [FieldOffset(0)] 191 | public HARDWAREINPUT Hardware; 192 | [FieldOffset(0)] 193 | public KEYBDINPUT Keyboard; 194 | [FieldOffset(0)] 195 | public MOUSEINPUT Mouse; 196 | } 197 | 198 | /// 199 | /// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx 200 | /// 201 | [StructLayout(LayoutKind.Sequential)] 202 | public struct HARDWAREINPUT 203 | { 204 | public uint Msg; 205 | public ushort ParamL; 206 | public ushort ParamH; 207 | } 208 | 209 | /// 210 | /// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx 211 | /// 212 | [StructLayout(LayoutKind.Sequential)] 213 | public struct KEYBDINPUT 214 | { 215 | public ushort Vk; 216 | public ushort Scan; 217 | public uint Flags; 218 | public uint Time; 219 | public IntPtr ExtraInfo; 220 | } 221 | 222 | /// 223 | /// http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/2abc6be8-c593-4686-93d2-89785232dacd 224 | /// 225 | [StructLayout(LayoutKind.Sequential)] 226 | public struct MOUSEINPUT 227 | { 228 | public int X; 229 | public int Y; 230 | public uint MouseData; 231 | public uint Flags; 232 | public uint Time; 233 | public IntPtr ExtraInfo; 234 | } 235 | 236 | public enum KeyCode : ushort 237 | { 238 | #region Media 239 | 240 | /// 241 | /// Next track if a song is playing 242 | /// 243 | MEDIA_NEXT_TRACK = 0xb0, 244 | 245 | /// 246 | /// Play pause 247 | /// 248 | MEDIA_PLAY_PAUSE = 0xb3, 249 | 250 | /// 251 | /// Previous track 252 | /// 253 | MEDIA_PREV_TRACK = 0xb1, 254 | 255 | /// 256 | /// Stop 257 | /// 258 | MEDIA_STOP = 0xb2, 259 | 260 | #endregion 261 | 262 | #region math 263 | 264 | /// Key "+" 265 | ADD = 0x6b, 266 | /// 267 | /// "*" key 268 | /// 269 | MULTIPLY = 0x6a, 270 | 271 | /// 272 | /// "/" key 273 | /// 274 | DIVIDE = 0x6f, 275 | 276 | /// 277 | /// Subtract key "-" 278 | /// 279 | SUBTRACT = 0x6d, 280 | 281 | #endregion 282 | 283 | #region Browser 284 | /// 285 | /// Go Back 286 | /// 287 | BROWSER_BACK = 0xa6, 288 | /// 289 | /// Favorites 290 | /// 291 | BROWSER_FAVORITES = 0xab, 292 | /// 293 | /// Forward 294 | /// 295 | BROWSER_FORWARD = 0xa7, 296 | /// 297 | /// Home 298 | /// 299 | BROWSER_HOME = 0xac, 300 | /// 301 | /// Refresh 302 | /// 303 | BROWSER_REFRESH = 0xa8, 304 | /// 305 | /// browser search 306 | /// 307 | BROWSER_SEARCH = 170, 308 | /// 309 | /// Stop 310 | /// 311 | BROWSER_STOP = 0xa9, 312 | #endregion 313 | 314 | #region Numpad numbers 315 | /// 316 | /// 317 | /// 318 | NUMPAD0 = 0x60, 319 | /// 320 | /// 321 | /// 322 | NUMPAD1 = 0x61, 323 | /// 324 | /// 325 | /// 326 | NUMPAD2 = 0x62, 327 | /// 328 | /// 329 | /// 330 | NUMPAD3 = 0x63, 331 | /// 332 | /// 333 | /// 334 | NUMPAD4 = 100, 335 | /// 336 | /// 337 | /// 338 | NUMPAD5 = 0x65, 339 | /// 340 | /// 341 | /// 342 | NUMPAD6 = 0x66, 343 | /// 344 | /// 345 | /// 346 | NUMPAD7 = 0x67, 347 | /// 348 | /// 349 | /// 350 | NUMPAD8 = 0x68, 351 | /// 352 | /// 353 | /// 354 | NUMPAD9 = 0x69, 355 | 356 | #endregion 357 | 358 | #region Fkeys 359 | /// 360 | /// F1 361 | /// 362 | F1 = 0x70, 363 | /// 364 | /// F10 365 | /// 366 | F10 = 0x79, 367 | /// 368 | /// 369 | /// 370 | F11 = 0x7a, 371 | /// 372 | /// 373 | /// 374 | F12 = 0x7b, 375 | /// 376 | /// 377 | /// 378 | F13 = 0x7c, 379 | /// 380 | /// 381 | /// 382 | F14 = 0x7d, 383 | /// 384 | /// 385 | /// 386 | F15 = 0x7e, 387 | /// 388 | /// 389 | /// 390 | F16 = 0x7f, 391 | /// 392 | /// 393 | /// 394 | F17 = 0x80, 395 | /// 396 | /// 397 | /// 398 | F18 = 0x81, 399 | /// 400 | /// 401 | /// 402 | F19 = 130, 403 | /// 404 | /// 405 | /// 406 | F2 = 0x71, 407 | /// 408 | /// 409 | /// 410 | F20 = 0x83, 411 | /// 412 | /// 413 | /// 414 | F21 = 0x84, 415 | /// 416 | /// 417 | /// 418 | F22 = 0x85, 419 | /// 420 | /// 421 | /// 422 | F23 = 0x86, 423 | /// 424 | /// 425 | /// 426 | F24 = 0x87, 427 | /// 428 | /// 429 | /// 430 | F3 = 0x72, 431 | /// 432 | /// 433 | /// 434 | F4 = 0x73, 435 | /// 436 | /// 437 | /// 438 | F5 = 0x74, 439 | /// 440 | /// 441 | /// 442 | F6 = 0x75, 443 | /// 444 | /// 445 | /// 446 | F7 = 0x76, 447 | /// 448 | /// 449 | /// 450 | F8 = 0x77, 451 | /// 452 | /// 453 | /// 454 | F9 = 120, 455 | 456 | #endregion 457 | 458 | #region Other 459 | /// 460 | /// 461 | /// 462 | OEM_1 = 0xba, 463 | /// 464 | /// 465 | /// 466 | OEM_102 = 0xe2, 467 | /// 468 | /// 469 | /// 470 | OEM_2 = 0xbf, 471 | /// 472 | /// 473 | /// 474 | OEM_3 = 0xc0, 475 | /// 476 | /// 477 | /// 478 | OEM_4 = 0xdb, 479 | /// 480 | /// 481 | /// 482 | OEM_5 = 220, 483 | /// 484 | /// 485 | /// 486 | OEM_6 = 0xdd, 487 | /// 488 | /// 489 | /// 490 | OEM_7 = 0xde, 491 | /// 492 | /// 493 | /// 494 | OEM_8 = 0xdf, 495 | /// 496 | /// 497 | /// 498 | OEM_CLEAR = 0xfe, 499 | /// 500 | /// 501 | /// 502 | OEM_COMMA = 0xbc, 503 | /// 504 | /// 505 | /// 506 | OEM_MINUS = 0xbd, 507 | /// 508 | /// 509 | /// 510 | OEM_PERIOD = 190, 511 | /// 512 | /// 513 | /// 514 | OEM_PLUS = 0xbb, 515 | 516 | #endregion 517 | 518 | #region KEYS 519 | 520 | /// 521 | /// 522 | /// 523 | KEY_0 = 0x30, 524 | /// 525 | /// 526 | /// 527 | KEY_1 = 0x31, 528 | /// 529 | /// 530 | /// 531 | KEY_2 = 50, 532 | /// 533 | /// 534 | /// 535 | KEY_3 = 0x33, 536 | /// 537 | /// 538 | /// 539 | KEY_4 = 0x34, 540 | /// 541 | /// 542 | /// 543 | KEY_5 = 0x35, 544 | /// 545 | /// 546 | /// 547 | KEY_6 = 0x36, 548 | /// 549 | /// 550 | /// 551 | KEY_7 = 0x37, 552 | /// 553 | /// 554 | /// 555 | KEY_8 = 0x38, 556 | /// 557 | /// 558 | /// 559 | KEY_9 = 0x39, 560 | /// 561 | /// 562 | /// 563 | KEY_A = 0x41, 564 | /// 565 | /// 566 | /// 567 | KEY_B = 0x42, 568 | /// 569 | /// 570 | /// 571 | KEY_C = 0x43, 572 | /// 573 | /// 574 | /// 575 | KEY_D = 0x44, 576 | /// 577 | /// 578 | /// 579 | KEY_E = 0x45, 580 | /// 581 | /// 582 | /// 583 | KEY_F = 70, 584 | /// 585 | /// 586 | /// 587 | KEY_G = 0x47, 588 | /// 589 | /// 590 | /// 591 | KEY_H = 0x48, 592 | /// 593 | /// 594 | /// 595 | KEY_I = 0x49, 596 | /// 597 | /// 598 | /// 599 | KEY_J = 0x4a, 600 | /// 601 | /// 602 | /// 603 | KEY_K = 0x4b, 604 | /// 605 | /// 606 | /// 607 | KEY_L = 0x4c, 608 | /// 609 | /// 610 | /// 611 | KEY_M = 0x4d, 612 | /// 613 | /// 614 | /// 615 | KEY_N = 0x4e, 616 | /// 617 | /// 618 | /// 619 | KEY_O = 0x4f, 620 | /// 621 | /// 622 | /// 623 | KEY_P = 80, 624 | /// 625 | /// 626 | /// 627 | KEY_Q = 0x51, 628 | /// 629 | /// 630 | /// 631 | KEY_R = 0x52, 632 | /// 633 | /// 634 | /// 635 | KEY_S = 0x53, 636 | /// 637 | /// 638 | /// 639 | KEY_T = 0x54, 640 | /// 641 | /// 642 | /// 643 | KEY_U = 0x55, 644 | /// 645 | /// 646 | /// 647 | KEY_V = 0x56, 648 | /// 649 | /// 650 | /// 651 | KEY_W = 0x57, 652 | /// 653 | /// 654 | /// 655 | KEY_X = 0x58, 656 | /// 657 | /// 658 | /// 659 | KEY_Y = 0x59, 660 | /// 661 | /// 662 | /// 663 | KEY_Z = 90, 664 | 665 | #endregion 666 | 667 | #region volume 668 | /// 669 | /// Decrese volume 670 | /// 671 | VOLUME_DOWN = 0xae, 672 | 673 | /// 674 | /// Mute volume 675 | /// 676 | VOLUME_MUTE = 0xad, 677 | 678 | /// 679 | /// Increase volue 680 | /// 681 | VOLUME_UP = 0xaf, 682 | 683 | #endregion 684 | 685 | 686 | /// 687 | /// Take snapshot of the screen and place it on the clipboard 688 | /// 689 | SNAPSHOT = 0x2c, 690 | 691 | /// Send right click from keyboard "key that is 2 keys to the right of space bar" 692 | RightClick = 0x5d, 693 | 694 | /// 695 | /// Go Back or delete 696 | /// 697 | BACKSPACE = 8, 698 | 699 | /// 700 | /// Control + Break "When debuging if you step into an infinite loop this will stop debug" 701 | /// 702 | CANCEL = 3, 703 | /// 704 | /// Caps lock key to send cappital letters 705 | /// 706 | CAPS_LOCK = 20, 707 | /// 708 | /// Ctlr key 709 | /// 710 | CONTROL = 0x11, 711 | 712 | /// 713 | /// Alt key 714 | /// 715 | ALT = 18, 716 | 717 | /// 718 | /// "." key 719 | /// 720 | DECIMAL = 110, 721 | 722 | /// 723 | /// Delete Key 724 | /// 725 | DELETE = 0x2e, 726 | 727 | 728 | /// 729 | /// Arrow down key 730 | /// 731 | DOWN = 40, 732 | 733 | /// 734 | /// End key 735 | /// 736 | END = 0x23, 737 | 738 | /// 739 | /// Escape key 740 | /// 741 | ESC = 0x1b, 742 | 743 | /// 744 | /// Home key 745 | /// 746 | HOME = 0x24, 747 | 748 | /// 749 | /// Insert key 750 | /// 751 | INSERT = 0x2d, 752 | 753 | /// 754 | /// Open my computer 755 | /// 756 | LAUNCH_APP1 = 0xb6, 757 | /// 758 | /// Open calculator 759 | /// 760 | LAUNCH_APP2 = 0xb7, 761 | 762 | /// 763 | /// Open default email in my case outlook 764 | /// 765 | LAUNCH_MAIL = 180, 766 | 767 | /// 768 | /// Opend default media player (itunes, winmediaplayer, etc) 769 | /// 770 | LAUNCH_MEDIA_SELECT = 0xb5, 771 | 772 | /// 773 | /// Left control 774 | /// 775 | LCONTROL = 0xa2, 776 | 777 | /// 778 | /// Left arrow 779 | /// 780 | LEFT = 0x25, 781 | 782 | /// 783 | /// Left shift 784 | /// 785 | LSHIFT = 160, 786 | 787 | /// 788 | /// left windows key 789 | /// 790 | LWIN = 0x5b, 791 | 792 | 793 | /// 794 | /// Next "page down" 795 | /// 796 | PAGEDOWN = 0x22, 797 | 798 | /// 799 | /// Num lock to enable typing numbers 800 | /// 801 | NUMLOCK = 0x90, 802 | 803 | /// 804 | /// Page up key 805 | /// 806 | PAGE_UP = 0x21, 807 | 808 | /// 809 | /// Right control 810 | /// 811 | RCONTROL = 0xa3, 812 | 813 | /// 814 | /// Return key 815 | /// 816 | ENTER = 13, 817 | 818 | /// 819 | /// Right arrow key 820 | /// 821 | RIGHT = 0x27, 822 | 823 | /// 824 | /// Right shift 825 | /// 826 | RSHIFT = 0xa1, 827 | 828 | /// 829 | /// Right windows key 830 | /// 831 | RWIN = 0x5c, 832 | 833 | /// 834 | /// Shift key 835 | /// 836 | SHIFT = 0x10, 837 | 838 | /// 839 | /// Space back key 840 | /// 841 | SPACE_BAR = 0x20, 842 | 843 | /// 844 | /// Tab key 845 | /// 846 | TAB = 9, 847 | 848 | /// 849 | /// Up arrow key 850 | /// 851 | UP = 0x26, 852 | 853 | } 854 | 855 | /* 856 | Hex Decimal Symbolic 857 | 0000 0 WM_NULL 858 | 0001 1 WM_CREATE 859 | 0002 2 WM_DESTROY 860 | 0003 3 WM_MOVE 861 | 0005 5 WM_SIZE 862 | 0006 6 WM_ACTIVATE 863 | 0007 7 WM_SETFOCUS 864 | 0008 8 WM_KILLFOCUS 865 | 000a 10 WM_ENABLE 866 | 000b 11 WM_SETREDRAW 867 | 000c 12 WM_SETTEXT 868 | 000d 13 WM_GETTEXT 869 | 000e 14 WM_GETTEXTLENGTH 870 | 000f 15 WM_PAINT 871 | 0010 16 WM_CLOSE 872 | 0011 17 WM_QUERYENDSESSION 873 | 0012 18 WM_QUIT 874 | 0013 19 WM_QUERYOPEN 875 | 0014 20 WM_ERASEBKGND 876 | 0015 21 WM_SYSCOLORCHANGE 877 | 0016 22 WM_ENDSESSION 878 | 0018 24 WM_SHOWWINDOW 879 | 0019 25 WM_CTLCOLOR 880 | 001a 26 WM_WININICHANGE 881 | 001b 27 WM_DEVMODECHANGE 882 | 001c 28 WM_ACTIVATEAPP 883 | 001d 29 WM_FONTCHANGE 884 | 001e 30 WM_TIMECHANGE 885 | 001f 31 WM_CANCELMODE 886 | 0020 32 WM_SETCURSOR 887 | 0021 33 WM_MOUSEACTIVATE 888 | 0022 34 WM_CHILDACTIVATE 889 | 0023 35 WM_QUEUESYNC 890 | 0024 36 WM_GETMINMAXINFO 891 | 0026 38 WM_PAINTICON 892 | 0027 39 WM_ICONERASEBKGND 893 | 0028 40 WM_NEXTDLGCTL 894 | 002a 42 WM_SPOOLERSTATUS 895 | 002b 43 WM_DRAWITEM 896 | 002c 44 WM_MEASUREITEM 897 | 002d 45 WM_DELETEITEM 898 | 002e 46 WM_VKEYTOITEM 899 | 002f 47 WM_CHARTOITEM 900 | 0030 48 WM_SETFONT 901 | 0031 49 WM_GETFONT 902 | 0032 50 WM_SETHOTKEY 903 | 0033 51 WM_GETHOTKEY 904 | 0037 55 WM_QUERYDRAGICON 905 | 0039 57 WM_COMPAREITEM 906 | 003d 61 WM_GETOBJECT 907 | 0041 65 WM_COMPACTING 908 | 0044 68 WM_COMMNOTIFY 909 | 0046 70 WM_WINDOWPOSCHANGING 910 | 0047 71 WM_WINDOWPOSCHANGED 911 | 0048 72 WM_POWER 912 | 0049 73 WM_COPYGLOBALDATA 913 | 004a 74 WM_COPYDATA 914 | 004b 75 WM_CANCELJOURNAL 915 | 004e 78 WM_NOTIFY 916 | 0050 80 WM_INPUTLANGCHANGEREQUEST 917 | 0051 81 WM_INPUTLANGCHANGE 918 | 0052 82 WM_TCARD 919 | 0053 83 WM_HELP 920 | 0054 84 WM_USERCHANGED 921 | 0055 85 WM_NOTIFYFORMAT 922 | 007b 123 WM_CONTEXTMENU 923 | 007c 124 WM_STYLECHANGING 924 | 007d 125 WM_STYLECHANGED 925 | 007e 126 WM_DISPLAYCHANGE 926 | 007f 127 WM_GETICON 927 | 0080 128 WM_SETICON 928 | 0081 129 WM_NCCREATE 929 | 0082 130 WM_NCDESTROY 930 | 0083 131 WM_NCCALCSIZE 931 | 0084 132 WM_NCHITTEST 932 | 0085 133 WM_NCPAINT 933 | 0086 134 WM_NCACTIVATE 934 | 0087 135 WM_GETDLGCODE 935 | 0088 136 WM_SYNCPAINT 936 | 00a0 160 WM_NCMOUSEMOVE 937 | 00a1 161 WM_NCLBUTTONDOWN 938 | 00a2 162 WM_NCLBUTTONUP 939 | 00a3 163 WM_NCLBUTTONDBLCLK 940 | 00a4 164 WM_NCRBUTTONDOWN 941 | 00a5 165 WM_NCRBUTTONUP 942 | 00a6 166 WM_NCRBUTTONDBLCLK 943 | 00a7 167 WM_NCMBUTTONDOWN 944 | 00a8 168 WM_NCMBUTTONUP 945 | 00a9 169 WM_NCMBUTTONDBLCLK 946 | 00ab 171 WM_NCXBUTTONDOWN 947 | 00ac 172 WM_NCXBUTTONUP 948 | 00ad 173 WM_NCXBUTTONDBLCLK 949 | 00b0 176 EM_GETSEL 950 | 00b1 177 EM_SETSEL 951 | 00b2 178 EM_GETRECT 952 | 00b3 179 EM_SETRECT 953 | 00b4 180 EM_SETRECTNP 954 | 00b5 181 EM_SCROLL 955 | 00b6 182 EM_LINESCROLL 956 | 00b7 183 EM_SCROLLCARET 957 | 00b8 185 EM_GETMODIFY 958 | 00b9 187 EM_SETMODIFY 959 | 00ba 188 EM_GETLINECOUNT 960 | 00bb 189 EM_LINEINDEX 961 | 00bc 190 EM_SETHANDLE 962 | 00bd 191 EM_GETHANDLE 963 | 00be 192 EM_GETTHUMB 964 | 00c1 193 EM_LINELENGTH 965 | 00c2 194 EM_REPLACESEL 966 | 00c3 195 EM_SETFONT 967 | 00c4 196 EM_GETLINE 968 | 00c5 197 EM_LIMITTEXT 969 | 00c5 197 EM_SETLIMITTEXT 970 | 00c6 198 EM_CANUNDO 971 | 00c7 199 EM_UNDO 972 | 00c8 200 EM_FMTLINES 973 | 00c9 201 EM_LINEFROMCHAR 974 | 00ca 202 EM_SETWORDBREAK 975 | 00cb 203 EM_SETTABSTOPS 976 | 00cc 204 EM_SETPASSWORDCHAR 977 | 00cd 205 EM_EMPTYUNDOBUFFER 978 | 00ce 206 EM_GETFIRSTVISIBLELINE 979 | 00cf 207 EM_SETREADONLY 980 | 00d0 209 EM_SETWORDBREAKPROC 981 | 00d1 209 EM_GETWORDBREAKPROC 982 | 00d2 210 EM_GETPASSWORDCHAR 983 | 00d3 211 EM_SETMARGINS 984 | 00d4 212 EM_GETMARGINS 985 | 00d5 213 EM_GETLIMITTEXT 986 | 00d6 214 EM_POSFROMCHAR 987 | 00d7 215 EM_CHARFROMPOS 988 | 00d8 216 EM_SETIMESTATUS 989 | 00d9 217 EM_GETIMESTATUS 990 | 00e0 224 SBM_SETPOS 991 | 00e1 225 SBM_GETPOS 992 | 00e2 226 SBM_SETRANGE 993 | 00e3 227 SBM_GETRANGE 994 | 00e4 228 SBM_ENABLE_ARROWS 995 | 00e6 230 SBM_SETRANGEREDRAW 996 | 00e9 233 SBM_SETSCROLLINFO 997 | 00ea 234 SBM_GETSCROLLINFO 998 | 00eb 235 SBM_GETSCROLLBARINFO 999 | 00f0 240 BM_GETCHECK 1000 | 00f1 241 BM_SETCHECK 1001 | 00f2 242 BM_GETSTATE 1002 | 00f3 243 BM_SETSTATE 1003 | 00f4 244 BM_SETSTYLE 1004 | 00f5 245 BM_CLICK 1005 | 00f6 246 BM_GETIMAGE 1006 | 00f7 247 BM_SETIMAGE 1007 | 00f8 248 BM_SETDONTCLICK 1008 | 00ff 255 WM_INPUT 1009 | 0100 256 WM_KEYDOWN 1010 | 0100 256 WM_KEYFIRST 1011 | 0101 257 WM_KEYUP 1012 | 0102 258 WM_CHAR 1013 | 0103 259 WM_DEADCHAR 1014 | 0104 260 WM_SYSKEYDOWN 1015 | 0105 261 WM_SYSKEYUP 1016 | 0106 262 WM_SYSCHAR 1017 | 0107 263 WM_SYSDEADCHAR 1018 | 0108 264 WM_KEYLAST 1019 | 0109 265 WM_UNICHAR 1020 | 0109 265 WM_WNT_CONVERTREQUESTEX 1021 | 010a 266 WM_CONVERTREQUEST 1022 | 010b 267 WM_CONVERTRESULT 1023 | 010c 268 WM_INTERIM 1024 | 010d 269 WM_IME_STARTCOMPOSITION 1025 | 010e 270 WM_IME_ENDCOMPOSITION 1026 | 010f 271 WM_IME_COMPOSITION 1027 | 010f 271 WM_IME_KEYLAST 1028 | 0110 272 WM_INITDIALOG 1029 | 0111 273 WM_COMMAND 1030 | 0112 274 WM_SYSCOMMAND 1031 | 0113 275 WM_TIMER 1032 | 0114 276 WM_HSCROLL 1033 | 0115 277 WM_VSCROLL 1034 | 0116 278 WM_INITMENU 1035 | 0117 279 WM_INITMENUPOPUP 1036 | 0118 280 WM_SYSTIMER 1037 | 011f 287 WM_MENUSELECT 1038 | 0120 288 WM_MENUCHAR 1039 | 0121 289 WM_ENTERIDLE 1040 | 0122 290 WM_MENURBUTTONUP 1041 | 0123 291 WM_MENUDRAG 1042 | 0124 292 WM_MENUGETOBJECT 1043 | 0125 293 WM_UNINITMENUPOPUP 1044 | 0126 294 WM_MENUCOMMAND 1045 | 0127 295 WM_CHANGEUISTATE 1046 | 0128 296 WM_UPDATEUISTATE 1047 | 0129 297 WM_QUERYUISTATE 1048 | 0132 306 WM_CTLCOLORMSGBOX 1049 | 0133 307 WM_CTLCOLOREDIT 1050 | 0134 308 WM_CTLCOLORLISTBOX 1051 | 0135 309 WM_CTLCOLORBTN 1052 | 0136 310 WM_CTLCOLORDLG 1053 | 0137 311 WM_CTLCOLORSCROLLBAR 1054 | 0138 312 WM_CTLCOLORSTATIC 1055 | 0200 512 WM_MOUSEFIRST 1056 | 0200 512 WM_MOUSEMOVE 1057 | 0201 513 WM_LBUTTONDOWN 1058 | 0202 514 WM_LBUTTONUP 1059 | 0203 515 WM_LBUTTONDBLCLK 1060 | 0204 516 WM_RBUTTONDOWN 1061 | 0205 517 WM_RBUTTONUP 1062 | 0206 518 WM_RBUTTONDBLCLK 1063 | 0207 519 WM_MBUTTONDOWN 1064 | 0208 520 WM_MBUTTONUP 1065 | 0209 521 WM_MBUTTONDBLCLK 1066 | 0209 521 WM_MOUSELAST 1067 | 020a 522 WM_MOUSEWHEEL 1068 | 020b 523 WM_XBUTTONDOWN 1069 | 020c 524 WM_XBUTTONUP 1070 | 020d 525 WM_XBUTTONDBLCLK 1071 | 0210 528 WM_PARENTNOTIFY 1072 | 0211 529 WM_ENTERMENULOOP 1073 | 0212 530 WM_EXITMENULOOP 1074 | 0213 531 WM_NEXTMENU 1075 | 0214 532 WM_SIZING 1076 | 0215 533 WM_CAPTURECHANGED 1077 | 0216 534 WM_MOVING 1078 | 0218 536 WM_POWERBROADCAST 1079 | 0219 537 WM_DEVICECHANGE 1080 | 0220 544 WM_MDICREATE 1081 | 0221 545 WM_MDIDESTROY 1082 | 0222 546 WM_MDIACTIVATE 1083 | 0223 547 WM_MDIRESTORE 1084 | 0224 548 WM_MDINEXT 1085 | 0225 549 WM_MDIMAXIMIZE 1086 | 0226 550 WM_MDITILE 1087 | 0227 551 WM_MDICASCADE 1088 | 0228 552 WM_MDIICONARRANGE 1089 | 0229 553 WM_MDIGETACTIVE 1090 | 0230 560 WM_MDISETMENU 1091 | 0231 561 WM_ENTERSIZEMOVE 1092 | 0232 562 WM_EXITSIZEMOVE 1093 | 0233 563 WM_DROPFILES 1094 | 0234 564 WM_MDIREFRESHMENU 1095 | 0280 640 WM_IME_REPORT 1096 | 0281 641 WM_IME_SETCONTEXT 1097 | 0282 642 WM_IME_NOTIFY 1098 | 0283 643 WM_IME_CONTROL 1099 | 0284 644 WM_IME_COMPOSITIONFULL 1100 | 0285 645 WM_IME_SELECT 1101 | 0286 646 WM_IME_CHAR 1102 | 0288 648 WM_IME_REQUEST 1103 | 0290 656 WM_IMEKEYDOWN 1104 | 0290 656 WM_IME_KEYDOWN 1105 | 0291 657 WM_IMEKEYUP 1106 | 0291 657 WM_IME_KEYUP 1107 | 02a0 672 WM_NCMOUSEHOVER 1108 | 02a1 673 WM_MOUSEHOVER 1109 | 02a2 674 WM_NCMOUSELEAVE 1110 | 02a3 675 WM_MOUSELEAVE 1111 | 0300 768 WM_CUT 1112 | 0301 769 WM_COPY 1113 | 0302 770 WM_PASTE 1114 | 0303 771 WM_CLEAR 1115 | 0304 772 WM_UNDO 1116 | 0305 773 WM_RENDERFORMAT 1117 | 0306 774 WM_RENDERALLFORMATS 1118 | 0307 775 WM_DESTROYCLIPBOARD 1119 | 0308 776 WM_DRAWCLIPBOARD 1120 | 0309 777 WM_PAINTCLIPBOARD 1121 | 030a 778 WM_VSCROLLCLIPBOARD 1122 | 030b 779 WM_SIZECLIPBOARD 1123 | 030c 780 WM_ASKCBFORMATNAME 1124 | 030d 781 WM_CHANGECBCHAIN 1125 | 030e 782 WM_HSCROLLCLIPBOARD 1126 | 030f 783 WM_QUERYNEWPALETTE 1127 | 0310 784 WM_PALETTEISCHANGING 1128 | 0311 785 WM_PALETTECHANGED 1129 | 0312 786 WM_HOTKEY 1130 | 0317 791 WM_PRINT 1131 | 0318 792 WM_PRINTCLIENT 1132 | 0319 793 WM_APPCOMMAND 1133 | 0358 856 WM_HANDHELDFIRST 1134 | 035f 863 WM_HANDHELDLAST 1135 | 0360 864 WM_AFXFIRST 1136 | 037f 895 WM_AFXLAST 1137 | 0380 896 WM_PENWINFIRST 1138 | 0381 897 WM_RCRESULT 1139 | 0382 898 WM_HOOKRCRESULT 1140 | 0383 899 WM_GLOBALRCCHANGE 1141 | 0383 899 WM_PENMISCINFO 1142 | 0384 900 WM_SKB 1143 | 0385 901 WM_HEDITCTL 1144 | 0385 901 WM_PENCTL 1145 | 0386 902 WM_PENMISC 1146 | 0387 903 WM_CTLINIT 1147 | 0388 904 WM_PENEVENT 1148 | 038f 911 WM_PENWINLAST 1149 | 0400 1024 DDM_SETFMT 1150 | 0400 1024 DM_GETDEFID 1151 | 0400 1024 NIN_SELECT 1152 | 0400 1024 TBM_GETPOS 1153 | 0400 1024 WM_PSD_PAGESETUPDLG 1154 | 0400 1024 WM_USER 1155 | 0401 1025 CBEM_INSERTITEMA 1156 | 0401 1025 DDM_DRAW 1157 | 0401 1025 DM_SETDEFID 1158 | 0401 1025 HKM_SETHOTKEY 1159 | 0401 1025 PBM_SETRANGE 1160 | 0401 1025 RB_INSERTBANDA 1161 | 0401 1025 SB_SETTEXTA 1162 | 0401 1025 TB_ENABLEBUTTON 1163 | 0401 1025 TBM_GETRANGEMIN 1164 | 0401 1025 TTM_ACTIVATE 1165 | 0401 1025 WM_CHOOSEFONT_GETLOGFONT 1166 | 0401 1025 WM_PSD_FULLPAGERECT 1167 | 0402 1026 CBEM_SETIMAGELIST 1168 | 0402 1026 DDM_CLOSE 1169 | 0402 1026 DM_REPOSITION 1170 | 0402 1026 HKM_GETHOTKEY 1171 | 0402 1026 PBM_SETPOS 1172 | 0402 1026 RB_DELETEBAND 1173 | 0402 1026 SB_GETTEXTA 1174 | 0402 1026 TB_CHECKBUTTON 1175 | 0402 1026 TBM_GETRANGEMAX 1176 | 0402 1026 WM_PSD_MINMARGINRECT 1177 | 0403 1027 CBEM_GETIMAGELIST 1178 | 0403 1027 DDM_BEGIN 1179 | 0403 1027 HKM_SETRULES 1180 | 0403 1027 PBM_DELTAPOS 1181 | 0403 1027 RB_GETBARINFO 1182 | 0403 1027 SB_GETTEXTLENGTHA 1183 | 0403 1027 TBM_GETTIC 1184 | 0403 1027 TB_PRESSBUTTON 1185 | 0403 1027 TTM_SETDELAYTIME 1186 | 0403 1027 WM_PSD_MARGINRECT 1187 | 0404 1028 CBEM_GETITEMA 1188 | 0404 1028 DDM_END 1189 | 0404 1028 PBM_SETSTEP 1190 | 0404 1028 RB_SETBARINFO 1191 | 0404 1028 SB_SETPARTS 1192 | 0404 1028 TB_HIDEBUTTON 1193 | 0404 1028 TBM_SETTIC 1194 | 0404 1028 TTM_ADDTOOLA 1195 | 0404 1028 WM_PSD_GREEKTEXTRECT 1196 | 0405 1029 CBEM_SETITEMA 1197 | 0405 1029 PBM_STEPIT 1198 | 0405 1029 TB_INDETERMINATE 1199 | 0405 1029 TBM_SETPOS 1200 | 0405 1029 TTM_DELTOOLA 1201 | 0405 1029 WM_PSD_ENVSTAMPRECT 1202 | 0406 1030 CBEM_GETCOMBOCONTROL 1203 | 0406 1030 PBM_SETRANGE32 1204 | 0406 1030 RB_SETBANDINFOA 1205 | 0406 1030 SB_GETPARTS 1206 | 0406 1030 TB_MARKBUTTON 1207 | 0406 1030 TBM_SETRANGE 1208 | 0406 1030 TTM_NEWTOOLRECTA 1209 | 0406 1030 WM_PSD_YAFULLPAGERECT 1210 | 0407 1031 CBEM_GETEDITCONTROL 1211 | 0407 1031 PBM_GETRANGE 1212 | 0407 1031 RB_SETPARENT 1213 | 0407 1031 SB_GETBORDERS 1214 | 0407 1031 TBM_SETRANGEMIN 1215 | 0407 1031 TTM_RELAYEVENT 1216 | 0408 1032 CBEM_SETEXSTYLE 1217 | 0408 1032 PBM_GETPOS 1218 | 0408 1032 RB_HITTEST 1219 | 0408 1032 SB_SETMINHEIGHT 1220 | 0408 1032 TBM_SETRANGEMAX 1221 | 0408 1032 TTM_GETTOOLINFOA 1222 | 0409 1033 CBEM_GETEXSTYLE 1223 | 0409 1033 CBEM_GETEXTENDEDSTYLE 1224 | 0409 1033 PBM_SETBARCOLOR 1225 | 0409 1033 RB_GETRECT 1226 | 0409 1033 SB_SIMPLE 1227 | 0409 1033 TB_ISBUTTONENABLED 1228 | 0409 1033 TBM_CLEARTICS 1229 | 0409 1033 TTM_SETTOOLINFOA 1230 | 040a 1034 CBEM_HASEDITCHANGED 1231 | 040a 1034 RB_INSERTBANDW 1232 | 040a 1034 SB_GETRECT 1233 | 040a 1034 TB_ISBUTTONCHECKED 1234 | 040a 1034 TBM_SETSEL 1235 | 040a 1034 TTM_HITTESTA 1236 | 040a 1034 WIZ_QUERYNUMPAGES 1237 | 040b 1035 CBEM_INSERTITEMW 1238 | 040b 1035 RB_SETBANDINFOW 1239 | 040b 1035 SB_SETTEXTW 1240 | 040b 1035 TB_ISBUTTONPRESSED 1241 | 040b 1035 TBM_SETSELSTART 1242 | 040b 1035 TTM_GETTEXTA 1243 | 040b 1035 WIZ_NEXT 1244 | 040c 1036 CBEM_SETITEMW 1245 | 040c 1036 RB_GETBANDCOUNT 1246 | 040c 1036 SB_GETTEXTLENGTHW 1247 | 040c 1036 TB_ISBUTTONHIDDEN 1248 | 040c 1036 TBM_SETSELEND 1249 | 040c 1036 TTM_UPDATETIPTEXTA 1250 | 040c 1036 WIZ_PREV 1251 | 040d 1037 CBEM_GETITEMW 1252 | 040d 1037 RB_GETROWCOUNT 1253 | 040d 1037 SB_GETTEXTW 1254 | 040d 1037 TB_ISBUTTONINDETERMINATE 1255 | 040d 1037 TTM_GETTOOLCOUNT 1256 | 040e 1038 CBEM_SETEXTENDEDSTYLE 1257 | 040e 1038 RB_GETROWHEIGHT 1258 | 040e 1038 SB_ISSIMPLE 1259 | 040e 1038 TB_ISBUTTONHIGHLIGHTED 1260 | 040e 1038 TBM_GETPTICS 1261 | 040e 1038 TTM_ENUMTOOLSA 1262 | 040f 1039 SB_SETICON 1263 | 040f 1039 TBM_GETTICPOS 1264 | 040f 1039 TTM_GETCURRENTTOOLA 1265 | 0410 1040 RB_IDTOINDEX 1266 | 0410 1040 SB_SETTIPTEXTA 1267 | 0410 1040 TBM_GETNUMTICS 1268 | 0410 1040 TTM_WINDOWFROMPOINT 1269 | 0411 1041 RB_GETTOOLTIPS 1270 | 0411 1041 SB_SETTIPTEXTW 1271 | 0411 1041 TBM_GETSELSTART 1272 | 0411 1041 TB_SETSTATE 1273 | 0411 1041 TTM_TRACKACTIVATE 1274 | 0412 1042 RB_SETTOOLTIPS 1275 | 0412 1042 SB_GETTIPTEXTA 1276 | 0412 1042 TB_GETSTATE 1277 | 0412 1042 TBM_GETSELEND 1278 | 0412 1042 TTM_TRACKPOSITION 1279 | 0413 1043 RB_SETBKCOLOR 1280 | 0413 1043 SB_GETTIPTEXTW 1281 | 0413 1043 TB_ADDBITMAP 1282 | 0413 1043 TBM_CLEARSEL 1283 | 0413 1043 TTM_SETTIPBKCOLOR 1284 | 0414 1044 RB_GETBKCOLOR 1285 | 0414 1044 SB_GETICON 1286 | 0414 1044 TB_ADDBUTTONSA 1287 | 0414 1044 TBM_SETTICFREQ 1288 | 0414 1044 TTM_SETTIPTEXTCOLOR 1289 | 0415 1045 RB_SETTEXTCOLOR 1290 | 0415 1045 TB_INSERTBUTTONA 1291 | 0415 1045 TBM_SETPAGESIZE 1292 | 0415 1045 TTM_GETDELAYTIME 1293 | 0416 1046 RB_GETTEXTCOLOR 1294 | 0416 1046 TB_DELETEBUTTON 1295 | 0416 1046 TBM_GETPAGESIZE 1296 | 0416 1046 TTM_GETTIPBKCOLOR 1297 | 0417 1047 RB_SIZETORECT 1298 | 0417 1047 TB_GETBUTTON 1299 | 0417 1047 TBM_SETLINESIZE 1300 | 0417 1047 TTM_GETTIPTEXTCOLOR 1301 | 0418 1048 RB_BEGINDRAG 1302 | 0418 1048 TB_BUTTONCOUNT 1303 | 0418 1048 TBM_GETLINESIZE 1304 | 0418 1048 TTM_SETMAXTIPWIDTH 1305 | 0419 1049 RB_ENDDRAG 1306 | 0419 1049 TB_COMMANDTOINDEX 1307 | 0419 1049 TBM_GETTHUMBRECT 1308 | 0419 1049 TTM_GETMAXTIPWIDTH 1309 | 041a 1050 RB_DRAGMOVE 1310 | 041a 1050 TBM_GETCHANNELRECT 1311 | 041a 1050 TB_SAVERESTOREA 1312 | 041a 1050 TTM_SETMARGIN 1313 | 041b 1051 RB_GETBARHEIGHT 1314 | 041b 1051 TB_CUSTOMIZE 1315 | 041b 1051 TBM_SETTHUMBLENGTH 1316 | 041b 1051 TTM_GETMARGIN 1317 | 041c 1052 RB_GETBANDINFOW 1318 | 041c 1052 TB_ADDSTRINGA 1319 | 041c 1052 TBM_GETTHUMBLENGTH 1320 | 041c 1052 TTM_POP 1321 | 041d 1053 RB_GETBANDINFOA 1322 | 041d 1053 TB_GETITEMRECT 1323 | 041d 1053 TBM_SETTOOLTIPS 1324 | 041d 1053 TTM_UPDATE 1325 | 041e 1054 RB_MINIMIZEBAND 1326 | 041e 1054 TB_BUTTONSTRUCTSIZE 1327 | 041e 1054 TBM_GETTOOLTIPS 1328 | 041e 1054 TTM_GETBUBBLESIZE 1329 | 041f 1055 RB_MAXIMIZEBAND 1330 | 041f 1055 TBM_SETTIPSIDE 1331 | 041f 1055 TB_SETBUTTONSIZE 1332 | 041f 1055 TTM_ADJUSTRECT 1333 | 0420 1056 TBM_SETBUDDY 1334 | 0420 1056 TB_SETBITMAPSIZE 1335 | 0420 1056 TTM_SETTITLEA 1336 | 0421 1057 MSG_FTS_JUMP_VA 1337 | 0421 1057 TB_AUTOSIZE 1338 | 0421 1057 TBM_GETBUDDY 1339 | 0421 1057 TTM_SETTITLEW 1340 | 0422 1058 RB_GETBANDBORDERS 1341 | 0423 1059 MSG_FTS_JUMP_QWORD 1342 | 0423 1059 RB_SHOWBAND 1343 | 0423 1059 TB_GETTOOLTIPS 1344 | 0424 1060 MSG_REINDEX_REQUEST 1345 | 0424 1060 TB_SETTOOLTIPS 1346 | 0425 1061 MSG_FTS_WHERE_IS_IT 1347 | 0425 1061 RB_SETPALETTE 1348 | 0425 1061 TB_SETPARENT 1349 | 0426 1062 RB_GETPALETTE 1350 | 0427 1063 RB_MOVEBAND 1351 | 0427 1063 TB_SETROWS 1352 | 0428 1064 TB_GETROWS 1353 | 0429 1065 TB_GETBITMAPFLAGS 1354 | 042a 1066 TB_SETCMDID 1355 | 042b 1067 RB_PUSHCHEVRON 1356 | 042b 1067 TB_CHANGEBITMAP 1357 | 042c 1068 TB_GETBITMAP 1358 | 042d 1069 MSG_GET_DEFFONT 1359 | 042d 1069 TB_GETBUTTONTEXTA 1360 | 042e 1070 TB_REPLACEBITMAP 1361 | 042f 1071 TB_SETINDENT 1362 | 0430 1072 TB_SETIMAGELIST 1363 | 0431 1073 TB_GETIMAGELIST 1364 | 0432 1074 TB_LOADIMAGES 1365 | 0432 1074 EM_CANPASTE 1366 | 0432 1074 TTM_ADDTOOLW 1367 | 0433 1075 EM_DISPLAYBAND 1368 | 0433 1075 TB_GETRECT 1369 | 0433 1075 TTM_DELTOOLW 1370 | 0434 1076 EM_EXGETSEL 1371 | 0434 1076 TB_SETHOTIMAGELIST 1372 | 0434 1076 TTM_NEWTOOLRECTW 1373 | 0435 1077 EM_EXLIMITTEXT 1374 | 0435 1077 TB_GETHOTIMAGELIST 1375 | 0435 1077 TTM_GETTOOLINFOW 1376 | 0436 1078 EM_EXLINEFROMCHAR 1377 | 0436 1078 TB_SETDISABLEDIMAGELIST 1378 | 0436 1078 TTM_SETTOOLINFOW 1379 | 0437 1079 EM_EXSETSEL 1380 | 0437 1079 TB_GETDISABLEDIMAGELIST 1381 | 0437 1079 TTM_HITTESTW 1382 | 0438 1080 EM_FINDTEXT 1383 | 0438 1080 TB_SETSTYLE 1384 | 0438 1080 TTM_GETTEXTW 1385 | 0439 1081 EM_FORMATRANGE 1386 | 0439 1081 TB_GETSTYLE 1387 | 0439 1081 TTM_UPDATETIPTEXTW 1388 | 043a 1082 EM_GETCHARFORMAT 1389 | 043a 1082 TB_GETBUTTONSIZE 1390 | 043a 1082 TTM_ENUMTOOLSW 1391 | 043b 1083 EM_GETEVENTMASK 1392 | 043b 1083 TB_SETBUTTONWIDTH 1393 | 043b 1083 TTM_GETCURRENTTOOLW 1394 | 043c 1084 EM_GETOLEINTERFACE 1395 | 043c 1084 TB_SETMAXTEXTROWS 1396 | 043d 1085 EM_GETPARAFORMAT 1397 | 043d 1085 TB_GETTEXTROWS 1398 | 043e 1086 EM_GETSELTEXT 1399 | 043e 1086 TB_GETOBJECT 1400 | 043f 1087 EM_HIDESELECTION 1401 | 043f 1087 TB_GETBUTTONINFOW 1402 | 0440 1088 EM_PASTESPECIAL 1403 | 0440 1088 TB_SETBUTTONINFOW 1404 | 0441 1089 EM_REQUESTRESIZE 1405 | 0441 1089 TB_GETBUTTONINFOA 1406 | 0442 1090 EM_SELECTIONTYPE 1407 | 0442 1090 TB_SETBUTTONINFOA 1408 | 0443 1091 EM_SETBKGNDCOLOR 1409 | 0443 1091 TB_INSERTBUTTONW 1410 | 0444 1092 EM_SETCHARFORMAT 1411 | 0444 1092 TB_ADDBUTTONSW 1412 | 0445 1093 EM_SETEVENTMASK 1413 | 0445 1093 TB_HITTEST 1414 | 0446 1094 EM_SETOLECALLBACK 1415 | 0446 1094 TB_SETDRAWTEXTFLAGS 1416 | 0447 1095 EM_SETPARAFORMAT 1417 | 0447 1095 TB_GETHOTITEM 1418 | 0448 1096 EM_SETTARGETDEVICE 1419 | 0448 1096 TB_SETHOTITEM 1420 | 0449 1097 EM_STREAMIN 1421 | 0449 1097 TB_SETANCHORHIGHLIGHT 1422 | 044a 1098 EM_STREAMOUT 1423 | 044a 1098 TB_GETANCHORHIGHLIGHT 1424 | 044b 1099 EM_GETTEXTRANGE 1425 | 044b 1099 TB_GETBUTTONTEXTW 1426 | 044c 1100 EM_FINDWORDBREAK 1427 | 044c 1100 TB_SAVERESTOREW 1428 | 044d 1101 EM_SETOPTIONS 1429 | 044d 1101 TB_ADDSTRINGW 1430 | 044e 1102 EM_GETOPTIONS 1431 | 044e 1102 TB_MAPACCELERATORA 1432 | 044f 1103 EM_FINDTEXTEX 1433 | 044f 1103 TB_GETINSERTMARK 1434 | 0450 1104 EM_GETWORDBREAKPROCEX 1435 | 0450 1104 TB_SETINSERTMARK 1436 | 0451 1105 EM_SETWORDBREAKPROCEX 1437 | 0451 1105 TB_INSERTMARKHITTEST 1438 | 0452 1106 EM_SETUNDOLIMIT 1439 | 0452 1106 TB_MOVEBUTTON 1440 | 0453 1107 TB_GETMAXSIZE 1441 | 0454 1108 EM_REDO 1442 | 0454 1108 TB_SETEXTENDEDSTYLE 1443 | 0455 1109 EM_CANREDO 1444 | 0455 1109 TB_GETEXTENDEDSTYLE 1445 | 0456 1110 EM_GETUNDONAME 1446 | 0456 1110 TB_GETPADDING 1447 | 0457 1111 EM_GETREDONAME 1448 | 0457 1111 TB_SETPADDING 1449 | 0458 1112 EM_STOPGROUPTYPING 1450 | 0458 1112 TB_SETINSERTMARKCOLOR 1451 | 0459 1113 EM_SETTEXTMODE 1452 | 0459 1113 TB_GETINSERTMARKCOLOR 1453 | 045a 1114 EM_GETTEXTMODE 1454 | 045a 1114 TB_MAPACCELERATORW 1455 | 045b 1115 EM_AUTOURLDETECT 1456 | 045b 1115 TB_GETSTRINGW 1457 | 045c 1116 EM_GETAUTOURLDETECT 1458 | 045c 1116 TB_GETSTRINGA 1459 | 045d 1117 EM_SETPALETTE 1460 | 045e 1118 EM_GETTEXTEX 1461 | 045f 1119 EM_GETTEXTLENGTHEX 1462 | 0460 1120 EM_SHOWSCROLLBAR 1463 | 0461 1121 EM_SETTEXTEX 1464 | 0463 1123 TAPI_REPLY 1465 | 0464 1124 ACM_OPENA 1466 | 0464 1124 BFFM_SETSTATUSTEXTA 1467 | 0464 1124 CDM_FIRST 1468 | 0464 1124 CDM_GETSPEC 1469 | 0464 1124 EM_SETPUNCTUATION 1470 | 0464 1124 IPM_CLEARADDRESS 1471 | 0464 1124 WM_CAP_UNICODE_START 1472 | 0465 1125 ACM_PLAY 1473 | 0465 1125 BFFM_ENABLEOK 1474 | 0465 1125 CDM_GETFILEPATH 1475 | 0465 1125 EM_GETPUNCTUATION 1476 | 0465 1125 IPM_SETADDRESS 1477 | 0465 1125 PSM_SETCURSEL 1478 | 0465 1125 UDM_SETRANGE 1479 | 0465 1125 WM_CHOOSEFONT_SETLOGFONT 1480 | 0466 1126 ACM_STOP 1481 | 0466 1126 BFFM_SETSELECTIONA 1482 | 0466 1126 CDM_GETFOLDERPATH 1483 | 0466 1126 EM_SETWORDWRAPMODE 1484 | 0466 1126 IPM_GETADDRESS 1485 | 0466 1126 PSM_REMOVEPAGE 1486 | 0466 1126 UDM_GETRANGE 1487 | 0466 1126 WM_CAP_SET_CALLBACK_ERRORW 1488 | 0466 1126 WM_CHOOSEFONT_SETFLAGS 1489 | 0467 1127 ACM_OPENW 1490 | 0467 1127 BFFM_SETSELECTIONW 1491 | 0467 1127 CDM_GETFOLDERIDLIST 1492 | 0467 1127 EM_GETWORDWRAPMODE 1493 | 0467 1127 IPM_SETRANGE 1494 | 0467 1127 PSM_ADDPAGE 1495 | 0467 1127 UDM_SETPOS 1496 | 0467 1127 WM_CAP_SET_CALLBACK_STATUSW 1497 | 0468 1128 BFFM_SETSTATUSTEXTW 1498 | 0468 1128 CDM_SETCONTROLTEXT 1499 | 0468 1128 EM_SETIMECOLOR 1500 | 0468 1128 IPM_SETFOCUS 1501 | 0468 1128 PSM_CHANGED 1502 | 0468 1128 UDM_GETPOS 1503 | 0469 1129 CDM_HIDECONTROL 1504 | 0469 1129 EM_GETIMECOLOR 1505 | 0469 1129 IPM_ISBLANK 1506 | 0469 1129 PSM_RESTARTWINDOWS 1507 | 0469 1129 UDM_SETBUDDY 1508 | 046a 1130 CDM_SETDEFEXT 1509 | 046a 1130 EM_SETIMEOPTIONS 1510 | 046a 1130 PSM_REBOOTSYSTEM 1511 | 046a 1130 UDM_GETBUDDY 1512 | 046b 1131 EM_GETIMEOPTIONS 1513 | 046b 1131 PSM_CANCELTOCLOSE 1514 | 046b 1131 UDM_SETACCEL 1515 | 046c 1132 EM_CONVPOSITION 1516 | 046c 1132 EM_CONVPOSITION 1517 | 046c 1132 PSM_QUERYSIBLINGS 1518 | 046c 1132 UDM_GETACCEL 1519 | 046d 1133 MCIWNDM_GETZOOM 1520 | 046d 1133 PSM_UNCHANGED 1521 | 046d 1133 UDM_SETBASE 1522 | 046e 1134 PSM_APPLY 1523 | 046e 1134 UDM_GETBASE 1524 | 046f 1135 PSM_SETTITLEA 1525 | 046f 1135 UDM_SETRANGE32 1526 | 0470 1136 PSM_SETWIZBUTTONS 1527 | 0470 1136 UDM_GETRANGE32 1528 | 0470 1136 WM_CAP_DRIVER_GET_NAMEW 1529 | 0471 1137 PSM_PRESSBUTTON 1530 | 0471 1137 UDM_SETPOS32 1531 | 0471 1137 WM_CAP_DRIVER_GET_VERSIONW 1532 | 0472 1138 PSM_SETCURSELID 1533 | 0472 1138 UDM_GETPOS32 1534 | 0473 1139 PSM_SETFINISHTEXTA 1535 | 0474 1140 PSM_GETTABCONTROL 1536 | 0475 1141 PSM_ISDIALOGMESSAGE 1537 | 0476 1142 MCIWNDM_REALIZE 1538 | 0476 1142 PSM_GETCURRENTPAGEHWND 1539 | 0477 1143 MCIWNDM_SETTIMEFORMATA 1540 | 0477 1143 PSM_INSERTPAGE 1541 | 0478 1144 EM_SETLANGOPTIONS 1542 | 0478 1144 MCIWNDM_GETTIMEFORMATA 1543 | 0478 1144 PSM_SETTITLEW 1544 | 0478 1144 WM_CAP_FILE_SET_CAPTURE_FILEW 1545 | 0479 1145 EM_GETLANGOPTIONS 1546 | 0479 1145 MCIWNDM_VALIDATEMEDIA 1547 | 0479 1145 PSM_SETFINISHTEXTW 1548 | 0479 1145 WM_CAP_FILE_GET_CAPTURE_FILEW 1549 | 047a 1146 EM_GETIMECOMPMODE 1550 | 047b 1147 EM_FINDTEXTW 1551 | 047b 1147 MCIWNDM_PLAYTO 1552 | 047b 1147 WM_CAP_FILE_SAVEASW 1553 | 047c 1148 EM_FINDTEXTEXW 1554 | 047c 1148 MCIWNDM_GETFILENAMEA 1555 | 047d 1149 EM_RECONVERSION 1556 | 047d 1149 MCIWNDM_GETDEVICEA 1557 | 047d 1149 PSM_SETHEADERTITLEA 1558 | 047d 1149 WM_CAP_FILE_SAVEDIBW 1559 | 047e 1150 EM_SETIMEMODEBIAS 1560 | 047e 1150 MCIWNDM_GETPALETTE 1561 | 047e 1150 PSM_SETHEADERTITLEW 1562 | 047f 1151 EM_GETIMEMODEBIAS 1563 | 047f 1151 MCIWNDM_SETPALETTE 1564 | 047f 1151 PSM_SETHEADERSUBTITLEA 1565 | 0480 1152 MCIWNDM_GETERRORA 1566 | 0480 1152 PSM_SETHEADERSUBTITLEW 1567 | 0481 1153 PSM_HWNDTOINDEX 1568 | 0482 1154 PSM_INDEXTOHWND 1569 | 0483 1155 MCIWNDM_SETINACTIVETIMER 1570 | 0483 1155 PSM_PAGETOINDEX 1571 | 0484 1156 PSM_INDEXTOPAGE 1572 | 0485 1157 DL_BEGINDRAG 1573 | 0485 1157 MCIWNDM_GETINACTIVETIMER 1574 | 0485 1157 PSM_IDTOINDEX 1575 | 0486 1158 DL_DRAGGING 1576 | 0486 1158 PSM_INDEXTOID 1577 | 0487 1159 DL_DROPPED 1578 | 0487 1159 PSM_GETRESULT 1579 | 0488 1160 DL_CANCELDRAG 1580 | 0488 1160 PSM_RECALCPAGESIZES 1581 | 048c 1164 MCIWNDM_GET_SOURCE 1582 | 048d 1165 MCIWNDM_PUT_SOURCE 1583 | 048e 1166 MCIWNDM_GET_DEST 1584 | 048f 1167 MCIWNDM_PUT_DEST 1585 | 0490 1168 MCIWNDM_CAN_PLAY 1586 | 0491 1169 MCIWNDM_CAN_WINDOW 1587 | 0492 1170 MCIWNDM_CAN_RECORD 1588 | 0493 1171 MCIWNDM_CAN_SAVE 1589 | 0494 1172 MCIWNDM_CAN_EJECT 1590 | 0495 1173 MCIWNDM_CAN_CONFIG 1591 | 0496 1174 IE_GETINK 1592 | 0496 1174 IE_MSGFIRST 1593 | 0496 1174 MCIWNDM_PALETTEKICK 1594 | 0497 1175 IE_SETINK 1595 | 0498 1176 IE_GETPENTIP 1596 | 0499 1177 IE_SETPENTIP 1597 | 049a 1178 IE_GETERASERTIP 1598 | 049b 1179 IE_SETERASERTIP 1599 | 049c 1180 IE_GETBKGND 1600 | 049d 1181 IE_SETBKGND 1601 | 049e 1182 IE_GETGRIDORIGIN 1602 | 049f 1183 IE_SETGRIDORIGIN 1603 | 04a0 1184 IE_GETGRIDPEN 1604 | 04a1 1185 IE_SETGRIDPEN 1605 | 04a2 1186 IE_GETGRIDSIZE 1606 | 04a3 1187 IE_SETGRIDSIZE 1607 | 04a4 1188 IE_GETMODE 1608 | 04a5 1189 IE_SETMODE 1609 | 04a6 1190 IE_GETINKRECT 1610 | 04a6 1190 WM_CAP_SET_MCI_DEVICEW 1611 | 04a7 1191 WM_CAP_GET_MCI_DEVICEW 1612 | 04b4 1204 WM_CAP_PAL_OPENW 1613 | 04b5 1205 WM_CAP_PAL_SAVEW 1614 | 04b8 1208 IE_GETAPPDATA 1615 | 04b9 1209 IE_SETAPPDATA 1616 | 04ba 1210 IE_GETDRAWOPTS 1617 | 04bb 1211 IE_SETDRAWOPTS 1618 | 04bc 1212 IE_GETFORMAT 1619 | 04bd 1213 IE_SETFORMAT 1620 | 04be 1214 IE_GETINKINPUT 1621 | 04bf 1215 IE_SETINKINPUT 1622 | 04c0 1216 IE_GETNOTIFY 1623 | 04c1 1217 IE_SETNOTIFY 1624 | 04c2 1218 IE_GETRECOG 1625 | 04c3 1219 IE_SETRECOG 1626 | 04c4 1220 IE_GETSECURITY 1627 | 04c5 1221 IE_SETSECURITY 1628 | 04c6 1222 IE_GETSEL 1629 | 04c7 1223 IE_SETSEL 1630 | 04c8 1224 CDM_LAST 1631 | 04c8 1224 EM_SETBIDIOPTIONS 1632 | 04c8 1224 IE_DOCOMMAND 1633 | 04c8 1224 MCIWNDM_NOTIFYMODE 1634 | 04c9 1225 EM_GETBIDIOPTIONS 1635 | 04c9 1225 IE_GETCOMMAND 1636 | 04ca 1226 EM_SETTYPOGRAPHYOPTIONS 1637 | 04ca 1226 IE_GETCOUNT 1638 | 04cb 1227 EM_GETTYPOGRAPHYOPTIONS 1639 | 04cb 1227 IE_GETGESTURE 1640 | 04cb 1227 MCIWNDM_NOTIFYMEDIA 1641 | 04cc 1228 EM_SETEDITSTYLE 1642 | 04cc 1228 IE_GETMENU 1643 | 04cd 1229 EM_GETEDITSTYLE 1644 | 04cd 1229 IE_GETPAINTDC 1645 | 04cd 1229 MCIWNDM_NOTIFYERROR 1646 | 04ce 1230 IE_GETPDEVENT 1647 | 04cf 1231 IE_GETSELCOUNT 1648 | 04d0 1232 IE_GETSELITEMS 1649 | 04d1 1233 IE_GETSTYLE 1650 | 04db 1243 MCIWNDM_SETTIMEFORMATW 1651 | 04dc 1244 EM_OUTLINE 1652 | 04dc 1244 MCIWNDM_GETTIMEFORMATW 1653 | 04dd 1245 EM_GETSCROLLPOS 1654 | 04de 1246 EM_SETSCROLLPOS 1655 | 04de 1246 EM_SETSCROLLPOS 1656 | 04df 1247 EM_SETFONTSIZE 1657 | 04e0 1248 EM_GETZOOM 1658 | 04e0 1248 MCIWNDM_GETFILENAMEW 1659 | 04e1 1249 EM_SETZOOM 1660 | 04e1 1249 MCIWNDM_GETDEVICEW 1661 | 04e2 1250 EM_GETVIEWKIND 1662 | 04e3 1251 EM_SETVIEWKIND 1663 | 04e4 1252 EM_GETPAGE 1664 | 04e4 1252 MCIWNDM_GETERRORW 1665 | 04e5 1253 EM_SETPAGE 1666 | 04e6 1254 EM_GETHYPHENATEINFO 1667 | 04e7 1255 EM_SETHYPHENATEINFO 1668 | 04eb 1259 EM_GETPAGEROTATE 1669 | 04ec 1260 EM_SETPAGEROTATE 1670 | 04ed 1261 EM_GETCTFMODEBIAS 1671 | 04ee 1262 EM_SETCTFMODEBIAS 1672 | 04f0 1264 EM_GETCTFOPENSTATUS 1673 | 04f1 1265 EM_SETCTFOPENSTATUS 1674 | 04f2 1266 EM_GETIMECOMPTEXT 1675 | 04f3 1267 EM_ISIME 1676 | 04f4 1268 EM_GETIMEPROPERTY 1677 | 050d 1293 EM_GETQUERYRTFOBJ 1678 | 050e 1294 EM_SETQUERYRTFOBJ 1679 | 0600 1536 FM_GETFOCUS 1680 | 0601 1537 FM_GETDRIVEINFOA 1681 | 0602 1538 FM_GETSELCOUNT 1682 | 0603 1539 FM_GETSELCOUNTLFN 1683 | 0604 1540 FM_GETFILESELA 1684 | 0605 1541 FM_GETFILESELLFNA 1685 | 0606 1542 FM_REFRESH_WINDOWS 1686 | 0607 1543 FM_RELOAD_EXTENSIONS 1687 | 0611 1553 FM_GETDRIVEINFOW 1688 | 0614 1556 FM_GETFILESELW 1689 | 0615 1557 FM_GETFILESELLFNW 1690 | 0659 1625 WLX_WM_SAS 1691 | 07e8 2024 SM_GETSELCOUNT 1692 | 07e8 2024 UM_GETSELCOUNT 1693 | 07e8 2024 WM_CPL_LAUNCH 1694 | 07e9 2025 SM_GETSERVERSELA 1695 | 07e9 2025 UM_GETUSERSELA 1696 | 07e9 2025 WM_CPL_LAUNCHED 1697 | 07ea 2026 SM_GETSERVERSELW 1698 | 07ea 2026 UM_GETUSERSELW 1699 | 07eb 2027 SM_GETCURFOCUSA 1700 | 07eb 2027 UM_GETGROUPSELA 1701 | 07ec 2028 SM_GETCURFOCUSW 1702 | 07ec 2028 UM_GETGROUPSELW 1703 | 07ed 2029 SM_GETOPTIONS 1704 | 07ed 2029 UM_GETCURFOCUSA 1705 | 07ee 2030 UM_GETCURFOCUSW 1706 | 07ef 2031 UM_GETOPTIONS 1707 | 07f0 2032 UM_GETOPTIONS2 1708 | 1000 4096 LVM_FIRST 1709 | 1000 4096 LVM_GETBKCOLOR 1710 | 1001 4097 LVM_SETBKCOLOR 1711 | 1002 4098 LVM_GETIMAGELIST 1712 | 1003 4099 LVM_SETIMAGELIST 1713 | 1004 4100 LVM_GETITEMCOUNT 1714 | 1005 4101 LVM_GETITEMA 1715 | 1006 4102 LVM_SETITEMA 1716 | 1007 4103 LVM_INSERTITEMA 1717 | 1008 4104 LVM_DELETEITEM 1718 | 1009 4105 LVM_DELETEALLITEMS 1719 | 100a 4106 LVM_GETCALLBACKMASK 1720 | 100b 4107 LVM_SETCALLBACKMASK 1721 | 100c 4108 LVM_GETNEXTITEM 1722 | 100d 4109 LVM_FINDITEMA 1723 | 100e 4110 LVM_GETITEMRECT 1724 | 100f 4111 LVM_SETITEMPOSITION 1725 | 1010 4112 LVM_GETITEMPOSITION 1726 | 1011 4113 LVM_GETSTRINGWIDTHA 1727 | 1012 4114 LVM_HITTEST 1728 | 1013 4115 LVM_ENSUREVISIBLE 1729 | 1014 4116 LVM_SCROLL 1730 | 1015 4117 LVM_REDRAWITEMS 1731 | 1016 4118 LVM_ARRANGE 1732 | 1017 4119 LVM_EDITLABELA 1733 | 1018 4120 LVM_GETEDITCONTROL 1734 | 1019 4121 LVM_GETCOLUMNA 1735 | 101a 4122 LVM_SETCOLUMNA 1736 | 101b 4123 LVM_INSERTCOLUMNA 1737 | 101c 4124 LVM_DELETECOLUMN 1738 | 101d 4125 LVM_GETCOLUMNWIDTH 1739 | 101e 4126 LVM_SETCOLUMNWIDTH 1740 | 101f 4127 LVM_GETHEADER 1741 | 1021 4129 LVM_CREATEDRAGIMAGE 1742 | 1022 4130 LVM_GETVIEWRECT 1743 | 1023 4131 LVM_GETTEXTCOLOR 1744 | 1024 4132 LVM_SETTEXTCOLOR 1745 | 1025 4133 LVM_GETTEXTBKCOLOR 1746 | 1026 4134 LVM_SETTEXTBKCOLOR 1747 | 1027 4135 LVM_GETTOPINDEX 1748 | 1028 4136 LVM_GETCOUNTPERPAGE 1749 | 1029 4137 LVM_GETORIGIN 1750 | 102a 4138 LVM_UPDATE 1751 | 102b 4139 LVM_SETITEMSTATE 1752 | 102c 4140 LVM_GETITEMSTATE 1753 | 102d 4141 LVM_GETITEMTEXTA 1754 | 102e 4142 LVM_SETITEMTEXTA 1755 | 102f 4143 LVM_SETITEMCOUNT 1756 | 1030 4144 LVM_SORTITEMS 1757 | 1031 4145 LVM_SETITEMPOSITION32 1758 | 1032 4146 LVM_GETSELECTEDCOUNT 1759 | 1033 4147 LVM_GETITEMSPACING 1760 | 1034 4148 LVM_GETISEARCHSTRINGA 1761 | 1035 4149 LVM_SETICONSPACING 1762 | 1036 4150 LVM_SETEXTENDEDLISTVIEWSTYLE 1763 | 1037 4151 LVM_GETEXTENDEDLISTVIEWSTYLE 1764 | 1038 4152 LVM_GETSUBITEMRECT 1765 | 1039 4153 LVM_SUBITEMHITTEST 1766 | 103a 4154 LVM_SETCOLUMNORDERARRAY 1767 | 103b 4155 LVM_GETCOLUMNORDERARRAY 1768 | 103c 4156 LVM_SETHOTITEM 1769 | 103d 4157 LVM_GETHOTITEM 1770 | 103e 4158 LVM_SETHOTCURSOR 1771 | 103f 4159 LVM_GETHOTCURSOR 1772 | 1040 4160 LVM_APPROXIMATEVIEWRECT 1773 | 1041 4161 LVM_SETWORKAREAS 1774 | 1042 4162 LVM_GETSELECTIONMARK 1775 | 1043 4163 LVM_SETSELECTIONMARK 1776 | 1044 4164 LVM_SETBKIMAGEA 1777 | 1045 4165 LVM_GETBKIMAGEA 1778 | 1046 4166 LVM_GETWORKAREAS 1779 | 1047 4167 LVM_SETHOVERTIME 1780 | 1048 4168 LVM_GETHOVERTIME 1781 | 1049 4169 LVM_GETNUMBEROFWORKAREAS 1782 | 104a 4170 LVM_SETTOOLTIPS 1783 | 104b 4171 LVM_GETITEMW 1784 | 104c 4172 LVM_SETITEMW 1785 | 104d 4173 LVM_INSERTITEMW 1786 | 104e 4174 LVM_GETTOOLTIPS 1787 | 1053 4179 LVM_FINDITEMW 1788 | 1057 4183 LVM_GETSTRINGWIDTHW 1789 | 105f 4191 LVM_GETCOLUMNW 1790 | 1060 4192 LVM_SETCOLUMNW 1791 | 1061 4193 LVM_INSERTCOLUMNW 1792 | 1073 4211 LVM_GETITEMTEXTW 1793 | 1074 4212 LVM_SETITEMTEXTW 1794 | 1075 4213 LVM_GETISEARCHSTRINGW 1795 | 1076 4214 LVM_EDITLABELW 1796 | 108b 4235 LVM_GETBKIMAGEW 1797 | 108c 4236 LVM_SETSELECTEDCOLUMN 1798 | 108d 4237 LVM_SETTILEWIDTH 1799 | 108e 4238 LVM_SETVIEW 1800 | 108f 4239 LVM_GETVIEW 1801 | 1091 4241 LVM_INSERTGROUP 1802 | 1093 4243 LVM_SETGROUPINFO 1803 | 1095 4245 LVM_GETGROUPINFO 1804 | 1096 4246 LVM_REMOVEGROUP 1805 | 1097 4247 LVM_MOVEGROUP 1806 | 109a 4250 LVM_MOVEITEMTOGROUP 1807 | 109b 4251 LVM_SETGROUPMETRICS 1808 | 109c 4252 LVM_GETGROUPMETRICS 1809 | 109d 4253 LVM_ENABLEGROUPVIEW 1810 | 109e 4254 LVM_SORTGROUPS 1811 | 109f 4255 LVM_INSERTGROUPSORTED 1812 | 10a0 4256 LVM_REMOVEALLGROUPS 1813 | 10a1 4257 LVM_HASGROUP 1814 | 10a2 4258 LVM_SETTILEVIEWINFO 1815 | 10a3 4259 LVM_GETTILEVIEWINFO 1816 | 10a4 4260 LVM_SETTILEINFO 1817 | 10a5 4261 LVM_GETTILEINFO 1818 | 10a6 4262 LVM_SETINSERTMARK 1819 | 10a7 4263 LVM_GETINSERTMARK 1820 | 10a8 4264 LVM_INSERTMARKHITTEST 1821 | 10a9 4265 LVM_GETINSERTMARKRECT 1822 | 10aa 4266 LVM_SETINSERTMARKCOLOR 1823 | 10ab 4267 LVM_GETINSERTMARKCOLOR 1824 | 10ad 4269 LVM_SETINFOTIP 1825 | 10ae 4270 LVM_GETSELECTEDCOLUMN 1826 | 10af 4271 LVM_ISGROUPVIEWENABLED 1827 | 10b0 4272 LVM_GETOUTLINECOLOR 1828 | 10b1 4273 LVM_SETOUTLINECOLOR 1829 | 10b3 4275 LVM_CANCELEDITLABEL 1830 | 10b4 4276 LVM_MAPINDEXTOID 1831 | 10b5 4277 LVM_MAPIDTOINDEX 1832 | 10b6 4278 LVM_ISITEMVISIBLE 1833 | 2000 8192 OCM__BASE 1834 | 2005 8197 LVM_SETUNICODEFORMAT 1835 | 2006 8198 LVM_GETUNICODEFORMAT 1836 | 2019 8217 OCM_CTLCOLOR 1837 | 202b 8235 OCM_DRAWITEM 1838 | 202c 8236 OCM_MEASUREITEM 1839 | 202d 8237 OCM_DELETEITEM 1840 | 202e 8238 OCM_VKEYTOITEM 1841 | 202f 8239 OCM_CHARTOITEM 1842 | 2039 8249 OCM_COMPAREITEM 1843 | 204e 8270 OCM_NOTIFY 1844 | 2111 8465 OCM_COMMAND 1845 | 2114 8468 OCM_HSCROLL 1846 | 2115 8469 OCM_VSCROLL 1847 | 2132 8498 OCM_CTLCOLORMSGBOX 1848 | 2133 8499 OCM_CTLCOLOREDIT 1849 | 2134 8500 OCM_CTLCOLORLISTBOX 1850 | 2135 8501 OCM_CTLCOLORBTN 1851 | 2136 8502 OCM_CTLCOLORDLG 1852 | 2137 8503 OCM_CTLCOLORSCROLLBAR 1853 | 2138 8504 OCM_CTLCOLORSTATIC 1854 | 2210 8720 OCM_PARENTNOTIFY 1855 | 8000 32768 WM_APP 1856 | cccd 52429 WM_RASDIALEVENT 1857 | 1858 | */ 1859 | } 1860 | -------------------------------------------------------------------------------- /src/ImageScanOpenCV.cs: -------------------------------------------------------------------------------- 1 | using Emgu.CV; 2 | using Emgu.CV.CvEnum; 3 | using Emgu.CV.Structure; 4 | using Emgu.CV.Util; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Drawing; 8 | using System.IO; 9 | using System.Threading; 10 | 11 | namespace KAutoHelper 12 | { 13 | public class ImageScanOpenCV 14 | { 15 | /// 16 | /// Lấy image từ đường dẫn 17 | /// 18 | /// 19 | /// 20 | public static Bitmap GetImage(string path) 21 | { 22 | return new Bitmap(path); 23 | } 24 | 25 | /// 26 | /// Kiểm tra hình nhỏ có tồn tại trong hình lớn hay không (2 đường dẫn). theo tỷ lệ percent mặc định là 0.9 27 | /// 28 | /// 29 | /// 30 | /// 31 | /// 32 | public static Bitmap Find(string main, string sub, double percent = 0.9) 33 | { 34 | var mainImg = GetImage(main); 35 | var subImg = GetImage(sub); 36 | var res = Find(main, sub, percent); 37 | 38 | return res; 39 | } 40 | 41 | /// 42 | /// Kiểm tra hình nhỏ có tồn tại trong hình lớn hay không (2 image). theo tỷ lệ percent mặc định là 0.9 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | public static Bitmap Find(Bitmap mainBitmap, Bitmap subBitmap, double percent = 0.9) 49 | { 50 | for (int i = 0; i < 5; i++) 51 | { 52 | try 53 | { 54 | Image source = mainBitmap.ToImage(); 55 | Image template = subBitmap.ToImage(); 56 | Image imageToShow = source.Copy(); 57 | 58 | using (Image result = source.MatchTemplate(template, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) 59 | { 60 | double[] minValues, maxValues; 61 | System.Drawing.Point[] minLocations, maxLocations; 62 | result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); 63 | 64 | if (maxValues[0] > percent) 65 | { 66 | Rectangle match = new Rectangle(maxLocations[0], template.Size); 67 | imageToShow.Draw(match, new Bgr(System.Drawing.Color.Red), 2); 68 | } 69 | else 70 | { 71 | imageToShow = null; 72 | } 73 | } 74 | 75 | return imageToShow == null ? null : imageToShow.ToBitmap(); 76 | } 77 | catch { } 78 | } 79 | return null; 80 | } 81 | 82 | [System.Runtime.InteropServices.DllImport("gdi32.dll")] 83 | public static extern bool DeleteObject(IntPtr hObject); 84 | /// 85 | /// Đưa ra tọa độ của hình nhỏ trong hình lớn theo tỷ lệ chính xác đưa vào là percent mặc định là 0.9 86 | /// 87 | /// 88 | /// 89 | /// 90 | /// 91 | public static System.Drawing.Point? FindOutPoint(Bitmap mainBitmap, Bitmap subBitmap, double percent = 0.9) 92 | { 93 | if (subBitmap == null || mainBitmap == null) 94 | return null; 95 | 96 | if (subBitmap.Width > mainBitmap.Width || subBitmap.Height > mainBitmap.Height) 97 | return null; 98 | System.Drawing.Point? resPoint = null; 99 | for (int i = 0; i < 5; i++) 100 | { 101 | try 102 | { 103 | Image source = mainBitmap.ToImage(); 104 | Image template = subBitmap.ToImage(); 105 | 106 | using (Image result = source.MatchTemplate(template, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) 107 | { 108 | double[] minValues, maxValues; 109 | System.Drawing.Point[] minLocations, maxLocations; 110 | result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); 111 | 112 | if (maxValues[0] > percent) 113 | { 114 | resPoint = maxLocations[0]; 115 | } 116 | } 117 | break; 118 | } 119 | catch (Exception ex) 120 | { 121 | 122 | } 123 | } 124 | System.GC.Collect(); 125 | System.GC.WaitForPendingFinalizers(); 126 | return resPoint; 127 | } 128 | 129 | public static List FindOutPoints(Bitmap mainBitmap, Bitmap subBitmap, double percent = 0.9) 130 | { 131 | List resPoint = new List(); 132 | for (int i = 0; i < 5; i++) 133 | { 134 | try 135 | { 136 | Image source = mainBitmap.ToImage(); 137 | Image template = subBitmap.ToImage(); 138 | 139 | while (true) 140 | { 141 | using (Image result = source.MatchTemplate(template, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed)) 142 | { 143 | double[] minValues, maxValues; 144 | System.Drawing.Point[] minLocations, maxLocations; 145 | result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations); 146 | 147 | if (maxValues[0] > percent) 148 | { 149 | Rectangle match = new Rectangle(maxLocations[0], template.Size); 150 | source.Draw(match, new Bgr(Color.Blue), -1); 151 | resPoint.Add(maxLocations[0]); 152 | } 153 | else 154 | { 155 | break; 156 | } 157 | 158 | } 159 | } 160 | break; 161 | } 162 | catch { } 163 | } 164 | 165 | return resPoint; 166 | } 167 | 168 | /// 169 | /// Đưa ra danh sách tọa độ các pixcel thỏa mãn trong hình. 170 | /// Nếu không tìm thấy thì count = 0 171 | /// 172 | /// 173 | /// 174 | /// 175 | public static List FindColor(Bitmap mainBitmap, Color color) 176 | { 177 | int searchValue = color.ToArgb(); 178 | List result = new List(); 179 | using (Bitmap bmp = mainBitmap) 180 | { 181 | for (int x = 0; x < bmp.Width; x++) 182 | { 183 | for (int y = 0; y < bmp.Height; y++) 184 | { 185 | if (searchValue.Equals(bmp.GetPixel(x, y).ToArgb())) 186 | result.Add(new Point(x, y)); 187 | } 188 | } 189 | } 190 | return result; 191 | } 192 | 193 | /// 194 | /// Đưa ra danh sách tọa độ các pixcel thỏa mãn trong hình. 195 | /// Nếu không tìm thấy thì count = 0 196 | /// Đưa vào là mã màu Hex của color ví dụ: 197 | /// #FFFFFFFF 198 | /// 199 | /// 200 | /// 201 | /// 202 | public static List FindColor(Bitmap mainBitmap, string color) 203 | { 204 | Color Color = (Color)System.Windows.Media.ColorConverter.ConvertFromString(color); 205 | return FindColor(mainBitmap, Color); 206 | } 207 | 208 | public static void TestDilate(Bitmap bmp) 209 | { 210 | while (true) 211 | { 212 | 213 | Image imgOld = bmp.ToImage(); 214 | imgOld.Save("old.png"); 215 | Image img2 = (new Image(imgOld.Width, imgOld.Height, new Gray(255))).Sub(imgOld); 216 | img2.Save("img23.png"); 217 | Image eroded = new Image(img2.Size); 218 | Image temp = new Image(img2.Size); 219 | Image skel = new Image(img2.Size); 220 | skel.SetValue(0); 221 | CvInvoke.Threshold(img2, img2, 127, 255, 0); 222 | var element = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(2, 2), new Point(-1, -1)); 223 | bool done = false; 224 | 225 | //while (!done) 226 | { 227 | CvInvoke.Dilate(imgOld, eroded, element, new Point(-1, -1), 1, BorderType.Reflect, default(MCvScalar)); 228 | //CvInvoke.Erode(img2, eroded, element, new Point(-1, -1), 1, BorderType.Reflect, default(MCvScalar)); 229 | //CvInvoke.Dilate(eroded, temp, element, new Point(-1, -1), 1, BorderType.Reflect, default(MCvScalar)); 230 | //CvInvoke.Subtract(img2, temp, temp); 231 | //CvInvoke.BitwiseOr(skel, temp, skel); 232 | eroded.CopyTo(img2); 233 | //if (CvInvoke.CountNonZero(img2) == 0) done = true; 234 | } 235 | //return skel.Bitmap; 236 | 237 | skel.ToBitmap().Save("ele.png"); 238 | img2.Save("img2.png"); 239 | eroded.Save("eroded.png"); 240 | temp.Save("temp.png"); 241 | } 242 | } 243 | 244 | 245 | /// 246 | /// Đọc chữ từ hình 247 | /// 248 | /// 249 | /// 250 | public static string RecolizeText(Bitmap img) 251 | { 252 | string text = ""; 253 | 254 | text = Get_Text_From_Image.Get_Text(img); 255 | 256 | return text; 257 | } 258 | 259 | public static void SplitImageInFolder(string folderPath) 260 | { 261 | DirectoryInfo dir = new DirectoryInfo(folderPath); 262 | foreach (var item in dir.GetFiles()) 263 | { 264 | Bitmap Bm_image_sour = new Bitmap(item.FullName); 265 | Bitmap image_new = Get_Text_From_Image.make_new_image(Bm_image_sour.ToImage().ToBitmap()); 266 | Bm_image_sour.Dispose(); 267 | 268 | int cout_picture = Get_Text_From_Image.split_image(image_new, Path.GetFileNameWithoutExtension(item.Name)); 269 | } 270 | } 271 | 272 | public static Bitmap ThreshHoldBinary(Bitmap bmp, byte threshold = 190) 273 | { 274 | Image img = bmp.ToImage(); 275 | 276 | var bmp1 = img.ThresholdBinary(new Gray(threshold), new Gray(255)); 277 | 278 | //bmp1.Save("adasdsad.png"); 279 | 280 | return bmp1.ToBitmap(); 281 | } 282 | 283 | public static Bitmap NotWhiteToTransparentPixelReplacement(Bitmap bmp) 284 | { 285 | bmp = CreateNonIndexedImage(bmp); 286 | for (var x = 0; x < bmp.Width; x++) 287 | for (var y = 0; y < bmp.Height; y++) 288 | { 289 | var pixel = bmp.GetPixel(x, y); 290 | if (pixel.R > 200 && pixel.G > 200 && pixel.B > 200) 291 | bmp.SetPixel(x, y, Color.Transparent); 292 | } 293 | 294 | return bmp; 295 | } 296 | 297 | public static Bitmap WhiteToBlackPixelReplacement(Bitmap bmp) 298 | { 299 | bmp = CreateNonIndexedImage(bmp); 300 | for (var x = 0; x < bmp.Width; x++) 301 | for (var y = 0; y < bmp.Height; y++) 302 | { 303 | var pixel = bmp.GetPixel(x, y); 304 | if (pixel.R > 20 && pixel.G > 230 && pixel.B > 230) 305 | bmp.SetPixel(x, y, Color.Black); 306 | } 307 | 308 | return bmp; 309 | } 310 | 311 | public static Bitmap TransparentToWhitePixelReplacement(Bitmap bmp) 312 | { 313 | bmp = CreateNonIndexedImage(bmp); 314 | for (var x = 0; x < bmp.Width; x++) 315 | for (var y = 0; y < bmp.Height; y++) 316 | { 317 | var pixel = bmp.GetPixel(x, y); 318 | if (pixel.A >= 1) 319 | bmp.SetPixel(x, y, Color.White); 320 | } 321 | 322 | return bmp; 323 | } 324 | 325 | public static Bitmap CreateNonIndexedImage(Image src) 326 | { 327 | Bitmap newBmp = new Bitmap(src.Width, src.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); 328 | 329 | using (Graphics gfx = Graphics.FromImage(newBmp)) 330 | { 331 | gfx.DrawImage(src, 0, 0); 332 | } 333 | 334 | return newBmp; 335 | } 336 | 337 | public static Bitmap ScanShape(Bitmap img) 338 | { 339 | 340 | if (img == null) 341 | { 342 | return null; 343 | } 344 | 345 | try 346 | { 347 | Image imgInput = img.ToImage(); 348 | 349 | var temp = imgInput.SmoothGaussian(5).Convert().ThresholdBinaryInv(new Gray(10), new Gray(255)); 350 | //temp.Save("bbb.png"); 351 | VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint(); 352 | Mat m = new Mat(); 353 | 354 | CvInvoke.FindContours(temp, contours, m, Emgu.CV.CvEnum.RetrType.External, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple); 355 | 356 | for (int i = 0; i < contours.Size; i++) 357 | { 358 | double perimeter = CvInvoke.ArcLength(contours[i], true); 359 | VectorOfPoint approx = new VectorOfPoint(); 360 | CvInvoke.ApproxPolyDP(contours[i], approx, 0.04 * perimeter, true); 361 | 362 | CvInvoke.DrawContours(imgInput, contours, i, new MCvScalar(0, 0, 255), 2); 363 | 364 | //moments center of the shape 365 | 366 | var moments = CvInvoke.Moments(contours[i]); 367 | int x = (int)(moments.M10 / moments.M00); 368 | int y = (int)(moments.M01 / moments.M00); 369 | 370 | if (approx.Size == 3) 371 | { 372 | CvInvoke.PutText(imgInput, "Triangle", new Point(x, y), 373 | Emgu.CV.CvEnum.FontFace.HersheySimplex, 0.5, new MCvScalar(0, 0, 255), 2); 374 | } 375 | 376 | if (approx.Size == 4) 377 | { 378 | Rectangle rect = CvInvoke.BoundingRectangle(contours[i]); 379 | 380 | double ar = (double)rect.Width / rect.Height; 381 | 382 | if (ar >= 0.95 && ar <= 1.05) 383 | { 384 | CvInvoke.PutText(imgInput, "Square", new Point(x, y), 385 | Emgu.CV.CvEnum.FontFace.HersheySimplex, 0.5, new MCvScalar(0, 0, 255), 2); 386 | } 387 | else 388 | { 389 | CvInvoke.PutText(imgInput, "Rectangle", new Point(x, y), 390 | Emgu.CV.CvEnum.FontFace.HersheySimplex, 0.5, new MCvScalar(0, 0, 255), 2); 391 | } 392 | 393 | } 394 | 395 | if (approx.Size == 6) 396 | { 397 | CvInvoke.PutText(imgInput, "Hexagon", new Point(x, y), 398 | Emgu.CV.CvEnum.FontFace.HersheySimplex, 0.5, new MCvScalar(0, 0, 255), 2); 399 | } 400 | 401 | 402 | if (approx.Size > 6) 403 | { 404 | CvInvoke.PutText(imgInput, "Circle", new Point(x, y), 405 | Emgu.CV.CvEnum.FontFace.HersheySimplex, 0.5, new MCvScalar(0, 0, 255), 2); 406 | } 407 | 408 | } 409 | return imgInput.ToBitmap(); 410 | } 411 | catch (Exception ex) 412 | { 413 | return null; 414 | //MessageBox.Show(ex.Message); 415 | } 416 | } 417 | } 418 | 419 | 420 | public class Get_Text_From_Image 421 | { 422 | private static int saisot = 5; 423 | private static int red = 217; 424 | private static int collor_Byte_Start = 160; 425 | private static string path_langue = @"C:\"; 426 | static string TempFolder = "image_temp"; 427 | static string StandarFolder = "image_standand"; 428 | 429 | 430 | private static List TemplateColors = new List() 431 | { 432 | Color.FromArgb(255,0,0,0) 433 | }; 434 | 435 | public static void information(string Path_Langue) 436 | { 437 | path_langue = Path_Langue; 438 | } 439 | 440 | public static string Get_Text(Bitmap Bm_image_sour) 441 | { 442 | string text = ""; 443 | 444 | Bitmap image_new = (Bitmap)Bm_image_sour.Clone();// make_new_image(new Image(Bm_image_sour).ToBitmap()); 445 | //image_new.Save("aaaaa.png"); 446 | Bm_image_sour.Dispose(); 447 | 448 | int cout_picture = split_image(image_new); 449 | 450 | text = Get_Text(cout_picture); 451 | 452 | return text; 453 | } 454 | 455 | 456 | #region Sub Function 457 | 458 | public static Bitmap make_new_image(Bitmap Bm_image_sour) 459 | { 460 | //infor image and make a new bitmap same size 461 | int _width = Bm_image_sour.Width; 462 | int _height = Bm_image_sour.Height; 463 | 464 | Bitmap Bm_image = new Bitmap(_width, _height); 465 | 466 | // set color cho điểm pixel của mà các chỉ số màu A,R,B,G thỏa mãn trong phạm vi sai sót cho phép 467 | int collor_Byte_Stop = 230; 468 | for (int i = collor_Byte_Start; i < collor_Byte_Stop; i++) 469 | { 470 | red = i; 471 | Get_List_Point(); 472 | } 473 | return Bm_image; 474 | 475 | #region ham con 476 | void Get_List_Point() 477 | { 478 | // get point 479 | for (int i = 0; i < _width; i++) 480 | { 481 | for (int j = 0; j < _height; j++) 482 | { 483 | Color color = Bm_image_sour.GetPixel(i, j); 484 | 485 | if (Check_sailenh_Color(color, TemplateColors, saisot)) 486 | { 487 | try 488 | { 489 | Bm_image.SetPixel(i, j, Color.Black); 490 | } 491 | catch (Exception) { } 492 | } 493 | 494 | } 495 | } 496 | } 497 | 498 | bool Check_sailenh_Color(Color indexColor, List templateColor, int sailech) 499 | { 500 | bool result = false; 501 | 502 | foreach (var item in templateColor) 503 | { 504 | if ((indexColor.R + sailech >= item.R && indexColor.R - sailech <= item.R) 505 | && (indexColor.G + sailech >= item.G && indexColor.G - sailech <= item.G) 506 | && (indexColor.B + sailech >= item.B && indexColor.B - sailech <= item.B)) 507 | { 508 | result = true; 509 | break; 510 | } 511 | } 512 | 513 | return result; 514 | } 515 | #endregion 516 | } 517 | 518 | public static int split_image(Bitmap image, string name = "") 519 | { 520 | //sự dụng bitmap image để tách image 521 | image.Save("aaa.png"); 522 | int cout_picture = 0; 523 | bool is_start = false; 524 | int width_start = 0; 525 | int width_stop = 0; 526 | int _height_top = 200; 527 | int _height_bottom = 0; 528 | 529 | int _width = image.Width; 530 | int _height = image.Height; 531 | 532 | for (int i = 0; i < _width; i++) 533 | { 534 | int cout_Black = 0; 535 | 536 | 537 | for (int j = 0; j < _height; j++) 538 | { 539 | Color color = image.GetPixel(i, j); 540 | 541 | if (color.Name != "ff000000") 542 | { 543 | cout_Black++; 544 | 545 | if (_height_top > j) _height_top = j; 546 | if (_height_bottom < j) _height_bottom = j; 547 | 548 | } 549 | else 550 | { 551 | 552 | } 553 | } 554 | if (cout_Black > 1 && is_start == false) 555 | { 556 | width_start = i - 1; is_start = true; 557 | } 558 | if (cout_Black < 1 && is_start == true) 559 | { 560 | width_stop = i + 1; is_start = false; 561 | save_image_splip(); 562 | cout_picture++; 563 | _height_top = 200; 564 | _height_bottom = 0; 565 | } 566 | } 567 | 568 | void save_image_splip() 569 | { 570 | int _width_image_slip = width_stop - width_start; 571 | int _height_image_split = _height_bottom - _height_top; 572 | Bitmap image_split = new Bitmap(_width_image_slip, _height_image_split); 573 | for (int i = 0; i < _width_image_slip; i++) 574 | { 575 | for (int j = 0; j < _height_image_split; j++) 576 | { 577 | try 578 | { 579 | Color color_image_split = image.GetPixel(width_start + i, _height_top + j); 580 | image_split.SetPixel(i, j, color_image_split); 581 | } 582 | catch { } 583 | 584 | } 585 | } 586 | 587 | string path_folder = TempFolder; 588 | check_folder_exists(path_folder); 589 | string output = path_folder + @"\" + name + cout_picture + ".jpg"; 590 | 591 | //=>kiem tra thu muc ton tai 592 | 593 | image_split.Save(output); 594 | image_split.Dispose(); 595 | } 596 | 597 | 598 | return cout_picture; 599 | } 600 | 601 | 602 | protected static string Get_Text(int cout_picture) 603 | { 604 | string text = ""; 605 | List character = new List() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 606 | for (int i = 0; i < cout_picture; i++) 607 | { 608 | List ketqua = new List(); 609 | for (int j = 0; j < character.Count; j++) 610 | { 611 | try 612 | { 613 | string name_text = character[j]; 614 | double max = 0; 615 | double currentMax = 0; 616 | string folderPath = StandarFolder + @"\" + name_text; 617 | DirectoryInfo dir = new DirectoryInfo(folderPath); 618 | foreach (var item in dir.GetFiles()) 619 | { 620 | string path_image_standate = item.FullName; 621 | Bitmap standand = new Bitmap(path_image_standate); 622 | 623 | string path_image = TempFolder + @"\" + i + ".jpg"; 624 | Bitmap main = new Bitmap(path_image); 625 | currentMax = Image_Equal(main, standand); 626 | standand.Dispose(); 627 | main.Dispose(); 628 | 629 | if (currentMax > max) 630 | { 631 | max = currentMax; 632 | } 633 | } 634 | 635 | ketqua.Add(max); 636 | } 637 | catch { } 638 | } 639 | 640 | int index_max_trung = 0; 641 | double _ketqua = 0; 642 | for (int j = 0; j < character.Count; j++) 643 | { 644 | if (_ketqua < ketqua[j]) 645 | { 646 | _ketqua = ketqua[j]; 647 | index_max_trung = j; 648 | } 649 | } 650 | 651 | text += character[index_max_trung]; 652 | } 653 | return text; 654 | } 655 | 656 | public static double Image_Equal(Bitmap main, Bitmap standand) 657 | { 658 | double count = 0; 659 | double trung = 0; 660 | 661 | //int _max_width = standand.Width; 662 | //int _max_height = standand.Height; 663 | //if (main.Width > standand.Width) _max_width = main.Width; 664 | //if (main.Height > standand.Height) _max_height = main.Height; 665 | 666 | Bitmap sub = new Bitmap(main, new System.Drawing.Size(standand.Width, standand.Height)); 667 | 668 | for (int i = 0; i < standand.Width; i++) 669 | { 670 | for (int j = 0; j < standand.Height; j++) 671 | { 672 | count++; 673 | if (sub.GetPixel(i, j).Equals(standand.GetPixel(i, j))) 674 | { 675 | trung += 1; 676 | } 677 | } 678 | } 679 | 680 | return trung / count; 681 | } 682 | 683 | protected static void check_folder_exists(string path) 684 | { 685 | bool is_exists = Directory.Exists(path); 686 | if (!is_exists) 687 | { 688 | Directory.CreateDirectory(path); 689 | } 690 | } 691 | #endregion 692 | } 693 | } 694 | -------------------------------------------------------------------------------- /src/KAutoHelper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48;net6.0-windows7.0 5 | enable 6 | 10.0 7 | true 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/KAutoHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30330.147 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KAutoHelper", "KAutoHelper.csproj", "{26C455C5-143C-4E6D-85F4-BBE85CDE8A42}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Debug|x64.ActiveCfg = Debug|x64 21 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Debug|x64.Build.0 = Debug|x64 22 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Debug|x86.ActiveCfg = Debug|x86 23 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Debug|x86.Build.0 = Debug|x86 24 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Release|x64.ActiveCfg = Release|x64 27 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Release|x64.Build.0 = Release|x64 28 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Release|x86.ActiveCfg = Release|x86 29 | {26C455C5-143C-4E6D-85F4-BBE85CDE8A42}.Release|x86.Build.0 = Release|x86 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {F33F5E13-8C82-4419-B1AA-3D9DD94F95FF} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /src/LDPlayer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace KAutoHelper 10 | { 11 | public class LDPlayer 12 | { 13 | public static string pathLD = @"C:\LDPlayer\LDPlayer4.0\ldconsole.exe"; 14 | //----------------------Tương Tác Tab Giả Lập--------------------------------// 15 | 16 | //Nhóm 1 - Thao Tác 17 | 18 | public void Open(string param, string NameOrId) 19 | { 20 | ExecuteLD(string.Format("launch --{0} {1}", param, NameOrId)); 21 | } 22 | 23 | public void Open_App(string param, string NameOrId, string Package_Name) 24 | { 25 | ExecuteLD(string.Format("launchex --{0} {1} --packagename {2}", param, NameOrId, Package_Name)); 26 | } 27 | 28 | public void Close(string param, string NameOrId) 29 | { 30 | ExecuteLD(string.Format("quit --{0} {1}", param, NameOrId)); 31 | } 32 | 33 | public void CloseAll() 34 | { 35 | ExecuteLD("quitall"); 36 | } 37 | 38 | public void ReBoot(string param, string NameOrId) 39 | { 40 | ExecuteLD(string.Format("reboot --{0} {1}", param, NameOrId)); 41 | } 42 | 43 | //Nhóm 2 - Tuỳ Chỉnh Thêm 44 | 45 | public void Create(string Name) 46 | { 47 | ExecuteLD("add --name " + Name); 48 | } 49 | 50 | public void Copy(string Name, string From_NameOrId) 51 | { 52 | ExecuteLD(string.Format("copy --name {0} --from {1}", Name, From_NameOrId)); 53 | } 54 | 55 | public void Delete(string param, string NameOrId) 56 | { 57 | ExecuteLD(string.Format("remove --{0} {1}", param, NameOrId)); 58 | } 59 | 60 | public void ReName(string param, string NameOrId, string title_new) 61 | { 62 | ExecuteLD(string.Format("rename --{0} {1} --title {2}", param, NameOrId, title_new)); 63 | } 64 | 65 | //Nhóm 3 - Change Setting 66 | 67 | public void InstallApp_File(string param, string NameOrId, string File_Name) 68 | { 69 | ExecuteLD(string.Format(@"installapp --{0} {1} --filename ""{2}""", param, NameOrId, File_Name)); 70 | } 71 | 72 | public void InstallApp_Package(string param, string NameOrId, string Package_Name) 73 | { 74 | ExecuteLD(string.Format("installapp --{0} {1} --packagename {2}", param, NameOrId, Package_Name)); 75 | } 76 | 77 | public void UnInstallApp(string param, string NameOrId, string Package_Name) 78 | { 79 | ExecuteLD(string.Format("uninstallapp --{0} {1} --packagename {2}", param, NameOrId, Package_Name)); 80 | } 81 | 82 | public void RunApp(string param, string NameOrId, string Package_Name) 83 | { 84 | ExecuteLD(string.Format("runapp --{0} {1} --packagename {2}", param, NameOrId, Package_Name)); 85 | } 86 | 87 | public void KillApp(string param, string NameOrId, string Package_Name) 88 | { 89 | ExecuteLD(string.Format("killapp --{0} {1} --packagename {2}", param, NameOrId, Package_Name)); 90 | } 91 | 92 | public void Locate(string param, string NameOrId, string Lng, string Lat) 93 | { 94 | ExecuteLD(string.Format("locate --{0} {1} --LLI {2},{3}", param, NameOrId, Lng, Lat)); 95 | } 96 | 97 | public void Change_Property(string param, string NameOrId, string cmd) 98 | { 99 | ExecuteLD(string.Format("modify --{0} {1} {2}", param, NameOrId, cmd)); 100 | //[--resolution ] 101 | //[--cpu < 1 | 2 | 3 | 4 >] 102 | //[--memory < 512 | 1024 | 2048 | 4096 | 8192 >] 103 | //[--manufacturer asus] 104 | //[--model ASUS_Z00DUO] 105 | //[--pnumber 13812345678] 106 | //[--imei ] 107 | //[--imsi ] 108 | //[--simserial ] 109 | //[--androidid ] 110 | //[--mac ] 111 | //[--autorotate < 1 | 0 >] 112 | //[--lockwindow < 1 | 0 >] 113 | } 114 | 115 | public void SetProp(string param, string NameOrId, string key, string value) 116 | { 117 | ExecuteLD(string.Format("setprop --{0} {1} --key {2} --value {3}", param, NameOrId, key, value)); 118 | } 119 | 120 | public string GetProp(string param, string NameOrId, string key) 121 | { 122 | return ExecuteLD_Result(string.Format("getprop --{0} {1} --key {2}", param, NameOrId, key)); 123 | } 124 | 125 | public string ADB(string param, string NameOrId, string cmd) 126 | { 127 | return ExecuteLD_Result(string.Format("adb --{0} {1} --command {2}", param, NameOrId, cmd)); 128 | } 129 | 130 | public void DownCPU(string param, string NameOrId, string rate) 131 | { 132 | ExecuteLD(string.Format("downcpu --{0} {1} --rate {2}", param, NameOrId, rate)); 133 | } 134 | 135 | public void Backup(string param, string NameOrId, string file_path) 136 | { 137 | ExecuteLD(string.Format(@"backup --{0} {1} --file ""{2}""", param, NameOrId, file_path)); 138 | } 139 | 140 | public void Restore(string param, string NameOrId, string file_path) 141 | { 142 | ExecuteLD(string.Format(@"restore --{0} {1} --file ""{2}""", param, NameOrId, file_path)); 143 | } 144 | 145 | public void Action(string param, string NameOrId, string key, string value) 146 | { 147 | ExecuteLD(string.Format("action --{0} {1} --key {2} --value {3}", param, NameOrId, key, value)); 148 | } 149 | 150 | public void Scan(string param, string NameOrId, string file_path) 151 | { 152 | ExecuteLD(string.Format("scan --{0} {1} --file {2}", param, NameOrId, file_path)); 153 | } 154 | 155 | public void SortWnd() 156 | { 157 | ExecuteLD("sortWnd"); 158 | } 159 | 160 | public void zoomIn(string param, string NameOrId) 161 | { 162 | ExecuteLD(string.Format("zoomIn --{0} {1}", param, NameOrId)); 163 | } 164 | 165 | public void zoomOut(string param, string NameOrId) 166 | { 167 | ExecuteLD(string.Format("zoomOut --{0} {1}", param, NameOrId)); 168 | } 169 | 170 | public void Pull(string param, string NameOrId, string remote_file_path, string local_file_path) 171 | { 172 | ExecuteLD(string.Format(@"pull --{0} {1} --remote ""{2}"" --local ""{3}""", param, NameOrId, remote_file_path, local_file_path)); 173 | } 174 | 175 | public void Push(string param, string NameOrId, string remote_file_path, string local_file_path) 176 | { 177 | ExecuteLD(string.Format(@"push --{0} {1} --remote ""{2}"" --local ""{3}""", param, NameOrId, remote_file_path, local_file_path)); 178 | } 179 | 180 | public void BackupApp(string param, string NameOrId, string Package_Name, string file_path) 181 | { 182 | ExecuteLD(string.Format(@"backupapp --{0} {1} --packagename {2} --file ""{3}""", param, NameOrId, Package_Name, file_path)); 183 | } 184 | 185 | public void RestoreApp(string param, string NameOrId, string Package_Name, string file_path) 186 | { 187 | ExecuteLD(string.Format(@"restoreapp --{0} {1} --packagename {2} --file ""{3}""", param, NameOrId, Package_Name, file_path)); 188 | } 189 | 190 | public void Golabal_Config(string param, string NameOrId, string fps, string audio, string fast_play, string clean_mode) 191 | { 192 | // [--fps <0~60>] [--audio <1 | 0>] [--fastplay <1 | 0>] [--cleanmode <1 | 0>] 193 | ExecuteLD(string.Format("globalsetting --{0} {1} --audio {2} --fastplay {3} --cleanmode {4}", param, NameOrId, audio, fast_play, clean_mode)); 194 | } 195 | 196 | public List GetDevices() 197 | { 198 | string[] arr = ExecuteLD_Result("list").Trim().Split('\n'); 199 | for (int i = 0; i < arr.Length; i++) 200 | { 201 | if (arr[i] == "") 202 | return new List(); 203 | arr[i] = arr[i].Trim(); 204 | } 205 | //System.Windows.Forms.MessageBox.Show(string.Join("|", arr)); 206 | return arr.ToList(); 207 | } 208 | 209 | public List GetDevices_Running() 210 | { 211 | string[] arr = ExecuteLD_Result("runninglist").Trim().Split('\n'); 212 | for (int i = 0; i < arr.Length; i++) 213 | { 214 | if (arr[i] == "") 215 | return new List(); 216 | arr[i] = arr[i].Trim(); 217 | } 218 | //System.Windows.Forms.MessageBox.Show(string.Join("|", arr)); 219 | return arr.ToList(); 220 | } 221 | 222 | public bool IsDevice_Running(string param, string NameOrId) 223 | { 224 | string result = ExecuteLD_Result(string.Format("isrunning --{0} {1}", param, NameOrId)).Trim(); 225 | if (result == "running") 226 | return true; 227 | return false; 228 | } 229 | 230 | public List GetDevices2() 231 | { 232 | try 233 | { 234 | List listLDPlayer = new List(); 235 | string[] arr = ExecuteLD_Result("list2").Trim().Split('\n'); 236 | for (int i = 0; i < arr.Length; i++) 237 | { 238 | Info_Devices devices = new Info_Devices(); 239 | string[] aDetail = arr[i].Trim().Split(','); 240 | devices.index = int.Parse(aDetail[0]); 241 | devices.name = aDetail[1]; 242 | devices.adb_id = "-1"; 243 | listLDPlayer.Add(devices); 244 | } 245 | //System.Windows.Forms.MessageBox.Show(string.Join("\n", arr)); 246 | return listLDPlayer; 247 | } 248 | catch 249 | { 250 | return new List(); 251 | } 252 | } 253 | 254 | public List GetDevices2_Running() 255 | { 256 | try 257 | { 258 | int j = 0; 259 | List list_adb_id = ADBHelper.GetDevices(); 260 | List listLDPlayer = new List(); 261 | List device_running = GetDevices_Running(); 262 | string[] arr = ExecuteLD_Result("list2").Trim().Split('\n'); 263 | for (int i = 0; i < arr.Length; i++) 264 | { 265 | Info_Devices devices = new Info_Devices(); 266 | string[] aDetail = arr[i].Trim().Split(','); 267 | devices.index = int.Parse(aDetail[0]); 268 | devices.name = aDetail[1]; 269 | if (device_running.Contains(devices.name)) 270 | { 271 | devices.adb_id = list_adb_id[j]; 272 | listLDPlayer.Add(devices); 273 | j++; 274 | } 275 | } 276 | return listLDPlayer; 277 | } 278 | catch 279 | { 280 | return new List(); 281 | } 282 | //System.Windows.Forms.MessageBox.Show(string.Join("\n", arr)); 283 | } 284 | 285 | public void ExecuteLD(string cmd) 286 | { 287 | Process p = new Process(); 288 | p.StartInfo.FileName = pathLD; 289 | p.StartInfo.Arguments = cmd; 290 | p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 291 | p.StartInfo.UseShellExecute = false; 292 | p.StartInfo.CreateNoWindow = true; 293 | p.EnableRaisingEvents = true; 294 | p.Start(); 295 | p.WaitForExit(); 296 | p.Close(); 297 | } 298 | 299 | public string ExecuteLD_Result(string cmdCommand) 300 | { 301 | string result; 302 | try 303 | { 304 | Process process = new Process(); 305 | process.StartInfo = new ProcessStartInfo 306 | { 307 | FileName = pathLD, 308 | Arguments = cmdCommand, 309 | CreateNoWindow = true, 310 | UseShellExecute = false, 311 | WindowStyle = ProcessWindowStyle.Hidden, 312 | RedirectStandardInput = true, 313 | RedirectStandardOutput = true 314 | }; 315 | process.Start(); 316 | process.WaitForExit(); 317 | string text = process.StandardOutput.ReadToEnd(); 318 | result = text; 319 | } 320 | catch 321 | { 322 | result = null; 323 | } 324 | return result; 325 | } 326 | 327 | // Điều Hướng 328 | public void Back(string deviceID) 329 | { 330 | ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_BACK); 331 | } 332 | 333 | public void Home(string deviceID) 334 | { 335 | ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_HOME); 336 | } 337 | 338 | public void Menu(string deviceID) 339 | { 340 | ADBHelper.Key(deviceID, ADBKeyEvent.KEYCODE_APP_SWITCH); 341 | } 342 | 343 | //IMG OpenCV 344 | public void Tap_Img(string deviceID, Bitmap ImgFind) 345 | { 346 | Bitmap bm = (Bitmap)ImgFind.Clone(); 347 | var screen = ADBHelper.ScreenShoot(deviceID); 348 | var Point = ImageScanOpenCV.FindOutPoint(screen, bm); 349 | if (Point != null) 350 | { 351 | ADBHelper.Tap(deviceID, Point.Value.X, Point.Value.Y); 352 | return; 353 | } 354 | //MessageBox.Show("Tìm không ra"); 355 | } 356 | 357 | //Change Proxy 358 | public void Change_Proxy(string deviceID, string ip_proxy, string port_proxy) 359 | { 360 | ADBHelper.ExecuteCMD(string.Format("adb -s {0} shell settings put global http_proxy {1}:{2}", deviceID, ip_proxy, port_proxy)); 361 | } 362 | 363 | public void Remove_Proxy(string deviceID) 364 | { 365 | ADBHelper.ExecuteCMD(string.Format("adb -s {0} shell settings put global http_proxy :0", deviceID)); 366 | } 367 | } 368 | 369 | public struct Info_Devices 370 | { 371 | public int index; 372 | public string name; 373 | public string adb_id; 374 | } 375 | } 376 | -------------------------------------------------------------------------------- /src/License-LGPL.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | 506 | 507 | -------------------------------------------------------------------------------- /src/MemoryHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace KAutoHelper 9 | { 10 | public class MemoryHelper 11 | { 12 | #region Memory API 13 | [DllImport("kernel32.dll")] 14 | static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Boolean bInheritHandle, UInt32 dwProcessId); 15 | [DllImport("kernel32.dll")] 16 | static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, 17 | byte[] lpBuffer, UIntPtr nSize, uint lpNumberOfBytesWritten); 18 | [DllImport("kernel32.dll", SetLastError = true)] 19 | public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, Int32 nSize, out IntPtr lpNumberOfBytesWritten); 20 | [DllImport("kernel32.dll", SetLastError = true)] 21 | public static extern bool WriteProcessMemory( IntPtr hProcess, IntPtr lpBaseAddress, [MarshalAs(UnmanagedType.AsAny)] object lpBuffer, int dwSize, out IntPtr lpNumberOfBytesWritten); 22 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] 23 | internal static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, FreeType dwFreeType); 24 | [DllImport("kernel32.dll", SetLastError = true)] 25 | internal static extern UInt32 WaitForSingleObject(IntPtr hProcess, UInt32 dwMilliseconds); 26 | [DllImport("kernel32.dll")] 27 | internal static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, IntPtr dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId); 28 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] 29 | internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, UInt32 flAllocationType, UInt32 flProtect); 30 | [DllImport("kernel32.dll")] 31 | internal static extern Int32 CloseHandle(IntPtr hProcess); 32 | [DllImport("kernel32", SetLastError = true)] 33 | public static extern int GetProcessId(IntPtr hProcess); 34 | 35 | [DllImport("user32.dll", SetLastError = true)] 36 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); 37 | 38 | // When you don't want the ProcessId, use this overload and pass IntPtr.Zero for the second parameter 39 | [DllImport("user32.dll")] 40 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId); 41 | 42 | 43 | const UInt32 INFINITE = 0xFFFFFFFF; 44 | const UInt32 WAIT_ABANDONED = 0x00000080; 45 | const UInt32 WAIT_OBJECT_0 = 0x00000000; 46 | const UInt32 WAIT_TIMEOUT = 0x00000102; 47 | #endregion 48 | 49 | 50 | public static IntPtr OpenProcess(int pId, ProcessAccessFlags ProcessAccess = ProcessAccessFlags.All) 51 | { 52 | return OpenProcess((uint)ProcessAccess, false, (uint)pId); 53 | } 54 | public static IntPtr OpenProcess(uint pId, ProcessAccessFlags ProcessAccess = ProcessAccessFlags.All) 55 | { 56 | return OpenProcess((uint)ProcessAccess, false, pId); 57 | } 58 | 59 | public static int AllocateMemory(IntPtr ProcessHandle, int memorySize) 60 | { 61 | return (int)VirtualAllocEx(ProcessHandle, (IntPtr)0, (IntPtr)memorySize, 0x1000, 0x40); 62 | } 63 | public static IntPtr CreateRemoteThread(IntPtr ProcessHandle, int address) 64 | { 65 | return CreateRemoteThread(ProcessHandle, (IntPtr)0, (IntPtr)0, (IntPtr)address, (IntPtr)0, 0, (IntPtr)0); 66 | } 67 | public static void WaitForSingleObject(IntPtr ProcessHandle, IntPtr threadHandle) 68 | { 69 | if (WaitForSingleObject(threadHandle, INFINITE) != WAIT_OBJECT_0) 70 | { 71 | Console.WriteLine("Failed waiting for single object"); 72 | } 73 | } 74 | public static void FreeMemory(IntPtr ProcessHandle, int address) 75 | { 76 | bool result; 77 | result = VirtualFreeEx(ProcessHandle, (IntPtr)address, (IntPtr)0, FreeType.Release); 78 | } 79 | public static void CloseProcess(IntPtr ProcessHandle, IntPtr handle) 80 | { 81 | Int32 result = CloseHandle(handle); 82 | } 83 | 84 | #region write memory 85 | public static bool WriteInt(IntPtr Handle, IntPtr pointer, uint offset, int value) 86 | { 87 | byte[] bytes = BitConverter.GetBytes(value); 88 | bool success = false; 89 | 90 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 91 | IntPtr nBytesRead = IntPtr.Zero; 92 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 93 | return success; 94 | } 95 | 96 | public static bool WriteFloat(IntPtr Handle, IntPtr pointer, uint offset, float value) 97 | { 98 | byte[] bytes = BitConverter.GetBytes(value); 99 | bool success = false; 100 | 101 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 102 | IntPtr nBytesRead = IntPtr.Zero; 103 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 104 | return success; 105 | } 106 | 107 | public static bool WriteUInt(IntPtr Handle, IntPtr pointer, uint offset, uint value) 108 | { 109 | byte[] bytes = BitConverter.GetBytes(value); 110 | bool success = false; 111 | 112 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 113 | IntPtr nBytesRead = IntPtr.Zero; 114 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 115 | return success; 116 | } 117 | 118 | public static bool WriteString(IntPtr Handle, IntPtr pointer, uint offset, string value) 119 | { 120 | byte[] bytes = Encoding.UTF8.GetBytes(value); 121 | bool success = false; 122 | 123 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 124 | IntPtr nBytesRead = IntPtr.Zero; 125 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 126 | return success; 127 | } 128 | 129 | public static bool WriteStruct(IntPtr Handle, IntPtr pointer, uint offset, object value) 130 | { 131 | byte[] bytes = RawSerialize(value); 132 | bool success = false; 133 | 134 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 135 | IntPtr nBytesRead = IntPtr.Zero; 136 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 137 | return success; 138 | } 139 | 140 | public static bool WriteBytes(IntPtr Handle, IntPtr pointer, uint offset, byte[] bytes) 141 | { 142 | bool success = false; 143 | 144 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 145 | IntPtr nBytesRead = IntPtr.Zero; 146 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 147 | return success; 148 | } 149 | 150 | public static bool WriteByte(IntPtr Handle, IntPtr pointer, uint offset, byte value) 151 | { 152 | byte[] bytes = BitConverter.GetBytes(value); 153 | bool success = false; 154 | 155 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 156 | IntPtr nBytesRead = IntPtr.Zero; 157 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 158 | return success; 159 | } 160 | 161 | public static bool WriteUnicode(IntPtr Handle, IntPtr pointer, uint offset, string value) 162 | { 163 | byte[] bytes = Encoding.Unicode.GetBytes(value); 164 | bool success = false; 165 | 166 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 167 | IntPtr nBytesRead = IntPtr.Zero; 168 | success = WriteProcessMemory(Handle, (IntPtr)address, bytes, bytes.Length, out nBytesRead); 169 | return success; 170 | } 171 | #endregion 172 | 173 | #region read memory 174 | public static int ReadInt(IntPtr Handle, IntPtr pointer, uint offset) 175 | { 176 | byte[] bytes = new byte[24]; 177 | bool success = false; 178 | 179 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 180 | 181 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)4, 0); 182 | if (success) 183 | { 184 | return BitConverter.ToInt32(bytes, 0); 185 | } 186 | else 187 | { 188 | return 0; 189 | } 190 | } 191 | 192 | public static uint ReadUInt(IntPtr Handle, IntPtr pointer, uint offset) 193 | { 194 | byte[] bytes = new byte[24]; 195 | bool success = false; 196 | 197 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 198 | 199 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)4, 0); 200 | if (success) 201 | { 202 | return BitConverter.ToUInt32(bytes, 0); 203 | } 204 | else 205 | { 206 | return 0; 207 | } 208 | } 209 | 210 | public static float ReadFloat(IntPtr Handle, IntPtr pointer, uint offset) 211 | { 212 | byte[] bytes = new byte[24]; 213 | bool success = false; 214 | 215 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 216 | 217 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)4, 0); 218 | if (success) 219 | { 220 | return BitConverter.ToSingle(bytes, 0); 221 | } 222 | else 223 | { 224 | return 0; 225 | } 226 | } 227 | 228 | public static string ReadString(IntPtr Handle, IntPtr pointer, uint offset) 229 | { 230 | byte[] bytes = new byte[24]; 231 | bool success = false; 232 | 233 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 234 | 235 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)Marshal.SizeOf("".GetType()), 0); 236 | if (success) 237 | { 238 | return Encoding.UTF8.GetString(bytes); 239 | } 240 | else 241 | { 242 | return null; 243 | } 244 | } 245 | 246 | /// 247 | /// đọc ra unicode string 248 | /// 249 | /// 250 | /// 251 | /// 252 | /// 253 | /// 254 | public static string ReadUnicode(IntPtr Handle, IntPtr pointer, uint offset, uint maxSize) 255 | { 256 | byte[] bytes = new byte[maxSize]; 257 | bool success = false; 258 | 259 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 260 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)maxSize, 0); 261 | 262 | if(success) 263 | return ByteArrayToString(bytes, EncodingType.Unicode); 264 | else 265 | return null; 266 | } 267 | 268 | /// 269 | /// Đọc ra mảng bytes 270 | /// 271 | /// 272 | /// 273 | /// 274 | /// 275 | /// 276 | public static byte[] ReadBytes(IntPtr Handle, IntPtr pointer, uint offset, uint maxSize) 277 | { 278 | byte[] bytes = new byte[maxSize]; 279 | bool success = false; 280 | 281 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 282 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)maxSize, 0); 283 | 284 | if (success) 285 | return bytes; 286 | else 287 | return null; 288 | } 289 | 290 | /// 291 | /// đọc ra một class theo cấu trúc 292 | /// 293 | /// 294 | /// 295 | /// 296 | /// 297 | /// 298 | public static object ReadStruct(IntPtr Handle, IntPtr pointer, uint offset) 299 | { 300 | int rawsize = Marshal.SizeOf(default(T)); 301 | byte[] bytes = new byte[rawsize]; 302 | bool success = false; 303 | 304 | uint address = (uint)ReadPointer(Handle, pointer) + offset; 305 | success = ReadProcessMemory(Handle, (IntPtr)address, bytes, (UIntPtr)rawsize, 0); 306 | 307 | if (success) 308 | return RawDeserialize(bytes, 0); 309 | else 310 | return null; 311 | } 312 | 313 | /// 314 | /// Đọc giá trị từ pointer ra kiểu Int32 315 | /// 316 | /// 317 | /// 318 | /// 319 | public static int ReadPointer(IntPtr Handle, IntPtr pointer) 320 | { 321 | byte[] bytes = new byte[24]; 322 | ReadProcessMemory(Handle, pointer, bytes, (UIntPtr)sizeof(int), 0); 323 | return BitConverter.ToInt32(bytes, 0); 324 | } 325 | #endregion 326 | 327 | private static object RawDeserialize(byte[] rawData, int position) 328 | { 329 | int rawsize = Marshal.SizeOf(default(T)); 330 | if (rawsize > rawData.Length) 331 | return null; 332 | IntPtr buffer = Marshal.AllocHGlobal(rawsize); 333 | Marshal.Copy(rawData, position, buffer, rawsize); 334 | object retobj = Marshal.PtrToStructure(buffer, typeof(T)); 335 | Marshal.FreeHGlobal(buffer); 336 | return retobj; 337 | } 338 | 339 | private static byte[] RawSerialize(object anything) 340 | { 341 | int rawSize = Marshal.SizeOf(anything); 342 | IntPtr buffer = Marshal.AllocHGlobal(rawSize); 343 | Marshal.StructureToPtr(anything, buffer, false); 344 | byte[] rawDatas = new byte[rawSize]; 345 | Marshal.Copy(buffer, rawDatas, 0, rawSize); 346 | Marshal.FreeHGlobal(buffer); 347 | return rawDatas; 348 | } 349 | 350 | private static string ByteArrayToString(byte[] bytes) 351 | { 352 | return ByteArrayToString(bytes, EncodingType.Unicode); 353 | } 354 | 355 | private static string ByteArrayToString(byte[] bytes, EncodingType encodingType) 356 | { 357 | System.Text.Encoding encoding = null; 358 | string result = ""; 359 | switch (encodingType) 360 | 361 | { 362 | case EncodingType.ASCII: 363 | encoding = new System.Text.ASCIIEncoding(); 364 | break; 365 | case EncodingType.Unicode: 366 | encoding = new System.Text.UnicodeEncoding(); 367 | break; 368 | case EncodingType.UTF7: 369 | encoding = new System.Text.UTF7Encoding(); 370 | break; 371 | case EncodingType.UTF8: 372 | encoding = new System.Text.UTF8Encoding(); 373 | break; 374 | } 375 | 376 | for (int i = 0; i < bytes.Length; i += 2) 377 | { 378 | if (bytes[i] == 0 && bytes[i + 1] == 0) 379 | { 380 | result = encoding.GetString(bytes, 0, i); 381 | break; 382 | } 383 | } 384 | 385 | return result; 386 | } 387 | private enum EncodingType 388 | { 389 | ASCII, 390 | Unicode, 391 | UTF7, 392 | UTF8 393 | } 394 | [Flags] 395 | internal enum FreeType 396 | { 397 | Decommit = 0x4000, 398 | Release = 0x8000, 399 | } 400 | public enum ProcessAccessFlags : uint 401 | { 402 | All = 0x001F0FFF, 403 | Terminate = 0x00000001, 404 | CreateThread = 0x00000002, 405 | VMOperation = 0x00000008, 406 | VMRead = 0x00000010, 407 | VMWrite = 0x00000020, 408 | DupHandle = 0x00000040, 409 | SetInformation = 0x00000200, 410 | QueryInformation = 0x00000400, 411 | Synchronize = 0x00100000 412 | } 413 | } 414 | } 415 | -------------------------------------------------------------------------------- /src/ProcessHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | using System.Text.RegularExpressions; 10 | using System.Threading.Tasks; 11 | 12 | namespace KAutoHelper 13 | { 14 | public class ProcessHelper 15 | { 16 | private delegate bool EnumWindowsProc(IntPtr windowHandle, IntPtr lParam); 17 | 18 | [DllImport("user32")] 19 | private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); 20 | 21 | [DllImport("user32.dll")] 22 | private static extern bool EnumChildWindows(IntPtr hWndStart, EnumWindowsProc callback, IntPtr lParam); 23 | 24 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 25 | public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, uint fuFlags, uint uTimeout, out IntPtr lpdwResult); 26 | 27 | public static List windowTitles = new List(); 28 | 29 | public static List GetWindowTitles(bool includeChildren) 30 | { 31 | EnumWindows(EnumWindowsCallback, includeChildren ? (IntPtr)1 : IntPtr.Zero); 32 | return windowTitles; 33 | } 34 | 35 | public static bool EnumWindowsCallback(IntPtr testWindowHandle, IntPtr includeChildren) 36 | { 37 | string title = GetWindowTitle(testWindowHandle); 38 | if (TitleMatches(title)) 39 | { 40 | windowTitles.Add(title); 41 | } 42 | if (includeChildren.Equals(IntPtr.Zero) == false) 43 | { 44 | EnumChildWindows(testWindowHandle, EnumWindowsCallback, IntPtr.Zero); 45 | } 46 | return true; 47 | } 48 | public static bool TitleMatches(string title) 49 | { 50 | bool match = title.Contains("e"); 51 | return match; 52 | } 53 | public static string GetWindowTitle(IntPtr windowHandle) 54 | { 55 | uint SMTO_ABORTIFHUNG = 0x0002; 56 | uint WM_GETTEXT = 0xD; 57 | int MAX_STRING_SIZE = 32768; 58 | IntPtr result; 59 | string title = string.Empty; 60 | IntPtr memoryHandle = Marshal.AllocCoTaskMem(MAX_STRING_SIZE); 61 | Marshal.Copy(title.ToCharArray(), 0, memoryHandle, title.Length); 62 | SendMessageTimeout(windowHandle, WM_GETTEXT, (IntPtr)MAX_STRING_SIZE, memoryHandle, SMTO_ABORTIFHUNG, (uint)1000, out result); 63 | title = Marshal.PtrToStringAuto(memoryHandle); 64 | Marshal.FreeCoTaskMem(memoryHandle); 65 | return title; 66 | } 67 | 68 | public static List GetNetStatPorts() 69 | { 70 | var Ports = new List(); 71 | 72 | try 73 | { 74 | using (Process p = new Process()) 75 | { 76 | ProcessStartInfo ps = new ProcessStartInfo(); 77 | ps.Arguments = "-a -n -o"; 78 | ps.FileName = "netstat.exe"; 79 | ps.CreateNoWindow = true; 80 | ps.UseShellExecute = false; 81 | ps.WindowStyle = ProcessWindowStyle.Hidden; 82 | ps.RedirectStandardInput = true; 83 | ps.RedirectStandardOutput = true; 84 | ps.RedirectStandardError = true; 85 | 86 | p.StartInfo = ps; 87 | p.Start(); 88 | 89 | StreamReader stdOutput = p.StandardOutput; 90 | StreamReader stdError = p.StandardError; 91 | 92 | string content = stdOutput.ReadToEnd() + stdError.ReadToEnd(); 93 | string exitStatus = p.ExitCode.ToString(); 94 | 95 | if (exitStatus != "0") 96 | { 97 | // Command Errored. Handle Here If Need Be 98 | } 99 | 100 | //Get The Rows 101 | string[] rows = Regex.Split(content, "\r\n"); 102 | foreach (string row in rows) 103 | { 104 | //Split it baby 105 | string[] tokens = Regex.Split(row, "\\s+"); 106 | if (tokens.Length > 4 && (tokens[1].Equals("UDP") || tokens[1].Equals("TCP"))) 107 | { 108 | string localAddress = Regex.Replace(tokens[2], @"\[(.*?)\]", "1.1.1.1"); 109 | Ports.Add(new Port 110 | { 111 | protocol = localAddress.Contains("1.1.1.1") ? String.Format("{0}v6", tokens[1]) : String.Format("{0}v4", tokens[1]), 112 | port_number = localAddress.Split(':')[1], 113 | process_name = tokens[1] == "UDP" ? LookupProcess(Convert.ToInt16(tokens[4])) : LookupProcess(Convert.ToInt16(tokens[5])), 114 | pid = Convert.ToInt16(tokens[5]) 115 | }); 116 | } 117 | } 118 | } 119 | } 120 | catch (Exception ex) 121 | { 122 | //Console.WriteLine(ex.Message) 123 | } 124 | return Ports; 125 | } 126 | 127 | public static string LookupProcess(int pid) 128 | { 129 | string procName; 130 | try { procName = Process.GetProcessById(pid).ProcessName; } 131 | catch (Exception) { procName = "-"; } 132 | return procName; 133 | } 134 | } 135 | public class Port 136 | { 137 | public string name 138 | { 139 | get 140 | { 141 | return string.Format("{0} ({1} port {2})", this.process_name, this.protocol, this.port_number); 142 | } 143 | set { } 144 | } 145 | public string port_number { get; set; } 146 | public string process_name { get; set; } 147 | public string protocol { get; set; } 148 | public int pid { get; set; } 149 | } 150 | 151 | /// 152 | /// A utility class to determine a process parent. 153 | /// 154 | [StructLayout(LayoutKind.Sequential)] 155 | public struct ParentProcessUtilities 156 | { 157 | // These members must match PROCESS_BASIC_INFORMATION 158 | internal IntPtr Reserved1; 159 | internal IntPtr PebBaseAddress; 160 | internal IntPtr Reserved2_0; 161 | internal IntPtr Reserved2_1; 162 | internal IntPtr UniqueProcessId; 163 | internal IntPtr InheritedFromUniqueProcessId; 164 | 165 | [DllImport("ntdll.dll")] 166 | private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, int processInformationLength, out int returnLength); 167 | 168 | /// 169 | /// Gets the parent process of the current process. 170 | /// 171 | /// An instance of the Process class. 172 | public static Process GetParentProcess() 173 | { 174 | return GetParentProcess(Process.GetCurrentProcess().Handle); 175 | } 176 | 177 | /// 178 | /// Gets the parent process of specified process. 179 | /// 180 | /// The process id. 181 | /// An instance of the Process class. 182 | public static Process GetParentProcess(int id) 183 | { 184 | Process process = Process.GetProcessById(id); 185 | return GetParentProcess(process.Handle); 186 | } 187 | 188 | /// 189 | /// Gets the parent process of a specified process. 190 | /// 191 | /// The process handle. 192 | /// An instance of the Process class. 193 | public static Process GetParentProcess(IntPtr handle) 194 | { 195 | ParentProcessUtilities pbi = new ParentProcessUtilities(); 196 | int returnLength; 197 | int status = NtQueryInformationProcess(handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength); 198 | if (status != 0) 199 | throw new Win32Exception(status); 200 | 201 | try 202 | { 203 | return Process.GetProcessById(pbi.InheritedFromUniqueProcessId.ToInt32()); 204 | } 205 | catch (ArgumentException) 206 | { 207 | // not found 208 | return null; 209 | } 210 | } 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /src/ThamKhao.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace KAutoHelper 9 | { 10 | class ThamKhao 11 | { 12 | /* 13 | Cách dùng send input 14 | 15 | SendKeyDown(KeyCode.SHIFT); 16 | SendKeyPress(KeyCode.END); 17 | SendKeyUp(KeyCode.SHIFT); 18 | 19 | */ 20 | 21 | [DllImport("user32.dll", SetLastError = true)] 22 | private static extern uint SendInput(uint numberOfInputs, INPUT[] inputs, int sizeOfInputStructure); 23 | 24 | /// 25 | /// Nhấn và nhả phím ra 26 | /// 27 | /// 28 | public void SendKeyPress(KeyCode keyCode) 29 | { 30 | INPUT input = new INPUT 31 | { 32 | Type = 1 33 | }; 34 | input.Data.Keyboard = new KEYBDINPUT() 35 | { 36 | Vk = (ushort)keyCode, 37 | Scan = 0, 38 | Flags = 0, 39 | Time = 0, 40 | ExtraInfo = IntPtr.Zero, 41 | }; 42 | 43 | INPUT input2 = new INPUT 44 | { 45 | Type = 1 46 | }; 47 | input2.Data.Keyboard = new KEYBDINPUT() 48 | { 49 | Vk = (ushort)keyCode, 50 | Scan = 0, 51 | Flags = 2, 52 | Time = 0, 53 | ExtraInfo = IntPtr.Zero 54 | }; 55 | INPUT[] inputs = new INPUT[] { input, input2 }; 56 | if (SendInput(2, inputs, Marshal.SizeOf(typeof(INPUT))) == 0) 57 | throw new Exception(); 58 | } 59 | 60 | /// 61 | /// Nhấn đè phím 62 | /// 63 | /// 64 | public void SendKeyDown(KeyCode keyCode) 65 | { 66 | INPUT input = new INPUT 67 | { 68 | Type = 1 69 | }; 70 | input.Data.Keyboard = new KEYBDINPUT(); 71 | input.Data.Keyboard.Vk = (ushort)keyCode; 72 | input.Data.Keyboard.Scan = 0; 73 | input.Data.Keyboard.Flags = 0; 74 | input.Data.Keyboard.Time = 0; 75 | input.Data.Keyboard.ExtraInfo = IntPtr.Zero; 76 | INPUT[] inputs = new INPUT[] { input }; 77 | if (SendInput(1, inputs, Marshal.SizeOf(typeof(INPUT))) == 0) 78 | { 79 | throw new Exception(); 80 | } 81 | } 82 | 83 | /// 84 | /// Giải phím nhấn 85 | /// 86 | /// 87 | public void SendKeyUp(KeyCode keyCode) 88 | { 89 | INPUT input = new INPUT 90 | { 91 | Type = 1 92 | }; 93 | input.Data.Keyboard = new KEYBDINPUT(); 94 | input.Data.Keyboard.Vk = (ushort)keyCode; 95 | input.Data.Keyboard.Scan = 0; 96 | input.Data.Keyboard.Flags = 2; 97 | input.Data.Keyboard.Time = 0; 98 | input.Data.Keyboard.ExtraInfo = IntPtr.Zero; 99 | INPUT[] inputs = new INPUT[] { input }; 100 | if (SendInput(1, inputs, Marshal.SizeOf(typeof(INPUT))) == 0) 101 | throw new Exception(); 102 | 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/apk/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RongK9/KAutoHelper/8fbdd4c248ce33d87720691f5a8db8198a7710fb/src/apk/app-release.apk -------------------------------------------------------------------------------- /src/apk/clipper.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RongK9/KAutoHelper/8fbdd4c248ce33d87720691f5a8db8198a7710fb/src/apk/clipper.apk -------------------------------------------------------------------------------- /src/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/autorunReg.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RongK9/KAutoHelper/8fbdd4c248ce33d87720691f5a8db8198a7710fb/src/autorunReg.reg -------------------------------------------------------------------------------- /src/command adb.txt: -------------------------------------------------------------------------------- 1 | adb push clipboard_content_file.txt /sdcard/clipboard_content_file.txt 2 | adb shell am broadcast -a clipper.setfile -e filepath \'/sdcard/clipboard_content_file.txt\' 3 | 4 | adb shell am broadcast -a clipper.set -e text "\"à hi hi\"" 5 | 6 | adb shell input keyevent 279 7 | 8 | adb push D:\script.sh sdcard/script.sh 9 | adb shell sh sdcard/script.sh 10 | 11 | adb shell am start ca.zgrs.clipper/.Main 12 | 13 | -------------------------------------------------------------------------------- /src/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | --------------------------------------------------------------------------------