├── AetherGazer.ahk └── README.md /AetherGazer.ahk: -------------------------------------------------------------------------------- 1 | ; ---------------------------------------------------------------------------- 2 | ; Script Name: 深空之眼 3 | ; Version: 3.0 4 | ; Author: qstdnx 5 | ; Contact: https://github.com/qstdnx/AetherGazer-ahk/issues 6 | ; ---------------------------------------------------------------------------- 7 | #Persistent ;~让脚本持久运行 8 | #SingleInstance,Force ;~运行替换旧实例 9 | ListLines,Off ;~不显示最近执行的脚本行 10 | SetBatchLines,-1 ;~脚本全速执行(默认10ms) 11 | CoordMode,Menu,Window ;~坐标相对活动窗口 12 | ;------------------------------------------------获取管理员权限 ↓↓↓ 13 | if !A_IsAdmin ; 如果不是管理员权限 14 | { 15 | try ; 尝试以管理员身份重新启动脚本 16 | { 17 | if A_IsCompiled ; 如果是编译后的 .exe 18 | Run *RunAs "%A_ScriptFullPath%" %1% %2% %3% %4% %5% %6% %7% %8% %9% 19 | else ; 如果是 .ahk 脚本 20 | Run *RunAs "%A_AhkPath%" "%A_ScriptFullPath%" %1% %2% %3% %4% %5% %6% %7% %8% %9% 21 | ExitApp ; 退出当前非管理员实例 22 | } 23 | catch ; 如果用户拒绝了 UAC 弹窗 24 | { 25 | MsgBox "管理员权限请求被拒绝,3.5版本后深空之眼需要使用管理员权限运行脚本" 26 | ExitApp 27 | } 28 | } 29 | 30 | ;------------------------------------------------设置 ↓↓↓ 31 | ; 初始化快捷键 32 | global AttackKey := "j" 33 | global Skill1Key := "u" 34 | global Skill2Key := "i" 35 | global Skill3Key := "o" 36 | global DodgeKey := "Space" 37 | global UltimateKey := "r" 38 | global Teammate1Key := "1" 39 | global Teammate2Key := "2" 40 | global JinwuKey := "Numpad1" 41 | global DimensionKey := "Numpad2" 42 | global LingguangKey := "Numpad3" 43 | global TuoteKey := "Numpad4" 44 | global NameiKey := "Numpad5" 45 | global WeierKey := "Numpad6" 46 | global KaorouKey := "Numpad7" 47 | global LiandianKey := "Numpad9" 48 | global FantianKey := "^Numpad1" 49 | global ShikoudiKey := "^Numpad2" 50 | global StopscriptKey := "Numpad0" 51 | global ScriptDir := A_ScriptDir 52 | IniFilePath := ScriptDir . "\settings.ini" 53 | 54 | ; 定义所有需要检查的键值对 55 | KeyMappings := { "AttackKey": AttackKey 56 | , "Skill1Key": Skill1Key 57 | , "Skill2Key": Skill2Key 58 | , "Skill3Key": Skill3Key 59 | , "DodgeKey": DodgeKey 60 | , "UltimateKey": UltimateKey 61 | , "Teammate1Key": Teammate1Key 62 | , "Teammate2Key": Teammate2Key 63 | , "JinwuKey": JinwuKey 64 | , "DimensionKey": DimensionKey 65 | , "LingguangKey": LingguangKey 66 | , "TuoteKey": TuoteKey 67 | , "NameiKey": NameiKey 68 | , "WeierKey": WeierKey 69 | , "KaorouKey": KaorouKey 70 | , "LiandianKey": LiandianKey 71 | , "FantianKey": FantianKey 72 | , "ShikoudiKey": ShikoudiKey 73 | , "StopscriptKey": StopscriptKey } 74 | 75 | ; 检查INI文件是否存在,不存在则创建 76 | if !FileExist(IniFilePath) { 77 | ; 创建新的INI文件并写入所有默认值 78 | for key, value in KeyMappings { 79 | IniWrite, %value%, %IniFilePath%, Hotkeys, %key% 80 | } 81 | } else { 82 | ; 检查INI文件中是否有缺失的键,有则补充 83 | for key, defaultValue in KeyMappings { 84 | IniRead, ReadValue, %IniFilePath%, Hotkeys, %key% 85 | if (ReadValue = "ERROR") { 86 | IniWrite, %defaultValue%, %IniFilePath%, Hotkeys, %key% 87 | ReadValue := defaultValue 88 | } 89 | ; 更新全局变量 90 | %key% := ReadValue 91 | } 92 | } 93 | 94 | ; 设置热键 95 | Hotkey, %JinwuKey%, Jinwu 96 | Hotkey, %DimensionKey%, Dimension 97 | Hotkey, %LingguangKey%, Lingguang 98 | Hotkey, %TuoteKey%, Tuote 99 | Hotkey, %NameiKey%, Namei 100 | Hotkey, %WeierKey%, Weier 101 | Hotkey, %KaorouKey%, Kaorou 102 | Hotkey, %LiandianKey%, Liandian 103 | Hotkey, %FantianKey%, Fantian 104 | Hotkey, %ShikoudiKey%, Shikoudi 105 | Hotkey, %StopscriptKey%, Stopscript 106 | 107 | Menu, Tray, NoStandard 108 | Menu, Tray, Add, 快捷键设置, ShowSettingsGui 109 | Menu, Tray, Add, 退出程序, ExitScript 110 | ShowSettingsGUI() { 111 | global 112 | Gui, New 113 | Gui, Add, Text,, 普攻快捷键: 114 | Gui, Add, Hotkey, vAttackKey, %AttackKey% 115 | Gui, Add, Text,, 1 技能快捷键: 116 | Gui, Add, Hotkey, vSkill1Key, %Skill1Key% 117 | Gui, Add, Text,, 2 技能快捷键: 118 | Gui, Add, Hotkey, vSkill2Key, %Skill2Key% 119 | Gui, Add, Text,, 3 技能快捷键: 120 | Gui, Add, Hotkey, vSkill3Key, %Skill3Key% 121 | Gui, Add, Text,, 闪避快捷键: 122 | Gui, Add, Hotkey, vDodgeKey, %DodgeKey% 123 | Gui, Add, Text,, 奥义快捷键: 124 | Gui, Add, Hotkey, vUltimateKey, %UltimateKey% 125 | Gui, Add, Text,, 队友1 奥义快捷键: 126 | Gui, Add, Hotkey, vTeammate1Key, %Teammate1Key% 127 | Gui, Add, Text,, 队友2 奥义快捷键: 128 | Gui, Add, Hotkey, vTeammate2Key, %Teammate2Key% 129 | Gui, Add, Text,, 金乌自动战斗快捷键: 130 | Gui, Add, Hotkey, vJinwuKey, %JinwuKey% 131 | Gui, Add, Text,, 自动多维变量快捷键: 132 | Gui, Add, Hotkey, vDimensionKey, %DimensionKey% 133 | Gui, Add, Text,, 陵光自动战斗快捷键: 134 | Gui, Add, Hotkey, vLingguangKey, %LingguangKey% 135 | Gui, Add, Text,, 托特/哈迪斯/雷前鬼/水姆`n自动战斗快捷键: 136 | Gui, Add, Hotkey, vTuoteKey, %TuoteKey% 137 | Gui, Add, Text,, 娜美自动战斗快捷键: 138 | Gui, Add, Hotkey, vNameiKey, %NameiKey% 139 | Gui, Add, Text,, 薇儿/光赫拉/瓦吉特`n自动战斗快捷键: 140 | Gui, Add, Hotkey, vWeierKey, %WeierKey% 141 | Gui, Add, Text,, 自动烤肉快捷键: 142 | Gui, Add, Hotkey, vKaorouKey, %KaorouKey% 143 | Gui, Add, Text,, 简易连点器快捷键: 144 | Gui, Add, Hotkey, vLiandianKey, %LiandianKey% 145 | Gui, Add, Text,, 梵天自动战斗快捷键: 146 | Gui, Add, Hotkey, vFantianKey, %FantianKey% 147 | Gui, Add, Text,, 诗寇蒂自动战斗快捷键: 148 | Gui, Add, Hotkey, vShikoudiKey, %ShikoudiKey% 149 | Gui, Add, Text,, 停止脚本快捷键: 150 | Gui, Add, Hotkey, vStopscriptKey, %StopscriptKey% 151 | Gui, Add, Button, default, OK 152 | Gui, Show, , 设置快捷键 153 | return 154 | } 155 | 156 | GuiClose: 157 | GuiEscape: 158 | Gui, Destroy 159 | return 160 | 161 | ButtonOK: 162 | Gui, Submit 163 | FileDelete, %IniFilePath% 164 | for key, value in KeyMappings { 165 | IniWrite, % %key%, %IniFilePath%, Hotkeys, %key% 166 | } 167 | 168 | ; 更新全局变量 169 | for key in KeyMappings { 170 | %key% := %key% 171 | } 172 | 173 | ; 重新设置热键 174 | Hotkey, %JinwuKey%, Jinwu 175 | Hotkey, %DimensionKey%, Dimension 176 | Hotkey, %LingguangKey%, Lingguang 177 | Hotkey, %TuoteKey%, Tuote 178 | Hotkey, %NameiKey%, Namei 179 | Hotkey, %WeierKey%, Weier 180 | Hotkey, %KaorouKey%, Kaorou 181 | Hotkey, %LiandianKey%, Liandian 182 | Hotkey, %FantianKey%, Fantian 183 | Hotkey, %ShikoudiKey%, Shikoudi 184 | Hotkey, %StopscriptKey%, Stopscript 185 | 186 | return 187 | 188 | ;------------------------------------------------深空之眼下才有效果 ↓↓↓ 189 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 190 | SysGet, VirtualWidth, 16 191 | SysGet, VirtualHeight, 17 192 | CoordMode, ToolTip, Screen 193 | ;-------------------------------------------------定义变量 ↓↓↓ 194 | GetColor(x,y) 195 | { 196 | PixelGetColor, color, x, y, RGB 197 | StringRight color,color,10 ; 198 | return color 199 | } 200 | ;这个游戏指针会干扰window spy取色,建议换截图工具取色。 201 | ;------------------------------------------------金乌飞天,小键盘1启动 ↓↓↓ 202 | 203 | 1_Enable= false 204 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 205 | Jinwu: 206 | { 207 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 208 | { 209 | 1_Enable :=!1_Enable 210 | if (1_Enable=false) 211 | { 212 | SetTimer, Press1, Off 213 | ToolTip 214 | } 215 | else 216 | { 217 | Sleep 100 218 | SetTimer, Press1, 10 ; 219 | ToolTip, 金乌:启动, 74, 1021 220 | } 221 | } 222 | } 223 | 224 | Press1: 225 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 226 | { 227 | loop{ 228 | if (GetColor(1161, 692)=="0xFFFFFF") 229 | { 230 | Send, {%Skill3Key%} 231 | Sleep 10 232 | Send, {%Skill3Key%} 233 | } 234 | else 235 | { 236 | break 237 | } 238 | } 239 | Send, {%Skill1Key%} 240 | Sleep 10 241 | Send, {%Skill1Key%} 242 | Sleep 10 243 | Send, {%AttackKey%} 244 | Sleep 10 245 | Send, {%Skill2Key%} 246 | Sleep 10 247 | Send, {%UltimateKey%} 248 | Sleep 10 249 | Send, {%AttackKey%} 250 | Sleep 10 251 | Send, {%Teammate1Key%} 252 | Sleep 10 253 | Send, {%AttackKey%} 254 | Sleep 10 255 | Send, {%Teammate2Key%} 256 | Sleep 10 257 | Send, {%AttackKey%} 258 | Sleep 10 259 | } 260 | else 261 | { 262 | SetTimer, Press1, Off 263 | ToolTip 264 | 1_Enable= false 265 | } 266 | return 267 | 268 | ;------------------------------------------------自动多维变量,要求分辨率1280x720, 小键盘2启动 ↓↓↓ 269 | 2_Enable=false 270 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 271 | Dimension: 272 | { 273 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 274 | { 275 | 2_Enable := !2_Enable 276 | if (2_Enable=false) 277 | { 278 | SetTimer, Press2, Off 279 | ToolTip 280 | } 281 | else 282 | { 283 | ToolTip, 多维变量:启动, 74, 1021 ; 设置ToolTip的显示内容和位置坐标 284 | Sleep 100 285 | Press2() 286 | } 287 | } 288 | } 289 | Press2() 290 | { 291 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 292 | { 293 | #NoEnv 294 | SetWorkingDir %A_ScriptDir% 295 | CoordMode, Mouse, Window 296 | SendMode Input 297 | SetTitleMatchMode 2 298 | #WinActivateForce 299 | SetControlDelay 1 300 | SetWinDelay 0 301 | SetKeyDelay -1 302 | SetMouseDelay -1 303 | loop 304 | { 305 | ;点击开始挑战 306 | Text:="|<>*204$83.zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzjzzzzzwzz003sz7yD8znt7y007lwTwSFzbm7w00DXsbsYWT1aDz7lw1X7010y1CTyDXs36C121w20TwT7sYED647tk0TsyDl00SC8DnU3y003W00QCFzXVbs007AzzsMVw1XDk00CF03011s3YTyDXwW06221l71zwT7sA0D44HbC7zsyDsMwSC8zCQBzXwTkFswQFiQ0ly7szU3lslXAs0XsTly803l30M0EDlzXsO060D0k7kTrzDtwSCAy3zzlzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" 307 | ok:=FindText(X:="wait", Y:=-1, 0,0,0,0,0,0,Text) 308 | if (ok:=FindText(X, Y, 1075-150000, 770-150000, 1075+150000, 770+150000, 0, 0, Text)) 309 | { 310 | FindText().Click(X, Y, "L") 311 | } 312 | ;难度选择 313 | Sleep, 500 314 | Click, 562, 674 Left, Down 315 | Sleep, 78 316 | Click, 563, 659, 0 317 | Click, 563, 650, 0 318 | Sleep, 31 319 | Click, 556, 549, 0 320 | Click, 550, 507, 0 321 | Click, 543, 447, 0 322 | Sleep, 16 323 | Click, 542, 430, 0 324 | Click, 539, 395, 0 325 | Sleep, 16 326 | Click, 530, 128, 0 327 | Sleep, 15 328 | Click, 530, 89, 0 329 | Click, 536, -7, 0 330 | Sleep, 16 331 | Click, 542, -63, 0 332 | Click, 551, -120, 0 333 | Sleep, 15 334 | Click, 593, -169, 0 335 | Sleep, 16 336 | Click, 600, -169, 0 337 | Click, 600, -169 Left, Up 338 | Sleep, 812 339 | Click, 391, 630 340 | Sleep, 500 341 | Click, 1060, 662 342 | Sleep, 1000 343 | ;选择真红 344 | Click, 71, 707 345 | Sleep, 500 346 | t1:=A_TickCount, Text:=X:=Y:="" 347 | Text:="|<>*211$37.0000000000000301U03zzknztzzsNzw0s0zjy7zsTzz30Q7TzVzy3rjUzz1tnkTzVzjwDzkwYY7zsSzz3zwDTzbzzVXb7zzknr0CD0MTUz3sBzwQ0Q6w60000000000004" 348 | if (ok:=FindText(X, Y, 163-150000, 267-150000, 163+150000, 267+150000, 0, 0, Text)) 349 | { 350 | FindText().Click(X, Y, "L") 351 | } 352 | Sleep, 500 353 | Text:="|<>*206$41.0000000000000032000006A00Ty0gM0zzw1MztxqM3zzkngkDyZVbzUPPP3Dz0q6qTNa1gBgyzw0SqMtzs3vgkkA0DaNVUQ03NX3Dz06767jy0AQMz300Mnlnzw0l7U3zs00000000000004" 354 | if (ok:=FindText(X, Y, 162-150000, 416-150000, 162+150000, 416+150000, 0, 0, Text)) 355 | { 356 | FindText().Click(X, Y, "L") 357 | } 358 | Sleep, 500 359 | Click, 235, 702 360 | Sleep, 500 361 | Text:="|<>*117$71.0Dzzzzzzzza00jzzzzzzzzi00PzzzzzzzzA0MbzzzzzzzzM1kCzTzzzxzzk348gjzzzzzzUCE03DzzjzzzETU04Izzzzzy1zU0N3yzzzzw3y0Am5nzzzzt7zLng/zzzzzwTzzzTzzzzzyAzzzzzzzzzzwNTzzzzzzzzzvnzzzzzzzzzzmvzzzzzzzzzzpjzzzzzzzzzzbTzzzztzzzzzizzzzznzzzzzzzTzzzXzzvzzzzzzzy7zznzzzzzzzwDzzXzzzzzzzkDzz7zzTzzzvUTzy7zyzzzzq0zzwDzz" 362 | 363 | if (ok:=FindText(X, Y, 161-150000, 436-150000, 161+150000, 436+150000, 0, 0, Text)) 364 | { 365 | FindText().Click(X, Y, "L") 366 | } 367 | Sleep, 500 368 | Click, 1173, 701 369 | Sleep, 500 370 | ;选择信标 371 | Click, 628, 562 Left, Down 372 | Sleep, 125 373 | Click, 628, 549, 0 374 | Click, 628, 546, 0 375 | Sleep, 16 376 | Click, 628, 521, 0 377 | Click, 628, 508, 0 378 | Sleep, 16 379 | Click, 628, 457, 0 380 | Click, 628, 436, 0 381 | Sleep, 15 382 | Click, 628, 362, 0 383 | Click, 628, 335, 0 384 | Sleep, 16 385 | Click, 626, 240, 0 386 | Click, 626, 224, 0 387 | Sleep, 15 388 | Click, 619, -9, 0 389 | Click, 618, -54, 0 390 | Sleep, 16 391 | Click, 618, -110, 0 392 | Sleep, 16 393 | Click, 618, -110 Left, Up 394 | Sleep, 812 395 | Click, 170, 492 396 | Sleep, 500 397 | Click, 483, 221 398 | Sleep, 500 399 | Click, 805, 221 400 | Sleep, 500 401 | Click, 1183, 702 402 | Sleep, 500 403 | ;选珍宝 404 | Text:= "|<>*167$45.zzzzzzzzzzzzzzzzzrzzzzzzwTwzXzw10DXwTzU81wDXzyCADlwTzlU0zTXzyA07zwTzk00kTXzw28a3sTzUE0sT1zsG07XsDz2E0wT1zsG8bWl7zmE0w68zyG07U3Xzk3Aw0QDy0NbW7kzk30yFz7zws7yTxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzw" 405 | ok:=FindText(X:="wait", Y:=-1, 0,0,0,0,0,0,Text) 406 | if (ok:=FindText(X, Y, 886-150000, 742-150000, 886+150000, 742+150000, 0, 0, Text)) 407 | { 408 | Click, 642, 400 409 | Sleep, 500 410 | FindText().Click(X, Y, "L") 411 | } 412 | Sleep, 500 413 | Click, 864, 643 414 | ;选关卡 415 | Sleep, 1687 416 | Send, {w Down} 417 | Sleep, 3300 418 | Send, {d Down} 419 | Sleep, 1200 420 | Send, {d Up} 421 | Sleep, 400 422 | Send, {w Up} 423 | Sleep, 1000 424 | Click, 889, 490 425 | Sleep, 500 426 | ;打完只有一个珍宝时,确认默认被选中时的图片 427 | text1:="|<>*202$43.zzzzzzzzzzzzzzzzrzzzzzzlztyDz0M3sT7zU81yDXzwMEz3lzyM0DnszyA03zwTz001UyDz0W8kT3zUE0QDVzV80D7UzkYF7XkDwG8Xls7z901s8lzYU0w0MzkF4S4SDs1WD4T3w0k7YDlzws7zDwzzzzzzzzzzzzzzzzzzzzzzzzzzzzzk" 428 | 429 | ;打怪 430 | loop 431 | { 432 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 433 | Send, {%Skill1Key%} 434 | Sleep, 10 435 | Send, {%Skill3Key%} 436 | Sleep, 10 437 | Send, {%AttackKey%} 438 | Sleep, 10 439 | Send, {%Skill2Key%} 440 | Sleep, 10 441 | Send, {%Skill3Key%} 442 | Sleep, 10 443 | Send, {%AttackKey%} 444 | Sleep, 10 445 | Send, {%UltimateKey%} 446 | Sleep, 10 447 | Send, {%Skill3Key%} 448 | Sleep, 10 449 | Send, {%AttackKey%} 450 | Sleep, 10 451 | if (ok:=FindText(X, Y, 886-150000, 742-150000, 886+150000, 742+150000, 0, 0, Text)) 452 | { 453 | break 454 | } 455 | if (ok:=FindText(X, Y, 886-150000, 742-150000, 886+150000, 742+150000, 0, 0, Text1)) 456 | { 457 | break 458 | } 459 | } 460 | Click, 642, 400 461 | Sleep, 500 462 | Click, 745, 643 463 | Sleep, 1000 464 | ;退出 465 | Send, {Alt} 466 | Sleep, 500 467 | Click, 1229, 74 468 | Sleep, 500 469 | Click, 1000, 692 470 | Sleep, 500 471 | Send, {Enter} 472 | Text:="|<>*202$39.zzzzzzzzzzzzzvzzzwzyA0DzbzkU1wwsz0TDbb7wU1wwszw0Dbb7kXtw00w40DU07kU0w00z4F7zbzsW1swwT4ED7bXsUEswwT07b7bXk3ws00QE03003nU0s00Tzzzzzbzzzzzzw" 473 | ok:=FindText(X:="wait", Y:=-1, 0,0,0,0,0,0,Text) 474 | if (ok:=FindText(X, Y, 1183-150000, 803-150000, 1183+150000, 803+150000, 0, 0, Text)) 475 | { 476 | FindText().Click(X, Y, "L") 477 | } 478 | Sleep, 1000 479 | } 480 | } 481 | else 482 | { 483 | SetTimer, Press2, Off 484 | ToolTip 485 | 2_Enable=false 486 | } 487 | } 488 | return 489 | ;------------------------------------------------陵光自动操作,小键盘3启动 ↓↓↓ 490 | 3_Enable= false 491 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 492 | Lingguang: 493 | { 494 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 495 | { 496 | 3_Enable :=!3_Enable 497 | if (3_Enable=false) 498 | { 499 | SetTimer, Press3, Off 500 | ToolTip 501 | } 502 | else 503 | { 504 | Sleep 100 505 | SetTimer, Press3, 10 ; 506 | ToolTip, 陵光:启动, 74, 1021 507 | } 508 | } 509 | } 510 | 511 | Press3: 512 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 513 | { 514 | Send, {%AttackKey%} 515 | Sleep 250 516 | Send, {%Skill1Key%} 517 | Sleep 250 518 | Send, {%UltimateKey%} 519 | Send, {%Teammate1Key%} 520 | Send, {%Teammate2Key%} 521 | } 522 | else 523 | { 524 | SetTimer, Press3, Off 525 | ToolTip 526 | 1_Enable= false 527 | } 528 | return 529 | 530 | ;------------------------------------------------托特或哈迪斯自动战斗,小键盘4启动 ↓↓↓ 531 | 532 | 4_Enable= false 533 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 534 | Tuote: 535 | { 536 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 537 | { 538 | 4_Enable :=!4_Enable 539 | if (4_Enable=false) 540 | { 541 | SetTimer, Press4, Off 542 | ToolTip 543 | } 544 | else 545 | { 546 | Sleep 100 547 | SetTimer, Press4, 10 ; 548 | ToolTip, 托特/哈迪斯/雷前鬼/水姆:启动, 74, 1021 549 | } 550 | } 551 | } 552 | 553 | Press4: 554 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 555 | { 556 | Send, {%AttackKey% Down} 557 | Sleep, 500 558 | Send, {%AttackKey% Up} 559 | Send, {%Skill3Key%} 560 | Sleep 10 561 | Send, {%Skill3Key%} 562 | Sleep 10 563 | Send, {%AttackKey%} 564 | Sleep 10 565 | Send, {%Skill1Key%} 566 | Sleep 10 567 | Send, {%Skill1Key%} 568 | Sleep 10 569 | Send, {%AttackKey%} 570 | Sleep 10 571 | Send, {%Skill2Key%} 572 | Sleep 10 573 | Send, {%UltimateKey%} 574 | Sleep 10 575 | Send, {%AttackKey%} 576 | Sleep 10 577 | Send, {%Teammate1Key%} 578 | Sleep 10 579 | Send, {%Teammate2Key%} 580 | Sleep 10 581 | } 582 | else 583 | { 584 | SetTimer, Press4, Off 585 | ToolTip 586 | 4_Enable= false 587 | } 588 | return 589 | ;------------------------------------------------娜美自动战斗,小键盘5启动 ↓↓↓ 590 | 5_Enable= false 591 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 592 | Namei: 593 | { 594 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 595 | { 596 | 5_Enable :=!5_Enable 597 | if (5_Enable=false) 598 | { 599 | SetTimer, Press5, Off 600 | ToolTip 601 | } 602 | else 603 | { 604 | Sleep 100 605 | Send, {%Skill1Key%}{%AttackKey%} 606 | SetTimer, Press5, 10 ; 607 | ToolTip, 娜美:启动, 74, 1021 608 | } 609 | } 610 | } 611 | 612 | Press5: 613 | if WinActive("ahk_exe AetherGazer.exe") 614 | { 615 | if (GetColor(1174, 684)=="0xFFFFFF") 616 | { 617 | Send, {%DodgeKey%} 618 | Sleep 400 619 | Send, {%AttackKey%} 620 | Sleep 300 621 | Send, {%AttackKey%} 622 | Sleep 700 623 | Send, {%AttackKey%} 624 | Sleep 600 625 | Send, {%Skill3Key%} 626 | Sleep 1400 627 | Send, {%Skill2Key%}{%Skill1Key%} 628 | } 629 | Sleep 10 630 | Send, {%AttackKey%} 631 | if (GetColor(1090, 672)=="0xFFFFFF") 632 | { 633 | Sleep 150 634 | Send, {%Skill2Key%} 635 | } 636 | Sleep 10 637 | Send, {%AttackKey%} 638 | if (GetColor(1016, 697)=="0xFFFFFF") 639 | { 640 | Sleep 150 641 | Send, {%Skill1Key%} 642 | } 643 | Send, {%UltimateKey%} 644 | Sleep 10 645 | Send, {%AttackKey%} 646 | Sleep 10 647 | Send, {%Teammate1Key%} 648 | Sleep 10 649 | Send, {%Teammate2Key%} 650 | Sleep 10 651 | } 652 | else 653 | { 654 | SetTimer, Press5, Off 655 | ToolTip 656 | 5_Enable= false 657 | } 658 | return 659 | ;------------------------------------------------光薇儿自动战斗,小键盘6启动 ↓↓↓ 660 | 6_Enable= false 661 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 662 | Weier: 663 | { 664 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 665 | { 666 | 6_Enable :=!6_Enable 667 | if (6_Enable=false) 668 | { 669 | SetTimer, Press6, Off 670 | ToolTip 671 | } 672 | else 673 | { 674 | Sleep 100 675 | SetTimer, Press6, 10 ; 676 | ToolTip, 薇儿/光赫拉/瓦吉特:启动, 74, 1021 677 | } 678 | } 679 | } 680 | 681 | Press6: 682 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 683 | { 684 | Send, {%Skill3Key%} 685 | Sleep 5 686 | Send, {%AttackKey%} 687 | Sleep 5 688 | Send, {%Skill1Key%} 689 | Sleep 5 690 | Send, {%UltimateKey%} 691 | Sleep 5 692 | Send, {%AttackKey%} 693 | Sleep 5 694 | Send, {%Skill2Key%} 695 | Sleep 5 696 | Send, {%Teammate1Key%} 697 | Sleep 5 698 | Send, {%Skill1Key%} 699 | Sleep 5 700 | Send, {%Teammate2Key%} 701 | Sleep 5 702 | Send, {%Skill2Key%} 703 | Sleep 5 704 | } 705 | else 706 | { 707 | SetTimer, Press6, Off 708 | ToolTip 709 | 6_Enable= false 710 | } 711 | return 712 | ;------------------------------------------------闲暇时刻自动烤肉,小键盘7启动↓↓↓ 713 | 7_Enable= false 714 | Kaorou: 715 | { 716 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 717 | { 718 | 7_Enable := !7_Enable 719 | if (7_Enable = false) 720 | { 721 | SetTimer, Press7, Off 722 | ToolTip 723 | } 724 | else 725 | { 726 | Sleep 100 727 | SetTimer, Press7, 10 728 | ToolTip, 烤肉:启动, 74, 1021 729 | } 730 | } 731 | } 732 | 733 | Press7: 734 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 735 | { 736 | color := GetColor(691, 180) 737 | if (IsColorClose(color, "0xde6566", 10)) ; 容差设为10 738 | { 739 | Send, i 740 | } 741 | if (IsColorClose(color, "0x4abbf1", 10)) ; 容差设为10 742 | { 743 | Send, u 744 | } 745 | } 746 | else 747 | { 748 | SetTimer, Press7, Off 749 | ToolTip 750 | 7_Enable = false 751 | } 752 | return 753 | 754 | ; 判断两个颜色值是否在容差范围内 755 | IsColorClose(color1, color2, tolerance) 756 | { 757 | color1 := "0x" SubStr(color1, 3) 758 | color2 := "0x" SubStr(color2, 3) 759 | 760 | r1 := (color1 >> 16) & 0xFF 761 | g1 := (color1 >> 8) & 0xFF 762 | b1 := color1 & 0xFF 763 | 764 | r2 := (color2 >> 16) & 0xFF 765 | g2 := (color2 >> 8) & 0xFF 766 | b2 := color2 & 0xFF 767 | 768 | if (Abs(r1 - r2) <= tolerance && Abs(g1 - g2) <= tolerance && Abs(b1 - b2) <= tolerance) 769 | { 770 | return true 771 | } 772 | return false 773 | } 774 | ;--------------------------简易连点器功能,右ctrl+任意键连点,小键盘9启动自定义连点↓↓↓ 775 | 9_Enable := false 776 | Inputkey := "" 777 | RControl:: 778 | Input, Inputkey, L1 I V, {MouseX, MouseY} 779 | 9_Enable := true 780 | loop { 781 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe"){ 782 | if (9_Enable){ 783 | Send, %Inputkey% 784 | Sleep, 50 785 | ToolTip, %Inputkey% 键连点中,按%StopscriptKey%停止 786 | } 787 | if (!9_Enable or Inputkey=""){ 788 | ToolTip 789 | break 790 | } 791 | } else { 792 | 9_Enable := false 793 | ToolTip 794 | break 795 | } 796 | } 797 | return 798 | 799 | ;可记忆版本,容易卡键 800 | ; keyToClick := "" 801 | ; RControl:: 802 | ; Input, Inputkey, L1 I V, {MouseX, MouseY} 803 | ; keyToClick := keyToClick . Inputkey 804 | ; 9_Enable := true 805 | ; Loop { 806 | ; If WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe"){ 807 | ; if (9_Enable){ 808 | ; Send, %keyToClick% 809 | ; Sleep, 50 810 | ; Tooltip, %keyToClick% 键连点中,按%StopscriptKey%停止`n按右alt键暂停,再次点击右ctrl+任意键同时连点暂停前记录的按键 811 | ; } 812 | ; if (!9_Enable or keyToClick=""){ 813 | ; Tooltip 814 | ; break 815 | ; } 816 | ; } else { 817 | ; 9_Enable := false 818 | ; Tooltip 819 | ; break 820 | ; } 821 | ; } 822 | ; return 823 | 824 | ;连点鼠标,导致rctrl失效 825 | ; RControl & LButton:: 826 | ; Loop { 827 | ; If WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe"){ 828 | ; if (9_Enable) 829 | ; Click 830 | ; Sleep, 50 831 | ; ToolTip,鼠标左键连点中,`n间隔50毫秒,按%StopscriptKey%停止 832 | ; } else { 833 | ; 9_Enable := false 834 | ; ToolTip 835 | ; break 836 | ; } 837 | ; } 838 | ; return 839 | 840 | ; RAlt:: 841 | ; 9_Enable := false 842 | ; return 843 | 844 | Liandian: 845 | { 846 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 847 | gosub, 连点弹框输入 848 | return 849 | } 850 | 连点弹框输入: 851 | Gui, MouseClickGui: New 852 | Gui, MouseClickGui: +AlwaysOnTop 853 | Gui, MouseClickGui: Add, Text, , 填写连点的按键:`n同时连按多个按键直接填入即可,例如填入jkio为同时连点jkio四个按键`n特殊按键用{}圈住,例如鼠标左键为{LButton},空格键为{Space},左Shift为{LShift} 854 | Gui, MouseClickGui: Add, Edit, w400 v连点按键, {LButton} 855 | Gui, MouseClickGui: Add, Text, , 连点间隔(单位毫秒): 856 | Gui, MouseClickGui: Add, Edit, w400 v连点间隔, 50 857 | Gui, MouseClickGui: Add, Button, default g连点确认, 确认 858 | Gui, MouseClickGui: Show, , 按键连点 859 | return 860 | 连点确认: 861 | Gui, MouseClickGui: Submit 862 | global WhichButton:= 连点按键 863 | global interval:= 连点间隔 864 | SetTimer, ContinuousClick, %连点间隔% 865 | return 866 | 867 | ContinuousClick: 868 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 869 | Send, %WhichButton% 870 | ToolTip,%WhichButton%键连点中,`n间隔%interval%毫秒,按%StopscriptKey%停止 871 | return 872 | 873 | ;------------------------------------------------梵天自动战斗,Ctrl+小键盘1启动 ↓↓↓ 874 | 11_Enable= false 875 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 876 | Fantian: 877 | { 878 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 879 | { 880 | 11_Enable :=!11_Enable 881 | if (11_Enable=false) 882 | { 883 | SetTimer, Press11, Off 884 | ToolTip 885 | } 886 | else 887 | { 888 | Sleep 100 889 | SetTimer, Press11, 10 ; 890 | ToolTip, 梵天:启动, 74, 1021 891 | } 892 | } 893 | } 894 | 895 | Press11: 896 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 897 | { 898 | if (GetColor(898, 681)!=="0xFFFFFF" and GetColor(1218, 681)=="0xFFFFFF") 899 | { 900 | Send, {%DodgeKey% Down} 901 | Sleep, 500 902 | Send, {%DodgeKey% Up} 903 | } 904 | Send, {%Skill3Key%} 905 | Sleep 5 906 | Send, {%AttackKey%} 907 | Sleep 5 908 | Send, {%Skill1Key%} 909 | Sleep 5 910 | Send, {%UltimateKey%} 911 | Sleep 5 912 | Send, {%AttackKey%} 913 | Sleep 5 914 | Send, {%Skill2Key%} 915 | Sleep 5 916 | Send, {%Teammate2Key%} 917 | Sleep 5 918 | Send, {%Skill1Key%} 919 | Sleep 5 920 | Send, {%AttackKey%} 921 | Sleep 5 922 | Send, {%Skill2Key%} 923 | Sleep 5 924 | } 925 | else 926 | { 927 | SetTimer, Press11, Off 928 | ToolTip 929 | 11_Enable= false 930 | } 931 | return 932 | 933 | ;------------------------------------------------诗寇蒂自动战斗,Ctrl+小键盘2启动 ↓↓↓ 934 | 12_Enable= false 935 | #If WinActive("ahk_exe AetherGazer.exe") || WinActive("ahk_exe AetherGazer_Bili.exe") 936 | Shikoudi: 937 | { 938 | if WinActive("ahk_exe AetherGazer.exe") or WinActive("ahk_exe AetherGazer_Bili.exe") 939 | { 940 | 12_Enable :=!12_Enable 941 | if (12_Enable=false) 942 | { 943 | ToolTip 944 | } 945 | else 946 | { 947 | Sleep 100 948 | ToolTip, 诗寇蒂:启动, 74, 1021 949 | gosub, Press12 950 | } 951 | } 952 | } 953 | 954 | Press12: 955 | loop 956 | { 957 | if (!WinActive("ahk_exe AetherGazer.exe") and !WinActive("ahk_exe AetherGazer_Bili.exe") or !12_Enable) 958 | { 959 | ToolTip 960 | 12_Enable := false 961 | break ; 退出循环 962 | } 963 | ; 优先检测技能3 964 | if (GetColor(1157, 683)=="0xFFFFFF" and GetColor(1173, 695)=="0xFFFFFF" and GetColor(770, 609)=="0xFFFFFF") 965 | { 966 | ; 左线、右线神格, 化身槽满, 长按3 967 | Send, {%Skill3Key% Down} 968 | Sleep, 10000 969 | Send, {%Skill3Key% Up} 970 | Sleep, 10 971 | } 972 | else if (GetColor(1157, 683)=="0xFFFFFF" or GetColor(1166, 668)=="0xFFFFFF" or GetColor(1143, 677)=="0xFFFFFF") 973 | { 974 | ; 化身槽不满, 图标有两种形态,一种是分割状态,一种是和中线一样, 所以同时检测两种图标有一种在就按3兼容三条神格 975 | Send, {%Skill3Key%} 976 | Sleep, 10 977 | } 978 | ; 其次检测技能2 979 | else if (GetColor(1097, 701)=="0xFFFFFF" and GetColor(1085, 700)=="0xFFFFFF") 980 | { 981 | Send, {%Skill2Key%} 982 | Sleep, 10 983 | } 984 | else { 985 | Send, {%AttackKey%} 986 | Sleep, 10 987 | } 988 | Send, {%UltimateKey%} 989 | Sleep, 10 990 | Send, {%Teammate1Key%} 991 | Sleep, 10 992 | Send, {%Teammate2Key%} 993 | Sleep, 10 994 | 995 | } 996 | ;------------------------------------------------强制停止脚本,小键盘0↓↓↓ 997 | Stopscript: 998 | Reload 999 | ; 1_Enable= False 1000 | ; 2_Enable= False 1001 | ; 3_Enable= False 1002 | ; 4_Enable= False 1003 | ; 5_Enable= False 1004 | ; 6_Enable= False 1005 | ; 7_Enable= False 1006 | ; 9_Enable= False 1007 | ; 11_Enable= False 1008 | return 1009 | ;------------------------------------------------退出脚本↓↓↓ 1010 | ExitScript: 1011 | ExitApp 1012 | return 1013 | 1014 | 1015 | 1016 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1017 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1018 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1019 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1020 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1021 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1022 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1023 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1024 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1025 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1026 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1027 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1028 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1029 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1030 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1031 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1032 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1033 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1034 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1035 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1036 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1037 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1038 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1039 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1040 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1041 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1042 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1043 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1044 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1045 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1046 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1047 | ;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1048 | FindText(ByRef x:="FindTextClass", ByRef y:="", args*) 1049 | { 1050 | static init, obj 1051 | if !VarSetCapacity(init) && (init:="1") 1052 | obj:=new FindTextClass() 1053 | return (x=="FindTextClass" && !args.Length()) ? obj : obj.FindText(x, y, args*) 1054 | } 1055 | 1056 | Class FindTextClass 1057 | { ;// Class Begin 1058 | 1059 | Floor(i) 1060 | { 1061 | if i is number 1062 | return i+0 1063 | else return 0 1064 | } 1065 | 1066 | __New() 1067 | { 1068 | this.bits:={ Scan0: 0, hBM: 0, oldzw: 0, oldzh: 0 } 1069 | this.bind:={ id: 0, mode: 0, oldStyle: 0 } 1070 | this.Lib:=[] 1071 | this.Cursor:=0 1072 | } 1073 | 1074 | __Delete() 1075 | { 1076 | if (this.bits.hBM) 1077 | Try DllCall("DeleteObject", "Ptr",this.bits.hBM) 1078 | } 1079 | 1080 | New() 1081 | { 1082 | return new FindTextClass() 1083 | } 1084 | 1085 | help() 1086 | { 1087 | return " 1088 | ( 1089 | )" 1090 | } 1091 | 1092 | FindText(ByRef OutputX:="", ByRef OutputY:="" 1093 | , x1:=0, y1:=0, x2:=0, y2:=0, err1:=0, err0:=0, text:="" 1094 | , ScreenShot:=1, FindAll:=1, JoinText:=0, offsetX:=20, offsetY:=10 1095 | , dir:=0, zoomW:=1, zoomH:=1) 1096 | { 1097 | local 1098 | if (OutputX ~= "i)^\s*wait[10]?\s*$") 1099 | { 1100 | found:=!InStr(OutputX,"0"), time:=this.Floor(OutputY) 1101 | , timeout:=A_TickCount+Round(time*1000), OutputX:="" 1102 | Loop 1103 | { 1104 | ok:=this.FindText(,, x1, y1, x2, y2, err1, err0, text, ScreenShot 1105 | , FindAll, JoinText, offsetX, offsetY, dir, zoomW, zoomH) 1106 | if (found && ok) 1107 | { 1108 | OutputX:=ok[1].x, OutputY:=ok[1].y 1109 | return ok 1110 | } 1111 | if (!found && !ok) 1112 | return 1 1113 | if (time>=0 && A_TickCount>=timeout) 1114 | Break 1115 | Sleep 50 1116 | } 1117 | return 0 1118 | } 1119 | SetBatchLines % (bch:=A_BatchLines)?"-1":"-1" 1120 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 1121 | if (x1=0 && y1=0 && x2=0 && y2=0) 1122 | n:=150000, x:=y:=-n, w:=h:=2*n 1123 | else 1124 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 1125 | bits:=this.GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy), x-=zx, y-=zy 1126 | , this.ok:=0, info:=[] 1127 | Loop Parse, text, | 1128 | if IsObject(j:=this.PicInfo(A_LoopField)) 1129 | info.Push(j) 1130 | if (w<1 || h<1 || !(num:=info.Length()) || !bits.Scan0) 1131 | { 1132 | SetBatchLines % bch 1133 | return 0 1134 | } 1135 | arr:=[], info2:=[], k:=0, s:="" 1136 | , mode:=(IsObject(JoinText) ? 2 : JoinText ? 1 : 0) 1137 | For i,j in info 1138 | { 1139 | k:=Max(k, (j[7]=5 && j[8]!=2 ? j[9] : j[2]*j[3])) 1140 | if (mode) 1141 | v:=(mode=1 ? i : j[10]) . "", s.="|" v 1142 | , (v!="") && ((!info2.HasKey(v) && info2[v]:=[]), info2[v].Push(j)) 1143 | } 1144 | sx:=x, sy:=y, sw:=w, sh:=h, (mode=1 && JoinText:=[s]) 1145 | , allpos_max:=(FindAll || JoinText ? 10000:1) 1146 | , VarSetCapacity(s1,k*4), VarSetCapacity(s0,k*4) 1147 | , VarSetCapacity(ss,sw*(sh+3)), VarSetCapacity(allpos,allpos_max*8) 1148 | , ini:={ sx:sx, sy:sy, sw:sw, sh:sh, zx:zx, zy:zy 1149 | , mode:mode, bits:bits, ss:&ss, s1:&s1, s0:&s0 1150 | , allpos:&allpos, allpos_max:allpos_max 1151 | , err1:err1, err0:err0, zoomW:zoomW, zoomH:zoomH } 1152 | Loop 2 1153 | { 1154 | if (err1=0 && err0=0) && (num>1 || A_Index>1) 1155 | ini.err1:=err1:=0.05, ini.err0:=err0:=0.05 1156 | if (!JoinText) 1157 | { 1158 | For i,j in info 1159 | Loop % this.PicFind(ini, j, dir, sx, sy, sw, sh) 1160 | { 1161 | v:=NumGet(allpos,4*A_Index-4,"uint"), x:=(v&0xFFFF)+zx, y:=(v>>16)+zy 1162 | , w:=Floor(j[2]*zoomW), h:=Floor(j[3]*zoomH) 1163 | , arr.Push({1:x, 2:y, 3:w, 4:h, x:x+w//2, y:y+h//2, id:j[10]}) 1164 | if (!FindAll) 1165 | Break 3 1166 | } 1167 | } 1168 | else 1169 | For k,v in JoinText 1170 | { 1171 | v:=StrSplit(Trim(RegExReplace(v, "\s*\|[|\s]*", "|"), "|") 1172 | , (InStr(v,"|")?"|":""), " `t") 1173 | , this.JoinText(arr, ini, info2, v, 1, offsetX, offsetY 1174 | , FindAll, dir, 0, 0, 0, sx, sy, sw, sh) 1175 | if (!FindAll && arr.Length()) 1176 | Break 2 1177 | } 1178 | if (err1!=0 || err0!=0 || arr.Length() || info[1][4] || info[1][7]=5) 1179 | Break 1180 | } 1181 | SetBatchLines % bch 1182 | if (arr.Length()) 1183 | { 1184 | OutputX:=arr[1].x, OutputY:=arr[1].y, this.ok:=arr 1185 | return arr 1186 | } 1187 | return 0 1188 | } 1189 | 1190 | ; the join text object use [ "abc", "xyz", "a1|a2|a3" ] 1191 | 1192 | JoinText(arr, ini, info2, text, index, offsetX, offsetY 1193 | , FindAll, dir, minX, minY, maxY, sx, sy, sw, sh) 1194 | { 1195 | local 1196 | if !(Len:=text.Length()) || !info2.HasKey(key:=text[index]) 1197 | return 0 1198 | zoomW:=ini.zoomW, zoomH:=ini.zoomH, mode:=ini.mode 1199 | For i,j in info2[key] 1200 | if (mode!=2 || key==j[10]) 1201 | Loop % ok:=this.PicFind(ini, j, dir, sx, sy, (index=1 ? sw 1202 | : Min(sx+offsetX+Floor(j[2]*zoomW),ini.sx+ini.sw)-sx), sh) 1203 | { 1204 | if (A_Index=1) 1205 | { 1206 | pos:=[], p:=ini.allpos-4 1207 | Loop % ok 1208 | pos.Push(NumGet(0|p+=4,"uint")) 1209 | } 1210 | v:=pos[A_Index], x:=v&0xFFFF, y:=v>>16 1211 | , w:=Floor(j[2]*zoomW), h:=Floor(j[3]*zoomH) 1212 | , (index=1 && (minX:=x, minY:=y, maxY:=y+h)) 1213 | , minY1:=Min(y, minY), maxY1:=Max(y+h, maxY), sx1:=x+w 1214 | if (index1 || !FindAll) 1221 | return 1 1222 | } 1223 | else 1224 | { 1225 | comment:="" 1226 | For k,v in text 1227 | comment.=(mode=2 ? v : info2[v][1][10]) 1228 | x:=minX+ini.zx, y:=minY1+ini.zy, w:=sx1-minX, h:=maxY1-minY1 1229 | , arr.Push({1:x, 2:y, 3:w, 4:h, x:x+w//2, y:y+h//2, id:comment}) 1230 | if (index>1 || !FindAll) 1231 | return 1 1232 | } 1233 | } 1234 | return 0 1235 | } 1236 | 1237 | PicFind(ini, j, dir, sx, sy, sw, sh) 1238 | { 1239 | local 1240 | static init, MyFunc 1241 | if !VarSetCapacity(init) && (init:="1") 1242 | { 1243 | x32:="VVdWU4HsmAAAAIuEJNQAAAADhCTMAAAAi5wk@AAAAIO8JKwAAAAFiUQkIIuEJPgA" 1244 | . "AACNBJiJRCQ0D4RKBgAAi4Qk6AAAAIXAD45ADwAAiXwkEIu8JOQAAAAx7ccEJAAA" 1245 | . "AADHRCQIAAAAAMdEJBQAAAAAx0QkDAAAAACNtgAAAACLhCTgAAAAi0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BEGDxgKJww+21A+2wMHrEEQp0kQp2A+220Qp64H5@@@@AHazQYnP" 1423 | . "QcHvEEUPtv8Pr9tFD6@@RDn7d7IPtt0Pr9IPr9s52nelD7bJD6@AD6@JOch3mGaQ" 1424 | . "i0QkCEgDfCQQA2wkHEQB4EQ55n5lQYnE6UP@@@8PHwCLRCRIRIt0JBhEievB4xBB" 1425 | . "weIIQQnamU1jzkUJ2ve8JIgBAAAPr4QkOAEAAInBieiZ9@5Ii5QkaAEAAI0EgUKJ" 1426 | . "BIpEifCDwAGJRCQYSIuEJHABAABGiRSI64aLfCRQi0QkCItUJHgBVCRISItUJHBI" 1427 | . "AVQkQAH4ObwkiAEAAH4JiUQkUOmk@v@@i0QkGESLpCRQAQAAD6+EJJABAADB+AqJ" 1428 | . "RCQcSIsEJMdEJEAAAAAARTH@i1gEidgPts8PttPB6BAPtsCJxw+v+InID6@Bibwk" 1429 | . "mAAAAImEJJwAAACJ0A+vwomEJJQAAADpffX@@8dEJEAAAAAAx0QkHAAAAABFMf@H" 1430 | . "RCQYAAAAAOn19P@@i5QkWAEAAIXSD4589v@@Q40EZESLdCQIQo0spQAAAAAx9jH@" 1431 | . "SJhIA4QkYAEAAEmJxUWF5H5aSIuUJDABAABJY8ZMY99FMclNAetIjUwCAg8fRAAA" 1432 | . "D7YRSIPBBERr0iYPtlH7a8JLQY0UAkQPtlH6RInQweAERCnQAdDB+AdDiAQLSYPB" 1433 | . "AUU5zH@KQQHuRAHng8YBRAN0JCA5tCRYAQAAdZBIi3wkWDHSQY1sJP9EiXwkSEUx" 1434 | . "0olcJCBBiddIifhIg8ABSIlEJAi4AQAAAEiJxouEJFgBAABIKf6LfCQwSIl0JBBE" 1435 | . "jXD@RYXkD47TAAAASItEJAhNY99Ii3QkKEuNVB0BTo0MGEiLRCQQTAHeTQHpSo0M" 1436 | . "GDHATAHpZi4PH4QAAAAAAEiFwA+EgQMAADnFD4R5AwAARYXSD4RwAwAARTnWD4Rn" 1437 | . "AwAARA+2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EEUPtv8Pr9JFD6@@RDn6D4dz@@@@D7bXD6@JD6@SOdEPh2L@" 1467 | . "@@8PttMPr8APr9I50A+HUf@@@0WF9nQFg+4BeDtJg8EBSINEJFBYg0QkeBZEOUwk" 1468 | . "IA+Pkf7@@0SLdCRwRIu8JIwAAABEi5wkkAAAAOmu@f@@RYX2dcfrwESLdCRwRIu8" 1469 | . "JIwAAABEi5wkkAAAAOml@P@@i0QkIIt0JByFwA+Eff3@@0Ux0us5OYQkmAAAAHwY" 1470 | . "D6@JOYwknAAAAHwMD6@SOZQklAAAAH0Jg+4BD4hm@P@@SYPCAUQ5VCQgD44@@f@@" 1471 | . "SIuEJGgBAACLVCQoTIuMJDABAABCAxSQSIuEJHABAABCiwSQicGNQgKJTCQwwekQ" 1472 | . "SJgPtslBD7YEASnIjUoBSGPSD6@ASGPJRQ+2DAlIi0wkMA+2zUEpyUSJyUyLjCQw" 1473 | . "AQAAQQ+2FBFED7ZMJDBEKcqB+@@@@wAPh0r@@@8Pr8mNBEAPr9KNBIiNBFA5ww+C" 1474 | . "VP@@@+lY@@@@x0QkHAAAAADHRCQYAAAAAOlF9@@@RDm0JLABAABEifAPjhvx@@+J" 1475 | . "+CuEJMABAABFMdKDwAFBD0jCicGLhCTAAQAAjUQH@0E5w0EPTsOJxkSJ6CuEJLgB" 1476 | . "AACDwAFED0nQi4QkuAEAAEGNRAX@OcUPTsU5zolEJCAPjEH7@@9EieJJY8IPr9FI" 1477 | . "Y9JIAdBIA4QkYAEAAEmJwY1GAYlEJCiLRCQgRCnQSI1wAUQ7VCQgfxNKjRQOTInI" 1478 | . "gCADSIPAAUg50HX0g8EBTANMJFg7TCQoddjp6Pr@@4uMJCgBAACFyQ+FQf@@@+nU" 1479 | . "+v@@kJCQkJCQkJCQkJCQkA==" 1480 | MyFunc:=this.MCode(StrReplace((A_PtrSize=8?x64:x32),"@","/")) 1481 | } 1482 | text:=j[1], w:=j[2], h:=j[3] 1483 | , err1:=this.Floor(j[4] ? j[5] : ini.err1) 1484 | , err0:=this.Floor(j[4] ? j[6] : ini.err0) 1485 | , mode:=j[7], color:=j[8], n:=j[9] 1486 | ok:=(!ini.bits.Scan0 || mode<1 || mode>5) ? 0 1487 | : DllCall(MyFunc.Ptr, "int",mode, "uint",color, "uint",n, "int",dir 1488 | , "Ptr",ini.bits.Scan0, "int",ini.bits.Stride 1489 | , "int",sx, "int",sy, "int",sw, "int",sh 1490 | , "Ptr",ini.ss, "Ptr",ini.s1, "Ptr",ini.s0 1491 | , "Ptr",text, "int",w, "int",h 1492 | , "int",Floor(Abs(err1)*1024), "int",Floor(Abs(err0)*1024) 1493 | , "int",(err1<0||err0<0), "Ptr",ini.allpos, "int",ini.allpos_max 1494 | , "int",Floor(w*ini.zoomW), "int",Floor(h*ini.zoomH)) 1495 | return ok 1496 | } 1497 | 1498 | code() 1499 | { 1500 | return " 1501 | ( 1502 | 1503 | //***** C source code of machine code ***** 1504 | // gcc.exe -m32/-m64 -O2 1505 | 1506 | int __attribute__((__stdcall__)) PicFind( 1507 | int mode, unsigned int c, unsigned int n, int dir 1508 | , unsigned char * Bmp, int Stride 1509 | , int sx, int sy, int sw, int sh 1510 | , unsigned char * ss, unsigned int * s1, unsigned int * s0 1511 | , unsigned char * text, int w, int h 1512 | , int err1, int err0, int more_err 1513 | , unsigned int * allpos, int allpos_max 1514 | , int new_w, int new_h ) 1515 | { 1516 | int ok, o, i, j, k, v, e1, e0, len1, len0, max, pic, shape, sort; 1517 | int x, y, x1, y1, x2, y2, x3, y3, r, g, b, rr, gg, bb, dR, dG, dB; 1518 | int ii, jj, RunDir, DirCount, RunCount, AllCount1, AllCount2; 1519 | unsigned int c1, c2, *cors, *arr; 1520 | unsigned char *ts, *gs; 1521 | ok=0; o=0; v=0; len1=0; len0=0; ts=ss+sw; gs=ss+sw*3; 1522 | arr=allpos+allpos_max; sort=(dir==0); 1523 | //---------------------- 1524 | if (mode==5) 1525 | { 1526 | if (pic=(c==2)) // FindPic 1527 | { 1528 | cors=(unsigned int *)(text+w*h*4); j=(err0>>10)+1; n*=2; 1529 | for (y=0; y>16)&0xFF)-rr; g=((c1>>8)&0xFF)-gg; b=(c1&0xFF)-bb; 1538 | v=(c2<0x1000000) ? (3*r*r+4*g*g+2*b*b<=c2) 1539 | : (r*r<=((c2>>16)&0xFF)*((c2>>16)&0xFF) 1540 | && g*g<=((c2>>8)&0xFF)*((c2>>8)&0xFF) && b*b<=(c2&0xFF)*(c2&0xFF)); 1541 | if (v) goto NoMatch1; 1542 | } 1543 | s1[len1]=(y*new_h/h)*Stride+(x*new_w/w)*4; 1544 | s0[len1++]=rr<<16|gg<<8|bb; 1545 | NoMatch1:; 1546 | } 1547 | } 1548 | c2=cors[1]; r=(c2>>16)&0xFF; g=(c2>>8)&0xFF; b=c2&0xFF; dR=r*r; dG=g*g; dB=b*b; 1549 | } 1550 | else // FindMultiColor or FindColor 1551 | { 1552 | shape=(c==1); // FindShape 1553 | cors=(unsigned int *)text; 1554 | for (i=0; i>16; x=c&0xFFFF; 1557 | s1[len1]=(y*new_h/h)*Stride+(x*new_w/w)*4; 1558 | s0[len1++]=o+cors[o+1]*2; 1559 | } 1560 | cors+=2; 1561 | } 1562 | goto StartLookUp; 1563 | } 1564 | //---------------------- 1565 | // Generate Lookup Table 1566 | for (y=0; y>16; x=c&0xFFFF; 1583 | c=(y*new_h/h)*Stride+(x*new_w/w)*4; 1584 | goto StartLookUp; 1585 | } 1586 | //---------------------- 1587 | // Generate Two Value Image 1588 | o=sy*Stride+sx*4; j=Stride-sw*4; i=0; 1589 | if (mode==1) // Color Mode 1590 | { 1591 | cors=(unsigned int *)(text+w*h); n*=2; 1592 | for (y=0; y>16)&0xFF)-rr; g=((c1>>8)&0xFF)-gg; b=(c1&0xFF)-bb; 1601 | v=(c2<0x1000000) ? (3*r*r+4*g*g+2*b*b<=c2) 1602 | : (r*r<=((c2>>16)&0xFF)*((c2>>16)&0xFF) 1603 | && g*g<=((c2>>8)&0xFF)*((c2>>8)&0xFF) && b*b<=(c2&0xFF)*(c2&0xFF)); 1604 | if (v) break; 1605 | } 1606 | ts[i]=(v) ? 1:0; 1607 | } 1608 | } 1609 | } 1610 | else if (mode==2) // Gray Threshold Mode 1611 | { 1612 | c=(c+1)<<7; 1613 | for (y=0; y>7; 1623 | } 1624 | for (i=0, y=0; yn || gs[i+1]>n 1632 | || gs[i-sw]>n || gs[i+sw]>n 1633 | || gs[i-sw-1]>n || gs[i-sw+1]>n 1634 | || gs[i+sw-1]>n || gs[i+sw+1]>n) ? 1:0; 1635 | } 1636 | } 1637 | //---------------------- 1638 | StartLookUp: 1639 | for (i=0, y=0; y=4) { ss[i]=4; continue; } 1644 | r=ts[i]; g=(x==0 ? 3 : ts[i-1]); b=(x==sw-1 ? 3 : ts[i+1]); 1645 | if (more_err) 1646 | ss[i]=4|(r==2||r==1||g==1||b==1)<<1|(r==2||r==0||g==0||b==0); 1647 | else 1648 | ss[i]=4|(r==2||r==1)<<1|(r==2||r==0); 1649 | } 1650 | } 1651 | if (mode<4 && more_err) sx++; 1652 | err1=(len1*err1)>>10; 1653 | err0=(len0*err0)>>10; 1654 | if (err1>=len1) len1=0; 1655 | if (err0>=len0) len0=0; 1656 | max=(len1>len0) ? len1 : len0; 1657 | w=new_w; h=new_h; x1=0; y1=0; x2=sw-w; y2=sh-h; 1658 | // 1 ==> ( Left to Right ) Top to Bottom 1659 | // 2 ==> ( Right to Left ) Top to Bottom 1660 | // 3 ==> ( Left to Right ) Bottom to Top 1661 | // 4 ==> ( Right to Left ) Bottom to Top 1662 | // 5 ==> ( Top to Bottom ) Left to Right 1663 | // 6 ==> ( Bottom to Top ) Left to Right 1664 | // 7 ==> ( Top to Bottom ) Right to Left 1665 | // 8 ==> ( Bottom to Top ) Right to Left 1666 | // 9 ==> Center to Four Sides 1667 | if (dir==9) 1668 | { 1669 | x=(x1+x2)/2; y=(y1+y2)/2; i=x2-x1+1; j=y2-y1+1; 1670 | AllCount1=i*j; i=(i>j?i:j)+8; 1671 | AllCount2=i*i; RunCount=0; DirCount=1; RunDir=0; 1672 | for (ii=0; RunCount=x1 && x<=x2 && y>=y1 && y<=y2) 1677 | { 1678 | RunCount++; 1679 | goto FindPos; 1680 | FindPos_GoBak:; 1681 | } 1682 | if (RunDir==0) y--; 1683 | else if (RunDir==1) x++; 1684 | else if (RunDir==2) y++; 1685 | else x--; 1686 | } 1687 | if (RunDir & 1) DirCount++; 1688 | RunDir = (++RunDir) & 3; 1689 | } 1690 | goto Return1; 1691 | } 1692 | if (dir<1 || dir>8) dir=1; 1693 | if (--dir>3) { r=y1; y1=x1; x1=r; r=y2; y2=x2; x2=r; } 1694 | for (y3=y1; y3<=y2; y3++) 1695 | { 1696 | for (x3=x1; x3<=x2; x3++) 1697 | { 1698 | y=(dir & 2) ? y1+y2-y3 : y3; 1699 | x=(dir & 1) ? x1+x2-x3 : x3; 1700 | if (dir>3) { r=y; y=x; x=r; } 1701 | //---------------------- 1702 | FindPos: 1703 | e1=err1; e0=err0; o=y*sw+x; 1704 | if (ss[o]<4) goto NoMatch; 1705 | if (mode<4) 1706 | { 1707 | for (i=0; i>16)&0xFF); 1721 | g=Bmp[1+j]-((c>>8)&0xFF); b=Bmp[j]-(c&0xFF); 1722 | v=(c2<0x1000000)?(3*r*r+4*g*g+2*b*b>c2):(r*r>dR||g*g>dG||b*b>dB); 1723 | if (v && (--e1)<0) goto NoMatch; 1724 | } 1725 | } 1726 | else 1727 | { 1728 | for (i=0; i0xFFFFFF, n=s0[i]; j>16)&0xFF)-rr; g=((c1>>8)&0xFF)-gg; b=(c1&0xFF)-bb; 1736 | v=(c2<0x1000000) ? (3*r*r+4*g*g+2*b*b<=c2) 1737 | : (r*r<=((c2>>16)&0xFF)*((c2>>16)&0xFF) 1738 | && g*g<=((c2>>8)&0xFF)*((c2>>8)&0xFF) && b*b<=(c2&0xFF)*(c2&0xFF)); 1739 | if (v) { if (k) goto NoMatch2; goto MatchOK; } 1740 | } 1741 | if (k) goto MatchOK; 1742 | NoMatch2: 1743 | if ((--e1)<0) goto NoMatch; 1744 | MatchOK:; 1745 | } 1746 | } 1747 | } 1748 | else // mode==4 1749 | { 1750 | o=(sy+y)*Stride+(sx+x)*4; j=o+c; rr=Bmp[2+j]; gg=Bmp[1+j]; bb=Bmp[j]; 1751 | for (i=0; in && (--e1)<0) goto NoMatch; 1757 | } 1758 | if (i=allpos_max) goto Return1; 1770 | } 1771 | // Skip areas that may overlap 1772 | if (!sort) 1773 | { 1774 | r=y-h+1; if (r<0) r=0; rr=y+h-1; if (rr>sh-h) rr=sh-h; 1775 | g=x-w+1; if (g<0) g=0; gg=x+w-1; if (gg>sw-w) gg=sw-w; 1776 | for (i=r; i<=rr; i++) 1777 | for (j=g; j<=gg; j++) 1778 | ss[i*sw+j] &= 3; 1779 | } 1780 | NoMatch: 1781 | if (dir==9) goto FindPos_GoBak; 1782 | } 1783 | } 1784 | //---------------------- 1785 | Return1: 1786 | if (!sort || !allpos || w*h==1) 1787 | return ok; 1788 | // Sort by smallest error 1789 | for (i=1; i=0 && arr[j]>k; j--) 1793 | { 1794 | arr[j+1]=arr[j]; allpos[j+1]=allpos[j]; 1795 | } 1796 | arr[j+1]=k; allpos[j+1]=v; 1797 | } 1798 | // Clean up overlapping results 1799 | w*=w; h*=h; k=ok; ok=0; 1800 | for (i=0; i>16; 1803 | for (j=0; j>16)-y1; 1806 | if (x*x 1832 | if RegExMatch(v, "O)<([^>\n]*)>", r) 1833 | v:=StrReplace(v,r[0]), comment:=Trim(r[1]) 1834 | ; You can Add two fault-tolerant in the [], separated by commas 1835 | if RegExMatch(v, "O)\[([^\]\n]*)]", r) 1836 | { 1837 | v:=StrReplace(v,r[0]), r:=StrSplit(r[1] ",", ",") 1838 | , seterr:=1, err1:=r[1], err0:=r[2] 1839 | } 1840 | color:=SubStr(v,1,InStr(v,"$")-1), v:=Trim(SubStr(v,InStr(v,"$")+1)) 1841 | mode:=InStr(color,"##") ? 5 : InStr(color,"#") ? 4 1842 | : InStr(color,"**") ? 3 : InStr(color,"*") ? 2 : 1 1843 | color:=RegExReplace(StrReplace(color,"@","-"), "[*#\s]") 1844 | (mode=1 || mode=5) && color:=StrReplace(color,"0x") 1845 | if (mode=5) 1846 | { 1847 | if !(v~="^[\s\-\w.]+/[\s\-\w.]+/[\s\-\w./,]+$") ; 1848 | { 1849 | if !(hBM:=LoadPicture(v)) 1850 | { 1851 | MsgBox, 4096, Tip, Can't Load Picture ! %v% 1852 | return 1853 | } 1854 | this.GetBitmapWH(hBM, w, h) 1855 | if (w<1 || h<1) 1856 | return 1857 | hBM2:=this.CreateDIBSection(w, h, 32, Scan0) 1858 | this.CopyHBM(hBM2, 0, 0, hBM, 0, 0, w, h) 1859 | DllCall("DeleteObject", "Ptr",hBM) 1860 | if (!Scan0) 1861 | return 1862 | arr:=StrSplit(color "/", "/"), arr.Pop(), n:=arr.Length() 1863 | bmp.Push(buf:=this.Buffer(w*h*4 + n*2*4)), v:=buf.Ptr, p:=v+w*h*4-4 1864 | DllCall("RtlMoveMemory", "Ptr",v, "Ptr",Scan0, "Ptr",w*h*4) 1865 | DllCall("DeleteObject", "Ptr",hBM2), color:=Trim(arr[1],"-") 1866 | For k1,v1 in arr 1867 | c:=StrSplit(Trim(v1,"-") "-" color, "-") 1868 | , x:=this.Floor(c[2]), x:=(x<=0||x>1?0:Floor(9*255*255*(1-x)*(1-x))) 1869 | , NumPut(this.ToRGB(c[1]), 0|p+=4, "uint") 1870 | , NumPut((InStr(c[2],".")?x:this.Floor("0x" c[2])|0x1000000), 0|p+=4, "uint") 1871 | color:=2 1872 | } 1873 | else ; or or 1874 | { 1875 | color:=Trim(StrSplit(color "/", "/")[1], "-") 1876 | arr:=StrSplit(Trim(RegExReplace(v, "i)\s|0x"), ","), ",") 1877 | if !(n:=arr.Length()) 1878 | return 1879 | bmp.Push(buf:=this.Buffer(n*22*4)), v:=buf.Ptr 1880 | shape:=(n>1 && StrLen(StrSplit(arr[1] "//","/")[3])=1 ? 1:0) 1881 | For k1,v1 in arr 1882 | { 1883 | r:=StrSplit(v1 "/","/"), x:=this.Floor(r[1]), y:=this.Floor(r[2]) 1884 | , (A_Index=1) ? (x1:=x2:=x, y1:=y2:=y) 1885 | : (x1:=Min(x1,x), x2:=Max(x2,x), y1:=Min(y1,y), y2:=Max(y2,y)) 1886 | } 1887 | For k1,v1 in arr 1888 | { 1889 | r:=StrSplit(v1 "/","/"), x:=this.Floor(r[1])-x1, y:=this.Floor(r[2])-y1 1890 | , NumPut(y<<16|x, 0|p:=v+(A_Index-1)*22*4, "uint") 1891 | , NumPut(n1:=Min(Max(r.Length()-3,0),(shape?1:10)), 0|p+=4, "uint") 1892 | Loop % n1 1893 | c:=StrSplit(Trim(v1:=r[2+A_Index],"-") "-" color, "-") 1894 | , x:=this.Floor(c[2]), x:=(x<=0||x>1?0:Floor(9*255*255*(1-x)*(1-x))) 1895 | , NumPut(this.ToRGB(c[1])&0xFFFFFF|(!shape&&InStr(v1,"-")=1?0x1000000:0), 0|p+=4, "uint") 1896 | , NumPut((InStr(c[2],".")?x:this.Floor("0x" c[2])|0x1000000), 0|p+=4, "uint") 1897 | } 1898 | color:=shape, w:=x2-x1+1, h:=y2-y1+1 1899 | } 1900 | } 1901 | else 1902 | { 1903 | r:=StrSplit(v ".", "."), w:=this.Floor(r[1]) 1904 | , v:=this.base64tobit(r[2]), h:=StrLen(v)//w 1905 | if (w<1 || h<1 || StrLen(v)!=w*h) 1906 | return 1907 | arr:=StrSplit(color "/", "/"), arr.Pop(), n:=arr.Length() 1908 | , bmp.Push(buf:=this.Buffer(StrPut(v, "CP0") + n*2*4)) 1909 | , StrPut(v, buf.Ptr, "CP0"), v:=buf.Ptr, p:=v+w*h-4 1910 | , color:=this.Floor(color) 1911 | if (mode=1) 1912 | { 1913 | For k1,v1 in arr 1914 | c:=StrSplit(Trim(v1,"-") "-", "-") 1915 | , x:=this.Floor(c[2]), x:=(x<=0||x>1?0:Floor(9*255*255*(1-x)*(1-x))) 1916 | , NumPut(this.ToRGB(c[1]), 0|p+=4, "uint") 1917 | , NumPut((InStr(c[2],".")?x:this.Floor("0x" c[2])|0x1000000), 0|p+=4, "uint") 1918 | } 1919 | else if (mode=4) 1920 | { 1921 | r:=StrSplit(Trim(arr[1],"-") "-", "-") 1922 | , n:=this.Floor(r[2]), n:=(n<=0||n>1?0:Floor(9*255*255*(1-n)*(1-n))) 1923 | , c:=this.Floor(r[1]), color:=(c<1||c>w*h?0:((c-1)//w)<<16|Mod(c-1,w)) 1924 | } 1925 | } 1926 | return info[key]:=[v, w, h, seterr, err1, err0, mode, color, n, comment] 1927 | } 1928 | 1929 | ToRGB(color) ; color can use: RRGGBB, Red, Yellow, Black, White 1930 | { 1931 | static init, tab 1932 | if !VarSetCapacity(init) && (init:="1") 1933 | tab:=Object("Black", "000000", "White", "FFFFFF" 1934 | , "Red", "FF0000", "Green", "008000", "Blue", "0000FF" 1935 | , "Yellow", "FFFF00", "Silver", "C0C0C0", "Gray", "808080" 1936 | , "Teal", "008080", "Navy", "000080", "Aqua", "00FFFF" 1937 | , "Olive", "808000", "Lime", "00FF00", "Fuchsia", "FF00FF" 1938 | , "Purple", "800080", "Maroon", "800000") 1939 | return this.Floor("0x" (tab.HasKey(color)?tab[color]:color)) 1940 | } 1941 | 1942 | Buffer(size, FillByte:="") 1943 | { 1944 | local 1945 | buf:={}, buf.SetCapacity("_key", size), p:=buf.GetAddress("_key") 1946 | , (FillByte!="" && DllCall("RtlFillMemory","Ptr",p,"Ptr",size,"uchar",FillByte)) 1947 | , buf.Ptr:=p, buf.Size:=size 1948 | return buf 1949 | } 1950 | 1951 | GetBitsFromScreen(ByRef x:=0, ByRef y:=0, ByRef w:=0, ByRef h:=0 1952 | , ScreenShot:=1, ByRef zx:=0, ByRef zy:=0, ByRef zw:=0, ByRef zh:=0) 1953 | { 1954 | local 1955 | static init, CAPTUREBLT 1956 | if !VarSetCapacity(init) && (init:="1") ; thanks Descolada 1957 | { 1958 | DllCall("Dwmapi\DwmIsCompositionEnabled", "Int*",i:=0) 1959 | CAPTUREBLT:=i ? 0 : 0x40000000 1960 | } 1961 | if InStr(A_OSVersion, ".") ; thanks QQ:349029755 1962 | Try DllCall("SetThreadDpiAwarenessContext", "Ptr",-3, "Ptr") 1963 | (!IsObject(this.bits) && this.bits:={Scan0:0, hBM:0, oldzw:0, oldzh:0}) 1964 | , bits:=this.bits 1965 | if (!ScreenShot && bits.Scan0) 1966 | { 1967 | zx:=bits.zx, zy:=bits.zy, zw:=bits.zw, zh:=bits.zh 1968 | , w:=Min(x+w,zx+zw), x:=Max(x,zx), w-=x 1969 | , h:=Min(y+h,zy+zh), y:=Max(y,zy), h-=y 1970 | return bits 1971 | } 1972 | bch:=A_BatchLines, cri:=A_IsCritical 1973 | Critical 1974 | bits.BindWindow:=id:=this.BindWindow(0,0,1) 1975 | if (id) 1976 | { 1977 | WinGet, id, ID, ahk_id %id% 1978 | WinGetPos, zx, zy, zw, zh, ahk_id %id% 1979 | } 1980 | if (!id) 1981 | { 1982 | SysGet, zx, 76 1983 | SysGet, zy, 77 1984 | SysGet, zw, 78 1985 | SysGet, zh, 79 1986 | } 1987 | this.UpdateBits(bits, zx, zy, zw, zh) 1988 | , w:=Min(x+w,zx+zw), x:=Max(x,zx), w-=x 1989 | , h:=Min(y+h,zy+zh), y:=Max(y,zy), h-=y 1990 | if (!ScreenShot || w<1 || h<1 || !bits.hBM) 1991 | { 1992 | Critical % cri 1993 | SetBatchLines % bch 1994 | return bits 1995 | } 1996 | if IsFunc(k:="GetBitsFromScreen2") 1997 | && %k%(bits, x-zx, y-zy, w, h) 1998 | { 1999 | ; Get the bind window use bits.BindWindow 2000 | ; Each small range of data obtained from DXGI must be 2001 | ; copied to the screenshot cache using FindText().CopyBits() 2002 | zx:=bits.zx, zy:=bits.zy, zw:=bits.zw, zh:=bits.zh 2003 | Critical % cri 2004 | SetBatchLines % bch 2005 | return bits 2006 | } 2007 | mDC:=DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") 2008 | oBM:=DllCall("SelectObject", "Ptr",mDC, "Ptr",bits.hBM, "Ptr") 2009 | if (id) 2010 | { 2011 | if (mode:=this.BindWindow(0,0,0,1))<2 2012 | { 2013 | hDC:=DllCall("GetDCEx", "Ptr",id, "Ptr",0, "int",3, "Ptr") 2014 | DllCall("BitBlt","Ptr",mDC,"int",x-zx,"int",y-zy,"int",w,"int",h 2015 | , "Ptr",hDC, "int",x-zx, "int",y-zy, "uint",0xCC0020|CAPTUREBLT) 2016 | DllCall("ReleaseDC", "Ptr",id, "Ptr",hDC) 2017 | } 2018 | else 2019 | { 2020 | hBM2:=this.CreateDIBSection(zw, zh) 2021 | mDC2:=DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") 2022 | oBM2:=DllCall("SelectObject", "Ptr",mDC2, "Ptr",hBM2, "Ptr") 2023 | DllCall("UpdateWindow", "Ptr",id) 2024 | ; RDW_INVALIDATE=0x1|RDW_ERASE=0x4|RDW_ALLCHILDREN=0x80|RDW_FRAME=0x400 2025 | ; DllCall("RedrawWindow", "Ptr",id, "Ptr",0, "Ptr",0, "uint", 0x485) 2026 | DllCall("PrintWindow", "Ptr",id, "Ptr",mDC2, "uint",(mode>3)*3) 2027 | DllCall("BitBlt","Ptr",mDC,"int",x-zx,"int",y-zy,"int",w,"int",h 2028 | , "Ptr",mDC2, "int",x-zx, "int",y-zy, "uint",0xCC0020) 2029 | DllCall("SelectObject", "Ptr",mDC2, "Ptr",oBM2) 2030 | DllCall("DeleteDC", "Ptr",mDC2) 2031 | DllCall("DeleteObject", "Ptr",hBM2) 2032 | } 2033 | } 2034 | else 2035 | { 2036 | hDC:=DllCall("GetWindowDC","Ptr",id:=DllCall("GetDesktopWindow","Ptr"),"Ptr") 2037 | DllCall("BitBlt","Ptr",mDC,"int",x-zx,"int",y-zy,"int",w,"int",h 2038 | , "Ptr",hDC, "int",x, "int",y, "uint",0xCC0020|CAPTUREBLT) 2039 | DllCall("ReleaseDC", "Ptr",id, "Ptr",hDC) 2040 | } 2041 | if this.CaptureCursor(0,0,0,0,0,1) 2042 | this.CaptureCursor(mDC, zx, zy, zw, zh) 2043 | DllCall("SelectObject", "Ptr",mDC, "Ptr",oBM) 2044 | DllCall("DeleteDC", "Ptr",mDC) 2045 | Critical % cri 2046 | SetBatchLines % bch 2047 | return bits 2048 | } 2049 | 2050 | UpdateBits(bits, zx, zy, zw, zh) 2051 | { 2052 | local 2053 | if (zw>bits.oldzw || zh>bits.oldzh || !bits.hBM) 2054 | { 2055 | Try DllCall("DeleteObject", "Ptr",bits.hBM) 2056 | bits.hBM:=this.CreateDIBSection(zw, zh, bpp:=32, ppvBits) 2057 | , bits.Scan0:=(!bits.hBM ? 0:ppvBits) 2058 | , bits.Stride:=((zw*bpp+31)//32)*4 2059 | , bits.oldzw:=zw, bits.oldzh:=zh 2060 | } 2061 | bits.zx:=zx, bits.zy:=zy, bits.zw:=zw, bits.zh:=zh 2062 | } 2063 | 2064 | CreateDIBSection(w, h, bpp:=32, ByRef ppvBits:=0) 2065 | { 2066 | local 2067 | VarSetCapacity(bi, 40, 0), NumPut(40, bi, 0, "int") 2068 | , NumPut(w, bi, 4, "int"), NumPut(-h, bi, 8, "int") 2069 | , NumPut(1, bi, 12, "short"), NumPut(bpp, bi, 14, "short") 2070 | return DllCall("CreateDIBSection", "Ptr",0, "Ptr",&bi 2071 | , "int",0, "Ptr*",ppvBits:=0, "Ptr",0, "int",0, "Ptr") 2072 | } 2073 | 2074 | GetBitmapWH(hBM, ByRef w, ByRef h) 2075 | { 2076 | local 2077 | VarSetCapacity(bm, size:=(A_PtrSize=8 ? 32:24), 0) 2078 | , DllCall("GetObject", "Ptr",hBM, "int",size, "Ptr",&bm) 2079 | , w:=NumGet(bm,4,"int"), h:=Abs(NumGet(bm,8,"int")) 2080 | } 2081 | 2082 | CopyHBM(hBM1, x1, y1, hBM2, x2, y2, w, h, Clear:=0) 2083 | { 2084 | local 2085 | if (w<1 || h<1 || !hBM1 || !hBM2) 2086 | return 2087 | mDC1:=DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") 2088 | oBM1:=DllCall("SelectObject", "Ptr",mDC1, "Ptr",hBM1, "Ptr") 2089 | mDC2:=DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") 2090 | oBM2:=DllCall("SelectObject", "Ptr",mDC2, "Ptr",hBM2, "Ptr") 2091 | DllCall("BitBlt", "Ptr",mDC1, "int",x1, "int",y1, "int",w, "int",h 2092 | , "Ptr",mDC2, "int",x2, "int",y2, "uint",0xCC0020) 2093 | if (Clear) 2094 | DllCall("BitBlt", "Ptr",mDC1, "int",x1, "int",y1, "int",w, "int",h 2095 | , "Ptr",mDC1, "int",x1, "int",y1, "uint",MERGECOPY:=0xC000CA) 2096 | DllCall("SelectObject", "Ptr",mDC1, "Ptr",oBM1) 2097 | DllCall("DeleteDC", "Ptr",mDC1) 2098 | DllCall("SelectObject", "Ptr",mDC2, "Ptr",oBM2) 2099 | DllCall("DeleteDC", "Ptr",mDC2) 2100 | } 2101 | 2102 | CopyBits(Scan01,Stride1,x1,y1,Scan02,Stride2,x2,y2,w,h,Reverse:=0) 2103 | { 2104 | local 2105 | if (w<1 || h<1 || !Scan01 || !Scan02) 2106 | return 2107 | static init, MFCopyImage 2108 | if !VarSetCapacity(init) && (init:="1") 2109 | { 2110 | MFCopyImage:=DllCall("GetProcAddress", "Ptr" 2111 | , DllCall("LoadLibrary", "Str","Mfplat.dll", "Ptr") 2112 | , "AStr","MFCopyImage", "Ptr") 2113 | } 2114 | if (MFCopyImage && !Reverse) ; thanks QQ:121507989 2115 | { 2116 | return DllCall(MFCopyImage 2117 | , "Ptr",Scan01+y1*Stride1+x1*4, "int",Stride1 2118 | , "Ptr",Scan02+y2*Stride2+x2*4, "int",Stride2 2119 | , "uint",w*4, "uint",h) 2120 | } 2121 | ListLines % (lls:=A_ListLines)?0:0 2122 | SetBatchLines % (bch:=A_BatchLines)?"-1":"-1" 2123 | p1:=Scan01+(y1-1)*Stride1+x1*4 2124 | , p2:=Scan02+(y2-1)*Stride2+x2*4, w*=4 2125 | , (Reverse) && (p2+=(h+1)*Stride2, Stride2:=-Stride2) 2126 | Loop % h 2127 | DllCall("RtlMoveMemory","Ptr",p1+=Stride1,"Ptr",p2+=Stride2,"Ptr",w) 2128 | SetBatchLines % bch 2129 | ListLines % lls 2130 | } 2131 | 2132 | DrawHBM(hBM, lines) 2133 | { 2134 | local 2135 | mDC:=DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") 2136 | oBM:=DllCall("SelectObject", "Ptr",mDC, "Ptr",hBM, "Ptr") 2137 | oldc:="", brush:=0, VarSetCapacity(rect, 16) 2138 | For k,v in lines ; [ [x, y, w, h, color] ] 2139 | if IsObject(v) 2140 | { 2141 | if (oldc!=v[5]) 2142 | { 2143 | oldc:=v[5], BGR:=(oldc&0xFF)<<16|oldc&0xFF00|(oldc>>16)&0xFF 2144 | DllCall("DeleteObject", "Ptr",brush) 2145 | brush:=DllCall("CreateSolidBrush", "uint",BGR, "Ptr") 2146 | } 2147 | DllCall("SetRect", "Ptr",&rect, "int",v[1], "int",v[2] 2148 | , "int",v[1]+v[3], "int",v[2]+v[4]) 2149 | DllCall("FillRect", "Ptr",mDC, "Ptr",&rect, "Ptr",brush) 2150 | } 2151 | DllCall("DeleteObject", "Ptr",brush) 2152 | DllCall("SelectObject", "Ptr",mDC, "Ptr",oBM) 2153 | DllCall("DeleteObject", "Ptr",mDC) 2154 | } 2155 | 2156 | ; Bind the window so that it can find images when obscured 2157 | ; by other windows, it's equivalent to always being 2158 | ; at the front desk. Unbind Window using FindText().BindWindow(0) 2159 | 2160 | BindWindow(bind_id:=0, bind_mode:=0, get_id:=0, get_mode:=0) 2161 | { 2162 | local 2163 | (!IsObject(this.bind) && this.bind:={id:0, mode:0, oldStyle:0}) 2164 | , bind:=this.bind 2165 | if (get_id) 2166 | return bind.id 2167 | if (get_mode) 2168 | return bind.mode 2169 | if (bind_id) 2170 | { 2171 | bind.id:=bind_id:=this.Floor(bind_id) 2172 | , bind.mode:=bind_mode, bind.oldStyle:=0 2173 | if (bind_mode & 1) 2174 | { 2175 | WinGet, i, ExStyle, ahk_id %bind_id% 2176 | bind.oldStyle:=i 2177 | WinSet, Transparent, 255, ahk_id %bind_id% 2178 | Loop 30 2179 | { 2180 | Sleep 100 2181 | WinGet, i, Transparent, ahk_id %bind_id% 2182 | } 2183 | Until (i=255) 2184 | } 2185 | } 2186 | else 2187 | { 2188 | bind_id:=bind.id 2189 | if (bind.mode & 1) 2190 | WinSet, ExStyle, % bind.oldStyle, ahk_id %bind_id% 2191 | bind.id:=0, bind.mode:=0, bind.oldStyle:=0 2192 | } 2193 | } 2194 | 2195 | ; Use FindText().CaptureCursor(1) to Capture Cursor 2196 | ; Use FindText().CaptureCursor(0) to Cancel Capture Cursor 2197 | 2198 | CaptureCursor(hDC:=0, zx:=0, zy:=0, zw:=0, zh:=0, get_cursor:=0) 2199 | { 2200 | local 2201 | if (get_cursor) 2202 | return this.Cursor 2203 | if (hDC=1 || hDC=0) && (zw=0) 2204 | { 2205 | this.Cursor:=hDC 2206 | return 2207 | } 2208 | VarSetCapacity(mi, 40, 0), NumPut(16+A_PtrSize, mi, "int") 2209 | DllCall("GetCursorInfo", "Ptr",&mi) 2210 | bShow:=NumGet(mi, 4, "int") 2211 | hCursor:=NumGet(mi, 8, "Ptr") 2212 | x:=NumGet(mi, 8+A_PtrSize, "int") 2213 | y:=NumGet(mi, 12+A_PtrSize, "int") 2214 | if (!bShow) || (x=zx+zw || y>=zy+zh) 2215 | return 2216 | VarSetCapacity(ni, 40, 0) 2217 | DllCall("GetIconInfo", "Ptr",hCursor, "Ptr",&ni) 2218 | xCenter:=NumGet(ni, 4, "int") 2219 | yCenter:=NumGet(ni, 8, "int") 2220 | hBMMask:=NumGet(ni, (A_PtrSize=8?16:12), "Ptr") 2221 | hBMColor:=NumGet(ni, (A_PtrSize=8?24:16), "Ptr") 2222 | DllCall("DrawIconEx", "Ptr",hDC 2223 | , "int",x-xCenter-zx, "int",y-yCenter-zy, "Ptr",hCursor 2224 | , "int",0, "int",0, "int",0, "int",0, "int",3) 2225 | DllCall("DeleteObject", "Ptr",hBMMask) 2226 | DllCall("DeleteObject", "Ptr",hBMColor) 2227 | } 2228 | 2229 | MCode(hex) 2230 | { 2231 | local 2232 | flag:=((hex~="[^A-Fa-f\d\s]") ? 1:4), len:=0 2233 | Loop 2 2234 | if !DllCall("crypt32\CryptStringToBinary", "Str",hex, "uint",0, "uint",flag 2235 | , "Ptr",(A_Index=1?0:(p:=this.Buffer(len)).Ptr), "uint*",len, "Ptr",0, "Ptr",0) 2236 | return 2237 | if DllCall("VirtualProtect", "Ptr",p.Ptr, "Ptr",len, "uint",0x40, "uint*",0) 2238 | return p 2239 | } 2240 | 2241 | bin2hex(addr, size, base64:=0) 2242 | { 2243 | local 2244 | flag:=(base64 ? 1:4)|0x40000000, len:=0 2245 | Loop 2 2246 | DllCall("crypt32\CryptBinaryToString", "Ptr",addr, "uint",size, "uint",flag 2247 | , "Ptr",(A_Index=1?0:(p:=this.Buffer(len*2)).Ptr), "uint*",len) 2248 | return RegExReplace(StrGet(p.Ptr, len), "\s+") 2249 | } 2250 | 2251 | base64tobit(s) 2252 | { 2253 | local 2254 | ListLines % (lls:=A_ListLines)?0:0 2255 | Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 2256 | SetFormat, IntegerFast, d 2257 | Loop Parse, Chars 2258 | if InStr(s, A_LoopField, 1) 2259 | s:=RegExReplace(s, "[" A_LoopField "]", ((i:=A_Index-1)>>5&1) 2260 | . (i>>4&1) . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)) 2261 | s:=RegExReplace(RegExReplace(s,"[^01]+"),"10*$") 2262 | ListLines % lls 2263 | return s 2264 | } 2265 | 2266 | bit2base64(s) 2267 | { 2268 | local 2269 | ListLines % (lls:=A_ListLines)?0:0 2270 | s:=RegExReplace(s,"[^01]+") 2271 | s.=SubStr("100000",1,6-Mod(StrLen(s),6)) 2272 | s:=RegExReplace(s,".{6}","|$0") 2273 | Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 2274 | SetFormat, IntegerFast, d 2275 | Loop Parse, Chars 2276 | s:=StrReplace(s, "|" . ((i:=A_Index-1)>>5&1) 2277 | . (i>>4&1) . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1), A_LoopField) 2278 | ListLines % lls 2279 | return s 2280 | } 2281 | 2282 | ASCII(s) 2283 | { 2284 | local 2285 | if RegExMatch(s, "O)\$(\d+)\.([\w+/]+)", r) 2286 | { 2287 | s:=RegExReplace(this.base64tobit(r[2]),".{" r[1] "}","$0`n") 2288 | s:=StrReplace(StrReplace(s,"0","_"),"1","0") 2289 | } 2290 | else s:="" 2291 | return s 2292 | } 2293 | 2294 | ; You can put the text library at the beginning of the script, 2295 | ; and Use FindText().PicLib(Text,1) to add the text library to PicLib()'s Lib, 2296 | ; Use FindText().PicLib("comment1|comment2|...") to get text images from Lib 2297 | 2298 | PicLib(comments, add_to_Lib:=0, index:=1) 2299 | { 2300 | local 2301 | (!IsObject(this.Lib) && this.Lib:=[]), Lib:=this.Lib 2302 | , (!Lib.HasKey(index) && Lib[index]:=[]), Lib:=Lib[index] 2303 | if (add_to_Lib) 2304 | { 2305 | re:="O)<([^>\n]*)>[^$\n]+\$[^""\r\n]+" 2306 | Loop Parse, comments, | 2307 | if RegExMatch(A_LoopField, re, r) 2308 | { 2309 | s1:=Trim(r[1]), s2:="" 2310 | Loop Parse, s1 2311 | s2.=Format("_{:d}", Ord(A_LoopField)) 2312 | (s2!="") && Lib[s2]:=r[0] 2313 | } 2314 | } 2315 | else 2316 | { 2317 | Text:="" 2318 | Loop Parse, comments, | 2319 | { 2320 | s1:=Trim(A_LoopField), s2:="" 2321 | Loop Parse, s1 2322 | s2.=Format("_{:d}", Ord(A_LoopField)) 2323 | (Lib.HasKey(s2)) && Text.="|" Lib[s2] 2324 | } 2325 | return Text 2326 | } 2327 | } 2328 | 2329 | ; Decompose a string into individual characters and get their data 2330 | 2331 | PicN(Number, index:=1) 2332 | { 2333 | return this.PicLib(RegExReplace(Number,".","|$0"), 0, index) 2334 | } 2335 | 2336 | ; Use FindText().PicX(Text) to automatically cut into multiple characters 2337 | ; Can't be used in ColorPos mode, because it can cause position errors 2338 | 2339 | PicX(Text) 2340 | { 2341 | local 2342 | if !RegExMatch(Text, "O)(<[^$\n]+)\$(\d+)\.([\w+/]+)", r) 2343 | return Text 2344 | v:=this.base64tobit(r[3]), Text:="" 2345 | c:=StrLen(StrReplace(v,"0"))<=StrLen(v)//2 ? "1":"0" 2346 | txt:=RegExReplace(v,".{" r[2] "}","$0`n") 2347 | While InStr(txt,c) 2348 | { 2349 | While !(txt~="m`n)^" c) 2350 | txt:=RegExReplace(txt,"m`n)^.") 2351 | i:=0 2352 | While (txt~="m`n)^.{" i "}" c) 2353 | i:=Format("{:d}",i+1) 2354 | v:=RegExReplace(txt,"m`n)^(.{" i "}).*","$1") 2355 | txt:=RegExReplace(txt,"m`n)^.{" i "}") 2356 | if (v!="") 2357 | Text.="|" r[1] "$" i "." this.bit2base64(v) 2358 | } 2359 | return Text 2360 | } 2361 | 2362 | ; Screenshot and retained as the last screenshot. 2363 | 2364 | ScreenShot(x1:=0, y1:=0, x2:=0, y2:=0) 2365 | { 2366 | this.FindText(,, x1, y1, x2, y2) 2367 | } 2368 | 2369 | ; Get the RGB color of a point from the last screenshot. 2370 | ; If the point to get the color is beyond the range of 2371 | ; Screen, it will return White color (0xFFFFFF). 2372 | 2373 | GetColor(x, y, fmt:=1) 2374 | { 2375 | local 2376 | bits:=this.GetBitsFromScreen(,,,,0,zx,zy,zw,zh), x-=zx, y-=zy 2377 | , c:=(x>=0 && x=0 && y=0 && x=0 && ymax_X ? x : max_X) 2408 | While (min_X!="" && min_X<=max_X) 2409 | { 2410 | LeftX:="" 2411 | For k,v in ok 2412 | { 2413 | x:=v.1, y:=v.2 2414 | if (xoffsetY) 2415 | Continue 2416 | ; Get the leftmost X coordinates 2417 | if (LeftX="" || xdx ? "*":"") . LeftOCR 2426 | ; Update for next search 2427 | min_X:=LeftX+LeftW-(overlapW>LeftW//2 ? LeftW//2:overlapW) 2428 | , dx:=LeftX+LeftW+offsetX, ocr_Y:=LeftY 2429 | , (LeftYmax_Y && max_Y:=LeftY+LeftH) 2431 | } 2432 | (ocr_X="") && ocr_X:=min_Y:=min_X:=max_Y:=0 2433 | return {text:ocr_Text, x:ocr_X, y:min_Y, w:min_X-ocr_X, h:max_Y-min_Y} 2434 | } 2435 | 2436 | ; Sort the results of FindText() from left to right 2437 | ; and top to bottom, ignore slight height difference 2438 | 2439 | Sort(ok, dy:=10) 2440 | { 2441 | local 2442 | if !IsObject(ok) 2443 | return ok 2444 | s:="", n:=150000, ypos:=[] 2445 | For k,v in ok 2446 | { 2447 | x:=v.x, y:=v.y, add:=1 2448 | For k1,v1 in ypos 2449 | if Abs(y-v1)<=dy 2450 | { 2451 | y:=v1, add:=0 2452 | Break 2453 | } 2454 | if (add) 2455 | ypos.Push(y) 2456 | s.=(y*n+x) "." k "|" 2457 | } 2458 | s:=Trim(s,"|") 2459 | Sort, s, N D| 2460 | ok2:=[] 2461 | For k,v in StrSplit(s,"|") 2462 | ok2.Push(ok[SubStr(v,InStr(v,".")+1)]) 2463 | return ok2 2464 | } 2465 | 2466 | ; Sort the results of FindText() according to the nearest distance 2467 | 2468 | Sort2(ok, px, py) 2469 | { 2470 | local 2471 | if !IsObject(ok) 2472 | return ok 2473 | s:="" 2474 | For k,v in ok 2475 | s.=((v.x-px)**2+(v.y-py)**2) "." k "|" 2476 | s:=Trim(s,"|") 2477 | Sort, s, N D| 2478 | ok2:=[] 2479 | For k,v in StrSplit(s,"|") 2480 | ok2.Push(ok[SubStr(v,InStr(v,".")+1)]) 2481 | return ok2 2482 | } 2483 | 2484 | ; Sort the results of FindText() according to the search direction 2485 | 2486 | Sort3(ok, dir:=1) 2487 | { 2488 | local 2489 | if !IsObject(ok) 2490 | return ok 2491 | s:="", n:=150000 2492 | For k,v in ok 2493 | x:=v.1, y:=v.2 2494 | , s.=(dir=1 ? y*n+x 2495 | : dir=2 ? y*n-x 2496 | : dir=3 ? -y*n+x 2497 | : dir=4 ? -y*n-x 2498 | : dir=5 ? x*n+y 2499 | : dir=6 ? x*n-y 2500 | : dir=7 ? -x*n+y 2501 | : dir=8 ? -x*n-y : y*n+x) "." k "|" 2502 | s:=Trim(s,"|") 2503 | Sort, s, N D| 2504 | ok2:=[] 2505 | For k,v in StrSplit(s,"|") 2506 | ok2.Push(ok[SubStr(v,InStr(v,".")+1)]) 2507 | return ok2 2508 | } 2509 | 2510 | ; Prompt mouse position in remote assistance 2511 | 2512 | MouseTip(x:="", y:="", w:=10, h:=10, d:=3) 2513 | { 2514 | local 2515 | if (x="") 2516 | { 2517 | VarSetCapacity(pt,16,0), DllCall("GetCursorPos","Ptr",&pt) 2518 | x:=NumGet(pt,0,"uint"), y:=NumGet(pt,4,"uint") 2519 | } 2520 | Loop 4 2521 | { 2522 | this.RangeTip(x-w, y-h, 2*w+1, 2*h+1, (A_Index & 1 ? "Red":"Blue"), d) 2523 | Sleep 500 2524 | } 2525 | this.RangeTip() 2526 | } 2527 | 2528 | ; Shows a range of the borders, similar to the ToolTip 2529 | 2530 | RangeTip(x:="", y:="", w:="", h:="", color:="Red", d:=3, num:=1) 2531 | { 2532 | local 2533 | ListLines % (lls:=A_ListLines)?0:0 2534 | static init, tab 2535 | if !VarSetCapacity(init) && (init:="1") 2536 | tab:=[] 2537 | (!tab.HasKey(num) && tab[num]:=[0,0,0,0]), Range:=tab[num] 2538 | if (x="") 2539 | { 2540 | if (Range[1]) 2541 | Loop 4 2542 | { 2543 | Gui, % Range[A_Index] ":Destroy" 2544 | Range[A_Index]:=0 2545 | } 2546 | ListLines % lls 2547 | return 2548 | } 2549 | if !(Range[1]) 2550 | { 2551 | Loop 4 2552 | { 2553 | Gui, New, +Hwndid +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000 2554 | Range[A_Index]:=id 2555 | } 2556 | } 2557 | x:=Floor(x), y:=Floor(y), w:=Floor(w), h:=Floor(h), d:=Floor(d) 2558 | Loop 4 2559 | { 2560 | i:=A_Index 2561 | , x1:=(i=2 ? x+w : x-d) 2562 | , y1:=(i=3 ? y+h : y-d) 2563 | , w1:=(i=1 || i=3 ? w+2*d : d) 2564 | , h1:=(i=2 || i=4 ? h+2*d : d) 2565 | Gui, % Range[i] ":Color", %color% 2566 | Gui, % Range[i] ":Show", NA x%x1% y%y1% w%w1% h%h1% 2567 | } 2568 | ListLines % lls 2569 | } 2570 | 2571 | State(key) 2572 | { 2573 | return GetKeyState(key,"P") || GetKeyState(key) 2574 | } 2575 | 2576 | ; Use RButton to select the screen range 2577 | 2578 | GetRange(ww:=25, hh:=8, key:="RButton") 2579 | { 2580 | local 2581 | static init, KeyOff, hk 2582 | if !VarSetCapacity(init) && (init:="1") 2583 | KeyOff:=this.GetRange.Bind(this, "Off") 2584 | if (ww=="Off") 2585 | return hk:=Trim(A_ThisHotkey, "*") 2586 | ;--------------------- 2587 | GetRange_HotkeyIf:=_Gui:=this.GuiNew() 2588 | _Gui.Opt("-Caption +ToolWindow +E0x80000") 2589 | _Gui.Title:="GetRange_HotkeyIf" 2590 | _Gui.Show("NA x0 y0 w0 h0") 2591 | ;--------------------- 2592 | if GetKeyState("Ctrl") 2593 | Send {Ctrl Up} 2594 | Hotkey, IfWinExist, GetRange_HotkeyIf 2595 | keys:=key "|Up|Down|Left|Right" 2596 | For k,v in StrSplit(keys, "|") 2597 | { 2598 | if GetKeyState(v) 2599 | Send {%v% Up} 2600 | Hotkey, *%v%, %KeyOff%, On UseErrorLevel 2601 | } 2602 | Hotkey, IfWinExist 2603 | ;--------------------- 2604 | Critical % (cri:=A_IsCritical)?"Off":"Off" 2605 | CoordMode, Mouse 2606 | tip:=this.Lang("s5") 2607 | hk:="", oldx:=oldy:="", keydown:=0 2608 | Loop 2609 | { 2610 | Sleep 50 2611 | MouseGetPos, x2, y2 2612 | if (hk=key) || this.State(key) || this.State("Ctrl") 2613 | { 2614 | keydown++ 2615 | if (keydown=1) 2616 | MouseGetPos, x1, y1, Bind_ID 2617 | timeout:=A_TickCount+3000 2618 | While (A_TickCount=2) 2622 | Break 2623 | } 2624 | else if (hk="Up") || this.State("Up") 2625 | (hh>1 && hh--), hk:="" 2626 | else if (hk="Down") || this.State("Down") 2627 | hh++, hk:="" 2628 | else if (hk="Left") || this.State("Left") 2629 | (ww>1 && ww--), hk:="" 2630 | else if (hk="Right") || this.State("Right") 2631 | ww++, hk:="" 2632 | x:=(keydown?x1:x2), y:=(keydown?y1:y2) 2633 | this.RangeTip(x-ww, y-hh, 2*ww+1, 2*hh+1, (A_MSec<500?"Red":"Blue")) 2634 | if (oldx=x2 && oldy=y2) 2635 | Continue 2636 | oldx:=x2, oldy:=y2 2637 | ToolTip % "x: " x " y: " y "`n" tip 2638 | } 2639 | ToolTip 2640 | this.RangeTip() 2641 | Hotkey, IfWinExist, GetRange_HotkeyIf 2642 | For k,v in StrSplit(keys, "|") 2643 | Hotkey, *%v%, %KeyOff%, Off UseErrorLevel 2644 | Hotkey, IfWinExist 2645 | GetRange_HotkeyIf.Destroy() 2646 | Critical % cri 2647 | return [x-ww, y-hh, x+ww, y+hh, Bind_ID] 2648 | } 2649 | 2650 | GetRange2(key:="LButton") 2651 | { 2652 | local 2653 | FindText_GetRange:=_Gui:=this.GuiNew() 2654 | _Gui.Opt("+LastFound +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000") 2655 | _Gui.BackColor:="White" 2656 | WinSet, Transparent, 10 2657 | this.GetBitsFromScreen(,,,,0,x,y,w,h) 2658 | _Gui.Title:="FindText_GetRange" 2659 | _Gui.Show("NA x" x " y" y " w" w " h" h) 2660 | CoordMode, Mouse 2661 | tip:=this.Lang("s7"), oldx:=oldy:="" 2662 | Loop 2663 | { 2664 | Sleep 50 2665 | MouseGetPos, x1, y1 2666 | if (oldx=x1 && oldy=y1) 2667 | Continue 2668 | oldx:=x1, oldy:=y1 2669 | ToolTip % "x: " x1 " y: " y1 " w: 0 h: 0`n" tip 2670 | } 2671 | Until this.State(key) || this.State("Ctrl") 2672 | Loop 2673 | { 2674 | Sleep 50 2675 | MouseGetPos, x2, y2 2676 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 2677 | this.RangeTip(x, y, w, h, (A_MSec<500 ? "Red":"Blue")) 2678 | if (oldx=x2 && oldy=y2) 2679 | Continue 2680 | oldx:=x2, oldy:=y2 2681 | ToolTip % "x: " x " y: " y " w: " w " h: " h "`n" tip 2682 | } 2683 | Until !(this.State(key) || this.State("Ctrl")) 2684 | ToolTip 2685 | this.RangeTip() 2686 | FindText_GetRange.Destroy() 2687 | Clipboard:=x "," y "," (x+w-1) "," (y+h-1) 2688 | return [x, y, x+w-1, y+h-1] 2689 | } 2690 | 2691 | BitmapFromScreen(ByRef x:=0, ByRef y:=0, ByRef w:=0, ByRef h:=0 2692 | , ScreenShot:=1, ByRef zx:=0, ByRef zy:=0, ByRef zw:=0, ByRef zh:=0) 2693 | { 2694 | local 2695 | bits:=this.GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy,zw,zh) 2696 | if (w<1 || h<1 || !bits.hBM) 2697 | return 2698 | hBM:=this.CreateDIBSection(w, h) 2699 | this.CopyHBM(hBM, 0, 0, bits.hBM, x-zx, y-zy, w, h, 1) 2700 | return hBM 2701 | } 2702 | 2703 | ; Quickly save screen image to BMP file for debugging 2704 | ; if file = 0 or "", save to Clipboard 2705 | 2706 | SavePic(file:=0, x1:=0, y1:=0, x2:=0, y2:=0, ScreenShot:=1) 2707 | { 2708 | local 2709 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 2710 | if (x1=0 && y1=0 && x2=0 && y2=0) 2711 | n:=150000, x:=y:=-n, w:=h:=2*n 2712 | else 2713 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 2714 | hBM:=this.BitmapFromScreen(x, y, w, h, ScreenShot) 2715 | this.SaveBitmapToFile(file, hBM) 2716 | DllCall("DeleteObject", "Ptr",hBM) 2717 | } 2718 | 2719 | ; Save Bitmap To File, if file = 0 or "", save to Clipboard 2720 | ; hBM_or_file can be a bitmap handle or file path, eg: "c:\1.bmp" 2721 | 2722 | SaveBitmapToFile(file, hBM_or_file, x:=0, y:=0, w:=0, h:=0) 2723 | { 2724 | local 2725 | if hBM_or_file is number 2726 | hBM_or_file:="HBITMAP:*" hBM_or_file 2727 | if !hBM:=DllCall("CopyImage", "Ptr",LoadPicture(hBM_or_file) 2728 | , "int",0, "int",0, "int",0, "uint",0x2008) 2729 | return 2730 | if (file) || (w!=0 && h!=0) 2731 | { 2732 | (w=0 || h=0) && this.GetBitmapWH(hBM, w, h) 2733 | hBM2:=this.CreateDIBSection(w, -h, bpp:=(file ? 24 : 32)) 2734 | this.CopyHBM(hBM2, 0, 0, hBM, x, y, w, h) 2735 | DllCall("DeleteObject", "Ptr",hBM), hBM:=hBM2 2736 | } 2737 | VarSetCapacity(dib, dib_size:=(A_PtrSize=8 ? 104:84), 0) 2738 | , DllCall("GetObject", "Ptr",hBM, "int",dib_size, "Ptr",&dib) 2739 | , pbi:=&dib+(bitmap_size:=A_PtrSize=8 ? 32:24) 2740 | , size:=NumGet(pbi+20, "uint"), pBits:=NumGet(pbi-A_PtrSize, "Ptr") 2741 | if (!file) 2742 | { 2743 | hdib:=DllCall("GlobalAlloc", "uint",2, "Ptr",40+size, "Ptr") 2744 | pdib:=DllCall("GlobalLock", "Ptr",hdib, "Ptr") 2745 | DllCall("RtlMoveMemory", "Ptr",pdib, "Ptr",pbi, "Ptr",40) 2746 | DllCall("RtlMoveMemory", "Ptr",pdib+40, "Ptr",pBits, "Ptr",size) 2747 | DllCall("GlobalUnlock", "Ptr",hdib) 2748 | DllCall("OpenClipboard", "Ptr",0) 2749 | DllCall("EmptyClipboard") 2750 | DllCall("SetClipboardData", "uint",8, "Ptr",hdib) 2751 | DllCall("CloseClipboard") 2752 | } 2753 | else 2754 | { 2755 | if InStr(file,"\") && !FileExist(dir:=RegExReplace(file,"[^\\]*$")) 2756 | Try FileCreateDir, % dir 2757 | VarSetCapacity(bf, 14, 0), NumPut(0x4D42, bf, "short") 2758 | NumPut(54+size, bf, 2, "uint"), NumPut(54, bf, 10, "uint") 2759 | f:=FileOpen(file, "w"), f.RawWrite(bf, 14) 2760 | , f.RawWrite(pbi+0, 40), f.RawWrite(pBits+0, size), f.Close() 2761 | } 2762 | DllCall("DeleteObject", "Ptr",hBM) 2763 | } 2764 | 2765 | ; Show the saved Picture file 2766 | 2767 | ShowPic(file:="", show:=1, ByRef x:="", ByRef y:="", ByRef w:="", ByRef h:="") 2768 | { 2769 | local 2770 | if (file="") 2771 | { 2772 | this.ShowScreenShot() 2773 | return 2774 | } 2775 | if !(hBM:=LoadPicture(file)) 2776 | return 2777 | this.GetBitmapWH(hBM, w, h) 2778 | bits:=this.GetBitsFromScreen(,,,,0,x,y,zw,zh) 2779 | this.UpdateBits(bits, x, y, Max(w,zw), Max(h,zh)) 2780 | this.CopyHBM(bits.hBM, 0, 0, hBM, 0, 0, w, h) 2781 | DllCall("DeleteObject", "Ptr",hBM) 2782 | if (show) 2783 | this.ShowScreenShot(x, y, x+w-1, y+h-1, 0) 2784 | return 1 2785 | } 2786 | 2787 | ; Show the memory Screenshot for debugging 2788 | 2789 | ShowScreenShot(x1:=0, y1:=0, x2:=0, y2:=0, ScreenShot:=1) 2790 | { 2791 | local 2792 | static init, hPic, oldx, oldy, oldw, oldh, FindText_Screen 2793 | if !VarSetCapacity(init) && (init:="1") 2794 | FindText_Screen:="" 2795 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 2796 | if (x1=0 && y1=0 && x2=0 && y2=0) 2797 | { 2798 | if (FindText_Screen) 2799 | FindText_Screen.Destroy(), FindText_Screen:="" 2800 | return 2801 | } 2802 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 2803 | if !hBM:=this.BitmapFromScreen(x,y,w,h,ScreenShot) 2804 | return 2805 | ;--------------- 2806 | if (!FindText_Screen) 2807 | { 2808 | FindText_Screen:=_Gui:=this.GuiNew() ; WS_EX_NOACTIVATE:=0x08000000 2809 | _Gui.Opt("+AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000") 2810 | _Gui.MarginX:=0, _Gui.MarginY:=0 2811 | id:=_Gui.Add("Pic", "w" w " h" h), hPic:=id.Hwnd 2812 | _Gui.Title:="Show Pic" 2813 | _Gui.Show("NA x" x " y" y " w" w " h" h) 2814 | oldx:=x, oldy:=y, oldw:=w, oldh:=h 2815 | } 2816 | else if (oldx!=x || oldy!=y || oldw!=w || oldh!=h) 2817 | { 2818 | if (oldw!=w || oldh!=h) 2819 | FindText_Screen[hPic].Move(,, w, h) 2820 | FindText_Screen.Show("NA x" x " y" y " w" w " h" h) 2821 | oldx:=x, oldy:=y, oldw:=w, oldh:=h 2822 | } 2823 | this.BitmapToWindow(hPic, 0, 0, hBM, 0, 0, w, h) 2824 | DllCall("DeleteObject", "Ptr",hBM) 2825 | } 2826 | 2827 | BitmapToWindow(hwnd, x1, y1, hBM, x2, y2, w, h) 2828 | { 2829 | local 2830 | mDC:=DllCall("CreateCompatibleDC", "Ptr",0, "Ptr") 2831 | oBM:=DllCall("SelectObject", "Ptr",mDC, "Ptr",hBM, "Ptr") 2832 | hDC:=DllCall("GetDC", "Ptr",hwnd, "Ptr") 2833 | DllCall("BitBlt", "Ptr",hDC, "int",x1, "int",y1, "int",w, "int",h 2834 | , "Ptr",mDC, "int",x2, "int",y2, "uint",0xCC0020) 2835 | DllCall("ReleaseDC", "Ptr",hwnd, "Ptr",hDC) 2836 | DllCall("SelectObject", "Ptr",mDC, "Ptr",oBM) 2837 | DllCall("DeleteDC", "Ptr",mDC) 2838 | } 2839 | 2840 | ; Quickly get the search data of screen image 2841 | 2842 | GetTextFromScreen(x1:=0, y1:=0, x2:=0, y2:=0, Threshold:="" 2843 | , ScreenShot:=1, ByRef rx:="", ByRef ry:="", cut:=1) 2844 | { 2845 | local 2846 | if (x1=0 && y1=0 && x2=0 && y2=0) 2847 | return this.Gui("CaptureS", ScreenShot) 2848 | SetBatchLines % (bch:=A_BatchLines)?"-1":"-1" 2849 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 2850 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 2851 | bits:=this.GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy) 2852 | if (w<1 || h<1 || !bits.Scan0) 2853 | { 2854 | SetBatchLines % bch 2855 | return 2856 | } 2857 | ListLines % (lls:=A_ListLines)?0:0 2858 | gs:=[] 2859 | j:=bits.Stride-w*4, p:=bits.Scan0+(y-zy)*bits.Stride+(x-zx)*4-j-4 2860 | Loop % h + 0*(k:=0) 2861 | Loop % w + 0*(p+=j) 2862 | c:=NumGet(0|p+=4,"uint") 2863 | , gs[++k]:=(((c>>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 2864 | if InStr(Threshold,"**") 2865 | { 2866 | Threshold:=Trim(Threshold,"* "), (Threshold="" && Threshold:=50) 2867 | s:="", sw:=w, w-=2, h-=2, x++, y++ 2868 | Loop % h + 0*(y1:=0) 2869 | Loop % w + 0*(y1++) 2870 | i:=y1*sw+A_Index+1, j:=gs[i]+Threshold 2871 | , s.=( gs[i-1]>j || gs[i+1]>j 2872 | || gs[i-sw]>j || gs[i+sw]>j 2873 | || gs[i-sw-1]>j || gs[i-sw+1]>j 2874 | || gs[i+sw-1]>j || gs[i+sw+1]>j ) ? "1":"0" 2875 | Threshold:="**" Threshold 2876 | } 2877 | else 2878 | { 2879 | Threshold:=Trim(Threshold,"* ") 2880 | if (Threshold="") 2881 | { 2882 | pp:=[] 2883 | Loop 256 2884 | pp[A_Index-1]:=0 2885 | Loop % w*h 2886 | pp[gs[A_Index]]++ 2887 | IP0:=IS0:=0 2888 | Loop 256 2889 | k:=A_Index-1, IP0+=k*pp[k], IS0+=pp[k] 2890 | Threshold:=Floor(IP0/IS0) 2891 | Loop 20 2892 | { 2893 | LastThreshold:=Threshold 2894 | IP1:=IS1:=0 2895 | Loop % LastThreshold+1 2896 | k:=A_Index-1, IP1+=k*pp[k], IS1+=pp[k] 2897 | IP2:=IP0-IP1, IS2:=IS0-IS1 2898 | if (IS1!=0 && IS2!=0) 2899 | Threshold:=Floor((IP1/IS1+IP2/IS2)/2) 2900 | if (Threshold=LastThreshold) 2901 | Break 2902 | } 2903 | } 2904 | s:="" 2905 | Loop % w*h 2906 | s.=gs[A_Index]<=Threshold ? "1":"0" 2907 | Threshold:="*" Threshold 2908 | } 2909 | ListLines % lls 2910 | ;-------------------- 2911 | w:=Format("{:d}",w), CutUp:=CutDown:=0 2912 | if (cut=1) 2913 | { 2914 | re1:="(^0{" w "}|^1{" w "})" 2915 | re2:="(0{" w "}$|1{" w "}$)" 2916 | While (s~=re1) 2917 | s:=RegExReplace(s,re1), CutUp++ 2918 | While (s~=re2) 2919 | s:=RegExReplace(s,re2), CutDown++ 2920 | } 2921 | rx:=x+w//2, ry:=y+CutUp+(h-CutUp-CutDown)//2 2922 | s:="|<>" Threshold "$" w "." this.bit2base64(s) 2923 | ;-------------------- 2924 | SetBatchLines % bch 2925 | return s 2926 | } 2927 | 2928 | ; Wait for the screen image to change within a few seconds 2929 | ; Take a Screenshot before using it: FindText().ScreenShot() 2930 | 2931 | WaitChange(time:=-1, x1:=0, y1:=0, x2:=0, y2:=0) 2932 | { 2933 | local 2934 | hash:=this.GetPicHash(x1, y1, x2, y2, 0) 2935 | time:=this.Floor(time), timeout:=A_TickCount+Round(time*1000) 2936 | Loop 2937 | { 2938 | if (hash!=this.GetPicHash(x1, y1, x2, y2, 1)) 2939 | return 1 2940 | if (time>=0 && A_TickCount>=timeout) 2941 | Break 2942 | Sleep 10 2943 | } 2944 | return 0 2945 | } 2946 | 2947 | ; Wait for the screen image to stabilize 2948 | 2949 | WaitNotChange(time:=1, timeout:=30, x1:=0, y1:=0, x2:=0, y2:=0) 2950 | { 2951 | local 2952 | oldhash:="", time:=this.Floor(time) 2953 | , timeout:=A_TickCount+Round(this.Floor(timeout)*1000) 2954 | Loop 2955 | { 2956 | hash:=this.GetPicHash(x1, y1, x2, y2, 1), t:=A_TickCount 2957 | if (hash!=oldhash) 2958 | oldhash:=hash, timeout2:=t+Round(time*1000) 2959 | if (t>=timeout2) 2960 | return 1 2961 | if (t>=timeout) 2962 | return 0 2963 | Sleep 100 2964 | } 2965 | } 2966 | 2967 | GetPicHash(x1:=0, y1:=0, x2:=0, y2:=0, ScreenShot:=1) 2968 | { 2969 | local 2970 | static init:=DllCall("LoadLibrary", "Str","ntdll", "Ptr") 2971 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 2972 | if (x1=0 && y1=0 && x2=0 && y2=0) 2973 | n:=150000, x:=y:=-n, w:=h:=2*n 2974 | else 2975 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 2976 | bits:=this.GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy), x-=zx, y-=zy 2977 | if (w<1 || h<1 || !bits.Scan0) 2978 | return 0 2979 | hash:=0, Stride:=bits.Stride, p:=bits.Scan0+(y-1)*Stride+x*4, w*=4 2980 | ListLines % (lls:=A_ListLines)?0:0 2981 | Loop % h 2982 | hash:=(hash*31+DllCall("ntdll\RtlComputeCrc32", "uint",0 2983 | , "Ptr",p+=Stride, "uint",w, "uint"))&0xFFFFFFFF 2984 | ListLines % lls 2985 | return hash 2986 | } 2987 | 2988 | WindowToScreen(ByRef x, ByRef y, x1, y1, id:="") 2989 | { 2990 | local 2991 | if (!id) 2992 | WinGet, id, ID, A 2993 | VarSetCapacity(rect, 16, 0) 2994 | , DllCall("GetWindowRect", "Ptr",id, "Ptr",&rect) 2995 | , x:=x1+NumGet(rect,"int"), y:=y1+NumGet(rect,4,"int") 2996 | } 2997 | 2998 | ScreenToWindow(ByRef x, ByRef y, x1, y1, id:="") 2999 | { 3000 | local 3001 | this.WindowToScreen(dx, dy, 0, 0, id), x:=x1-dx, y:=y1-dy 3002 | } 3003 | 3004 | ClientToScreen(ByRef x, ByRef y, x1, y1, id:="") 3005 | { 3006 | local 3007 | if (!id) 3008 | WinGet, id, ID, A 3009 | VarSetCapacity(pt, 8, 0), NumPut(0, pt, "int64") 3010 | , DllCall("ClientToScreen", "Ptr",id, "Ptr",&pt) 3011 | , x:=x1+NumGet(pt,"int"), y:=y1+NumGet(pt,4,"int") 3012 | } 3013 | 3014 | ScreenToClient(ByRef x, ByRef y, x1, y1, id:="") 3015 | { 3016 | local 3017 | this.ClientToScreen(dx, dy, 0, 0, id), x:=x1-dx, y:=y1-dy 3018 | } 3019 | 3020 | ; It is not like FindText always use Screen Coordinates, 3021 | ; But like built-in command PixelGetColor using CoordMode Settings 3022 | 3023 | PixelGetColor(x, y, ScreenShot:=1, id:="") 3024 | { 3025 | if (A_CoordModePixel="Window") 3026 | this.WindowToScreen(x, y, x, y, id) 3027 | else if (A_CoordModePixel="Client") 3028 | this.ClientToScreen(x, y, x, y, id) 3029 | if (ScreenShot) 3030 | this.ScreenShot(x, y, x, y) 3031 | return this.GetColor(x, y) 3032 | } 3033 | 3034 | ; It is not like FindText always use Screen Coordinates, 3035 | ; But like built-in command ImageSearch using CoordMode Settings 3036 | ; ImageFile can use "*n *TransBlack/White/RRGGBB-DRDGDB... d:\a.bmp" 3037 | 3038 | ImageSearch(ByRef rx:="", ByRef ry:="", x1:=0, y1:=0, x2:=0, y2:=0 3039 | , ImageFile:="", ScreenShot:=1, FindAll:=0, dir:=1) 3040 | { 3041 | local 3042 | dx:=dy:=0 3043 | if (A_CoordModePixel="Window") 3044 | this.WindowToScreen(dx, dy, 0, 0) 3045 | else if (A_CoordModePixel="Client") 3046 | this.ClientToScreen(dx, dy, 0, 0) 3047 | text:="" 3048 | Loop Parse, ImageFile, | 3049 | if (v:=Trim(A_LoopField))!="" 3050 | { 3051 | text.=InStr(v,"$") ? "|" v : "|##" 3052 | . (RegExMatch(v, "O)(^|\s)\*(\d+)\s", r) 3053 | ? Format("{:06X}", r[2]<<16|r[2]<<8|r[2]) : "000000") 3054 | . (RegExMatch(v, "Oi)(^|\s)\*Trans(\S+)\s", r) ? "/" Trim(r[2],"/"):"") 3055 | . "$" Trim(RegExReplace(v,"(^|\s)\*\S+")) 3056 | } 3057 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 3058 | if (x1=0 && y1=0 && x2=0 && y2=0) 3059 | n:=150000, x1:=y1:=-n, x2:=y2:=n 3060 | if (ok:=this.FindText(,, x1+dx, y1+dy, x2+dx, y2+dy 3061 | , 0, 0, text, ScreenShot, FindAll,,,, dir)) 3062 | { 3063 | For k,v in ok ; you can use ok:=FindText().ok 3064 | v.1-=dx, v.2-=dy, v.x-=dx, v.y-=dy 3065 | rx:=ok[1].1, ry:=ok[1].2, ErrorLevel:=0 3066 | return ok 3067 | } 3068 | else 3069 | { 3070 | rx:=ry:="", ErrorLevel:=1 3071 | return 0 3072 | } 3073 | } 3074 | 3075 | ; It is not like FindText always use Screen Coordinates, 3076 | ; But like built-in command PixelSearch using CoordMode Settings 3077 | ; ColorID can use "RRGGBB-DRDGDB|RRGGBB-DRDGDB", Variation in 0-255 3078 | 3079 | PixelSearch(ByRef rx:="", ByRef ry:="", x1:=0, y1:=0, x2:=0, y2:=0 3080 | , ColorID:="", Variation:=0, ScreenShot:=1, FindAll:=0, dir:=1) 3081 | { 3082 | local 3083 | n:=this.Floor(Variation), text:=Format("##{:06X}$0/0/", n<<16|n<<8|n) 3084 | . Trim(StrReplace(ColorID, "|", "/"), "- /") 3085 | return this.ImageSearch(rx, ry, x1, y1, x2, y2, text, ScreenShot, FindAll, dir) 3086 | } 3087 | 3088 | ; Pixel count of certain colors within the range indicated by Screen Coordinates 3089 | ; ColorID can use "RRGGBB-DRDGDB|RRGGBB-DRDGDB", Variation in 0-255 3090 | 3091 | PixelCount(x1:=0, y1:=0, x2:=0, y2:=0, ColorID:="", Variation:=0, ScreenShot:=1) 3092 | { 3093 | local 3094 | x1:=this.Floor(x1), y1:=this.Floor(y1), x2:=this.Floor(x2), y2:=this.Floor(y2) 3095 | if (x1=0 && y1=0 && x2=0 && y2=0) 3096 | n:=150000, x:=y:=-n, w:=h:=2*n 3097 | else 3098 | x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 3099 | bits:=this.GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy), x-=zx, y-=zy 3100 | sum:=0, VarSetCapacity(s1,4), VarSetCapacity(s0,4), VarSetCapacity(ss,w*(h+3)) 3101 | ini:={ bits:bits, ss:&ss, s1:&s1, s0:&s0, allpos:0, allpos_max:0 3102 | , err1:0, err0:0, zoomW:1, zoomH:1 } 3103 | n:=this.Floor(Variation), text:=Format("##{:06X}$0/0/", n<<16|n<<8|n) 3104 | . Trim(StrReplace(ColorID, "|", "/"), "- /") 3105 | if IsObject(j:=this.PicInfo(text)) 3106 | sum:=this.PicFind(ini, j, 1, x, y, w, h) 3107 | return sum 3108 | } 3109 | 3110 | ; Create color blocks containing a specified number of specified colors 3111 | ; ColorID can use "RRGGBB-DRDGDB|RRGGBB-DRDGDB", "*128", "**50" 3112 | ; Count1, Count0 is the minimum number of black and white dots after binarization of this color block 3113 | 3114 | ColorBlock(ColorID, w, h, Count1:=0, Count0:=0) 3115 | { 3116 | local 3117 | (Count0>0 && Count1:=0) 3118 | Text:="|<>[" (1-Count1/(w*h)) "," (1-Count0/(w*h)) "]" 3119 | . Trim(StrReplace(ColorID,"|","/"),"- /") . Format("${:d}.",w) 3120 | . this.bit2base64(StrReplace(Format(Format("{{}:0{:d}d{}}",w*h),0),"0" 3121 | , (Count0>0 ? "0":"1"))) 3122 | return Text 3123 | } 3124 | 3125 | Click(x:="", y:="", other1:="", other2:="", GoBack:=0) 3126 | { 3127 | local 3128 | CoordMode, Mouse, % (bak:=A_CoordModeMouse)?"Screen":"Screen" 3129 | if GoBack 3130 | MouseGetPos, oldx, oldy 3131 | MouseMove, x, y, 0 3132 | Sleep 30 3133 | Click % x "," y "," other1 "," other2 3134 | if GoBack 3135 | MouseMove, oldx, oldy, 0 3136 | CoordMode, Mouse, %bak% 3137 | return 1 3138 | } 3139 | 3140 | ; Running AHK code dynamically with new threads 3141 | 3142 | Class Thread 3143 | { 3144 | __New(args*) 3145 | { 3146 | this.pid:=this.Exec(args*) 3147 | } 3148 | __Delete() 3149 | { 3150 | Process, Close, % this.pid 3151 | } 3152 | Exec(s, Ahk:="", args:="") ; required AHK v1.1.34+ and Ahk2Exe Use .exe 3153 | { 3154 | local 3155 | Ahk:=Ahk ? Ahk : A_IsCompiled ? A_ScriptFullPath : A_AhkPath 3156 | s:="`nDllCall(""SetWindowText"",""Ptr"",A_ScriptHwnd,""Str"","""")`n" 3157 | . "`nSetBatchLines,-1`n" . s, s:=RegExReplace(s, "\R", "`r`n") 3158 | Try 3159 | { 3160 | shell:=ComObjCreate("WScript.Shell") 3161 | oExec:=shell.Exec("""" Ahk """ /script /force /CP0 * " args) 3162 | oExec.StdIn.Write(s) 3163 | oExec.StdIn.Close(), pid:=oExec.ProcessID 3164 | } 3165 | Catch 3166 | { 3167 | f:=A_Temp "\~ahk.tmp" 3168 | s:="`r`nTry FileDelete " f "`r`n" s 3169 | Try FileDelete % f 3170 | FileAppend % s, % f 3171 | r:=this.Clear.Bind(this) 3172 | SetTimer % r, -3000 3173 | Run "%Ahk%" /script /force /CP0 "%f%" %args%,, UseErrorLevel, pid 3174 | } 3175 | return pid 3176 | } 3177 | Clear() 3178 | { 3179 | Try FileDelete % A_Temp "\~ahk.tmp" 3180 | SetTimer,, Off 3181 | } 3182 | } 3183 | 3184 | ; FindText().QPC() Use the same as A_TickCount 3185 | 3186 | QPC() 3187 | { 3188 | static init, f, c 3189 | if !VarSetCapacity(init) && (init:="1") 3190 | f:=0, c:=DllCall("QueryPerformanceFrequency", "Int64*",f)+(f/=1000) 3191 | return (!DllCall("QueryPerformanceCounter","Int64*",c))*0+(c/f) 3192 | } 3193 | 3194 | ; FindText().ToolTip() Use the same as ToolTip 3195 | 3196 | ToolTip(s:="", x:="", y:="", num:=1, arg:="") 3197 | { 3198 | local 3199 | static init, ini, tip, timer 3200 | if !VarSetCapacity(init) && (init:="1") 3201 | ini:=[], tip:=[], timer:=[] 3202 | f:="ToolTip_" . this.Floor(num) 3203 | if (s="") 3204 | { 3205 | Try tip[f].Destroy() 3206 | ini[f]:="", tip[f]:="" 3207 | return 3208 | } 3209 | ;----------------- 3210 | r1:=A_CoordModeToolTip 3211 | r2:=A_CoordModeMouse 3212 | CoordMode Mouse, Screen 3213 | MouseGetPos x1, y1 3214 | CoordMode Mouse, %r1% 3215 | MouseGetPos x2, y2 3216 | CoordMode Mouse, %r2% 3217 | (x!="" && x:="x" (this.Floor(x)+x1-x2)) 3218 | , (y!="" && y:="y" (this.Floor(y)+y1-y2)) 3219 | , (x="" && y="" && x:="x" (x1+16) " y" (y1+16)) 3220 | ;----------------- 3221 | bgcolor:=arg.bgcolor!="" ? arg.bgcolor : "FAFBFC" 3222 | color:=arg.color!="" ? arg.color : "Black" 3223 | font:=arg.font ? arg.font : "Consolas" 3224 | size:=arg.size ? arg.size : "10" 3225 | bold:=arg.bold ? arg.bold : "" 3226 | trans:=arg.trans!="" ? arg.trans & 255 : 255 3227 | timeout:=arg.timeout!="" ? arg.timeout : "" 3228 | ;----------------- 3229 | r:=bgcolor "|" color "|" font "|" size "|" bold "|" trans "|" s 3230 | if (!ini.HasKey(f) || ini[f]!=r) 3231 | { 3232 | ini[f]:=r 3233 | Try tip[f].Destroy() 3234 | tip[f]:=_Gui:=this.GuiNew() ; WS_EX_LAYERED:=0x80000, WS_EX_TRANSPARENT:=0x20 3235 | _Gui.Opt("+LastFound +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x80020") 3236 | _Gui.MarginX:=2, _Gui.MarginY:=2 3237 | _Gui.BackColor:=bgcolor 3238 | _Gui.SetFont("c" color " s" size " " bold, font) 3239 | _Gui.Add("Text",, s) 3240 | _Gui.Title:=f 3241 | _Gui.Show("Hide") 3242 | WinSet, Transparent, % trans 3243 | } 3244 | tip[f].Opt("+AlwaysOnTop") 3245 | tip[f].Show("NA " x " " y) 3246 | if (timeout) 3247 | { 3248 | (!timer.HasKey(f) && timer[f]:=this.ToolTip.Bind(this,"","","",num)) 3249 | , r:=timer[f] 3250 | SetTimer % r, % -Round(Abs(this.Floor(timeout)*1000))-1 3251 | } 3252 | } 3253 | 3254 | ; FindText().ObjView() view object values for Debug 3255 | 3256 | ObjView(obj, keyname:="") 3257 | { 3258 | local 3259 | if IsObject(obj) ; thanks lexikos's type(v) 3260 | { 3261 | s:="" 3262 | For k,v in obj 3263 | s.=this.ObjView(v, keyname "[" (StrLen(k)>1000 3264 | || [k].GetCapacity(1) ? """" k """":k) "]") 3265 | } 3266 | else 3267 | s:=keyname ": " (StrLen(obj)>1000 3268 | || [obj].GetCapacity(1) ? """" obj """":obj) "`n" 3269 | if (keyname!="") 3270 | return s 3271 | ;------------------ 3272 | _Gui:=this.GuiNew("+AlwaysOnTop") 3273 | _Gui.Add("Button", "y270 w350 gCancel Default", "OK") 3274 | _Gui.Add("Edit", "xp y10 w350 h250 -Wrap -WantReturn") 3275 | _Gui["Edit1"].Value:=s 3276 | _Gui.Title:="Debug view object values" 3277 | _Gui.Show() 3278 | DetectHiddenWindows 0 3279 | WinWaitClose % "ahk_id " _Gui.Hwnd 3280 | _Gui.Destroy() 3281 | } 3282 | 3283 | EditScroll(hEdit, regex:="", line:=0, pos:=0) 3284 | { 3285 | local 3286 | ControlGetText, s,, ahk_id %hEdit% 3287 | pos:=(regex!="") ? InStr(SubStr(s,1,s~=regex) " ","`n",0,-1) 3288 | : (line>1) ? InStr(s,"`n",0,1,line-1) : pos 3289 | SendMessage, 0xB1, pos, pos,, ahk_id %hEdit% 3290 | SendMessage, 0xB7,,,, ahk_id %hEdit% 3291 | } 3292 | 3293 | LastCtrl() 3294 | { 3295 | local 3296 | return (G:=this.GuiFromHwnd(WinExist()))[G.LastHwnd] 3297 | } 3298 | 3299 | Hide(args*) 3300 | { 3301 | WinMinimize 3302 | WinHide 3303 | ToolTip 3304 | DetectHiddenWindows 0 3305 | WinWaitClose % "ahk_id " WinExist() 3306 | } 3307 | 3308 | SC(RGB, hwnd) 3309 | { 3310 | SendMessage,0x2001,0,(RGB&0xFF)<<16|RGB&0xFF00|(RGB>>16)&0xFF,,% "ahk_id " hwnd 3311 | } 3312 | 3313 | 3314 | ;==== Optional GUI interface ==== 3315 | 3316 | 3317 | Gui(cmd, arg1:="", args*) 3318 | { 3319 | local 3320 | static 3321 | local bch, cri, lls, _Gui 3322 | ListLines % InStr("MouseMove|ToolTipOff",cmd)?0:A_ListLines 3323 | static init 3324 | if !VarSetCapacity(init) && (init:="1") 3325 | { 3326 | SavePicDir:=A_Temp "\Ahk_ScreenShot\" 3327 | G_ := this.Gui.Bind(this) 3328 | G_G := this.Gui.Bind(this, "G") 3329 | G_Run := this.Gui.Bind(this, "Run") 3330 | G_Show := this.Gui.Bind(this, "Show") 3331 | G_KeyDown := this.Gui.Bind(this, "KeyDown") 3332 | G_LButtonDown := this.Gui.Bind(this, "LButtonDown") 3333 | G_RButtonDown := this.Gui.Bind(this, "RButtonDown") 3334 | G_MouseMove := this.Gui.Bind(this, "MouseMove") 3335 | G_ScreenShot := this.Gui.Bind(this, "ScreenShot") 3336 | G_ShowPic := this.Gui.Bind(this, "ShowPic") 3337 | G_Slider := this.Gui.Bind(this, "Slider") 3338 | G_ToolTip := this.Gui.Bind(this, "ToolTip") 3339 | G_ToolTipOff := this.Gui.Bind(this, "ToolTipOff") 3340 | G_SaveScr := this.Gui.Bind(this, "SaveScr") 3341 | G_PicShowOK := this.Gui.Bind(this, "PicShowOK") 3342 | G_Drag := this.Gui.Bind(this, "Drag") 3343 | FindText_Capture:=FindText_Main:="" 3344 | PrevControl:=x:=y:=oldx:=oldy:="" 3345 | Pics:=[], hBM_old:=dx:=dy:=0 3346 | bch:=A_BatchLines, cri:=A_IsCritical 3347 | Critical 3348 | #NoEnv 3349 | Lang:=this.Lang(,1), Tip_Text:=this.Lang(,2) 3350 | G_.Call("MakeCaptureWindow") 3351 | G_.Call("MakeMainWindow") 3352 | OnMessage(0x100, G_KeyDown) 3353 | OnMessage(0x201, G_LButtonDown) 3354 | OnMessage(0x204, G_RButtonDown) 3355 | OnMessage(0x200, G_MouseMove) 3356 | Menu, Tray, Add 3357 | Menu, Tray, Add, % Lang["s1"], % G_Show 3358 | if (!A_IsCompiled && A_LineFile=A_ScriptFullPath) 3359 | { 3360 | Menu, Tray, Default, % Lang["s1"] 3361 | Menu, Tray, Click, 1 3362 | Menu, Tray, Icon, Shell32.dll, 23 3363 | } 3364 | Critical % cri 3365 | SetBatchLines % bch 3366 | this.GuiNew("+LastFound").Destroy() 3367 | } 3368 | Switch cmd 3369 | { 3370 | Case "G": 3371 | id:=this.LastCtrl() 3372 | Try id.OnEvent("Click", G_Run) 3373 | Catch 3374 | Try id.OnEvent("Change", G_Run) 3375 | return 3376 | Case "Run": 3377 | Critical 3378 | G_.Call(arg1.Name) 3379 | return 3380 | Case "Show": 3381 | FindText_Main.Show(arg1 ? "Center" : "") 3382 | ControlFocus,, % "ahk_id " hscr 3383 | return 3384 | Case "Cancel", "Cancel2": 3385 | WinHide 3386 | return 3387 | Case "MakeCaptureWindow": 3388 | WindowColor:="0xDDEEFF" 3389 | Try FindText_Capture.Destroy() 3390 | FindText_Capture:=_Gui:=this.GuiNew() 3391 | _Gui.Opt("+LastFound +AlwaysOnTop -DPIScale") 3392 | _Gui.MarginX:=15, _Gui.MarginY:=10 3393 | _Gui.BackColor:=WindowColor 3394 | _Gui.SetFont("s12", "Verdana") 3395 | Tab:=_Gui.Add("Tab3", "vMyTab1 -Wrap", StrSplit(Lang["s18"],"|")) 3396 | Tab.UseTab(1) 3397 | C_:=[], Cid_:=[] 3398 | , nW:=71, nH:=25, w:=h:=12, pW:=nW*(w+1)-1, pH:=(nH+1)*(h+1)-1 3399 | id:=_Gui.Add("Text", "w" pW " h" pH), Cid_[id.Hwnd]:=-1 3400 | _Gui.Opt("-Theme") 3401 | ListLines % (lls:=A_ListLines)?0:0 3402 | Loop % nW*(nH+1) 3403 | { 3404 | i:=A_Index, j:=i=1 ? "xp yp Section" : Mod(i,nW)=1 ? "xs y+1":"x+1" 3405 | id:=_Gui.Add("Progress", j " w" w " h" h " -E0x20000 Smooth") 3406 | C_[i]:=id.Hwnd, Cid_[id.Hwnd]:=i 3407 | } 3408 | ListLines % lls 3409 | _Gui.Opt("+Theme") 3410 | _Gui.Add("Slider", "xs w" pW " vMySlider1 +Center Page20 Line10 NoTicks AltSubmit") 3411 | G_G.Call() 3412 | _Gui.Add("Slider", "ys h" pH " vMySlider2 +Center Page20 Line10 NoTicks AltSubmit +Vertical") 3413 | G_G.Call() 3414 | Tab.UseTab(2) 3415 | id:=_Gui.Add("Pic", "w" (pW-135) " h" pH " +Border -Background Section"), hPic:=id.Hwnd 3416 | Pic_hBM:=this.CreateDIBSection(Pic_w:=(pW-135), Pic_h:=pH) 3417 | _Gui.Add("Slider", "xs wp vMySlider3 +Center Page20 Line10 NoTicks AltSubmit") 3418 | G_G.Call() 3419 | _Gui.Add("Slider", "ys h" pH " vMySlider4 +Center Page20 Line10 NoTicks AltSubmit +Vertical") 3420 | G_G.Call() 3421 | _Gui.Add("ListBox", "ys w120 h200 vSelectBox AltSubmit 0x100") 3422 | G_G.Call() 3423 | _Gui.Add("Button", "y+0 wp vClearAll", Lang["ClearAll"]) 3424 | G_G.Call() 3425 | _Gui.Add("Button", "y+0 wp vOpenDir", Lang["OpenDir"]) 3426 | G_G.Call() 3427 | _Gui.Add("Button", "y+0 wp vLoadPic", Lang["LoadPic"]) 3428 | G_G.Call() 3429 | _Gui.Add("Button", "y+0 wp vSavePic", Lang["SavePic"]) 3430 | G_G.Call() 3431 | Tab.UseTab() 3432 | ;-------------- 3433 | _Gui.Add("Text", "xm Section", Lang["SelGray"]) 3434 | _Gui.Add("Edit", "x+5 yp-3 w80 vSelGray ReadOnly") 3435 | _Gui.Add("Text", "x+15 ys", Lang["SelColor"]) 3436 | _Gui.Add("Edit", "x+5 yp-3 w150 vSelColor ReadOnly") 3437 | _Gui.Add("Text", "x+15 ys", Lang["SelR"]) 3438 | _Gui.Add("Edit", "x+5 yp-3 w80 vSelR ReadOnly") 3439 | _Gui.Add("Text", "x+5 ys", Lang["SelG"]) 3440 | _Gui.Add("Edit", "x+5 yp-3 w80 vSelG ReadOnly") 3441 | _Gui.Add("Text", "x+5 ys", Lang["SelB"]) 3442 | _Gui.Add("Edit", "x+5 yp-3 w80 vSelB ReadOnly") 3443 | ;-------------- 3444 | id:=_Gui.Add("Button", "xm Hidden Section", Lang["Auto"]) 3445 | id.GetPos(pX, pY, pW, pH) 3446 | w:=Round(pW*0.75), i:=Round(w*3+15+pW*0.5-w*1.5) 3447 | _Gui.Add("Button", "xm+" i " yp w" w " hp -Wrap vRepU", Lang["RepU"]) 3448 | G_G.Call() 3449 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutU", Lang["CutU"]) 3450 | G_G.Call() 3451 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutU3", Lang["CutU3"]) 3452 | G_G.Call() 3453 | _Gui.Add("Button", "xm wp hp -Wrap vRepL", Lang["RepL"]) 3454 | G_G.Call() 3455 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutL", Lang["CutL"]) 3456 | G_G.Call() 3457 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutL3", Lang["CutL3"]) 3458 | G_G.Call() 3459 | _Gui.Add("Button", "x+15 w" pW " hp -Wrap vAuto", Lang["Auto"]) 3460 | G_G.Call() 3461 | _Gui.Add("Button", "x+15 w" w " hp -Wrap vRepR", Lang["RepR"]) 3462 | G_G.Call() 3463 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutR", Lang["CutR"]) 3464 | G_G.Call() 3465 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutR3", Lang["CutR3"]) 3466 | G_G.Call() 3467 | _Gui.Add("Button", "xm+" i " wp hp -Wrap vRepD", Lang["RepD"]) 3468 | G_G.Call() 3469 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutD", Lang["CutD"]) 3470 | G_G.Call() 3471 | _Gui.Add("Button", "x+0 wp hp -Wrap vCutD3", Lang["CutD3"]) 3472 | G_G.Call() 3473 | ;-------------- 3474 | Tab:=_Gui.Add("Tab3", "ys -Wrap", StrSplit(Lang["s2"],"|")) 3475 | Tab.UseTab(1) 3476 | _Gui.Add("Text", "x+30 y+35", Lang["Threshold"]) 3477 | _Gui.Add("Edit", "x+15 w100 vThreshold") 3478 | _Gui.Add("Button", "x+15 yp-3 vGray2Two", Lang["Gray2Two"]) 3479 | G_G.Call() 3480 | Tab.UseTab(2) 3481 | _Gui.Add("Text", "x+30 y+35", Lang["GrayDiff"]) 3482 | _Gui.Add("Edit", "x+15 w100 vGrayDiff", "50") 3483 | _Gui.Add("Button", "x+15 yp-3 vGrayDiff2Two", Lang["GrayDiff2Two"]) 3484 | G_G.Call() 3485 | Tab.UseTab(3) 3486 | _Gui.Add("Text", "x+10 y+15 Section", Lang["Similar1"] " 0") 3487 | _Gui.Add("Slider", "x+0 w100 vSimilar1 +Center Page1 NoTicks ToolTip") 3488 | G_G.Call() 3489 | _Gui.Add("Text", "x+0", "100") 3490 | _Gui.Add("Button", "x+10 ys-2 vAddColorSim", Lang["AddColorSim"]) 3491 | G_G.Call() 3492 | _Gui.Add("Text", "x+25 ys+4", Lang["DiffRGB2"]) 3493 | _Gui.Add("Edit", "x+5 ys w80 vDiffRGB2 Limit3") 3494 | _Gui.Add("UpDown", "vdRGB2 Range0-255 Wrap", 50) 3495 | _Gui.Add("Button", "x+10 ys-2 vAddColorDiff", Lang["AddColorDiff"]) 3496 | G_G.Call() 3497 | _Gui.Add("Button", "xs vUndo2", Lang["Undo2"]) 3498 | G_G.Call() 3499 | _Gui.Add("Edit", "x+10 yp+2 w340 vColorList") 3500 | _Gui.Add("Button", "x+10 yp-2 vColor2Two", Lang["Color2Two"]) 3501 | G_G.Call() 3502 | Tab.UseTab(4) 3503 | _Gui.Add("Text", "x+30 y+35", Lang["Similar2"] " 0") 3504 | _Gui.Add("Slider", "x+0 w120 vSimilar2 +Center Page1 NoTicks ToolTip") 3505 | G_G.Call() 3506 | _Gui.Add("Text", "x+0", "100") 3507 | _Gui.Add("Button", "x+15 yp-3 vColorPos2Two", Lang["ColorPos2Two"]) 3508 | G_G.Call() 3509 | Tab.UseTab(5) 3510 | _Gui.Add("Text", "x+30 y+15 Section", Lang["Similar3"] " 0") 3511 | _Gui.Add("Slider", "x+0 w120 vSimilar3 +Center Page1 NoTicks ToolTip") 3512 | G_G.Call() 3513 | _Gui.Add("Text", "x+0", "100") 3514 | _Gui.Add("Button", "x+15 ys-2 vUndo", Lang["Undo"]) 3515 | G_G.Call() 3516 | _Gui.Add("Checkbox", "xs vMultiColor", Lang["MultiColor"]) 3517 | G_G.Call() 3518 | _Gui.Add("Checkbox", "x+50 vFindShape", Lang["FindShape"]) 3519 | G_G.Call() 3520 | Tab.UseTab() 3521 | ;-------------- 3522 | _Gui.Add("Button", "xm vReset", Lang["Reset"]) 3523 | G_G.Call() 3524 | _Gui.Add("Checkbox", "x+15 yp+5 vModify", Lang["Modify"]) 3525 | G_G.Call() 3526 | _Gui.Add("Text", "x+30", Lang["Comment"]) 3527 | _Gui.Add("Edit", "x+5 yp-2 w250 vComment") 3528 | _Gui.Add("Button", "x+10 yp-3 vSplitAdd", Lang["SplitAdd"]) 3529 | G_G.Call() 3530 | _Gui.Add("Button", "x+10 vAllAdd", Lang["AllAdd"]) 3531 | G_G.Call() 3532 | _Gui.Add("Button", "x+30 wp vOK", Lang["OK"]) 3533 | G_G.Call() 3534 | _Gui.Add("Button", "x+15 wp vCancel", Lang["Cancel"]) 3535 | G_G.Call() 3536 | _Gui.Add("Button", "xm vBind0", Lang["Bind0"]) 3537 | G_G.Call() 3538 | _Gui.Add("Button", "x+10 vBind1", Lang["Bind1"]) 3539 | G_G.Call() 3540 | _Gui.Add("Button", "x+10 vBind2", Lang["Bind2"]) 3541 | G_G.Call() 3542 | _Gui.Add("Button", "x+10 vBind3", Lang["Bind3"]) 3543 | G_G.Call() 3544 | _Gui.Add("Button", "x+10 vBind4", Lang["Bind4"]) 3545 | G_G.Call() 3546 | _Gui.Add("Button", "x+30 vSavePic2", Lang["SavePic2"]) 3547 | G_G.Call() 3548 | _Gui.Title:=Lang["s3"] 3549 | _Gui.Show("Hide") 3550 | _Gui.OnEvent("DropFiles", G_Drag) 3551 | return 3552 | Case "Drag": 3553 | Try G_.Call("LoadPic", args[2][1]) 3554 | return 3555 | Case "MakeMainWindow": 3556 | Try FindText_Main.Destroy() 3557 | FindText_Main:=_Gui:=this.GuiNew() 3558 | _Gui.Opt("+LastFound +AlwaysOnTop -DPIScale") 3559 | _Gui.MarginX:=15, _Gui.MarginY:=10 3560 | _Gui.BackColor:=WindowColor 3561 | _Gui.SetFont("s12", "Verdana") 3562 | _Gui.Add("Text", "xm", Lang["NowHotkey"]) 3563 | _Gui.Add("Edit", "x+5 w160 vNowHotkey ReadOnly") 3564 | _Gui.Add("Hotkey", "x+5 w160 vSetHotkey1") 3565 | s:="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|LWin|Ctrl|Shift|Space|MButton" 3566 | . "|ScrollLock|CapsLock|Ins|Esc|BS|Del|Tab|Home|End|PgUp|PgDn" 3567 | . "|NumpadDot|NumpadSub|NumpadAdd|NumpadDiv|NumpadMult" 3568 | _Gui.Add("DDL", "x+5 w160 vSetHotkey2", StrSplit(s,"|")) 3569 | _Gui.Add("Button", "x+15 vApply", Lang["Apply"]) 3570 | G_G.Call() 3571 | _Gui.Add("GroupBox", "xm y+0 w280 h55 vMyGroup cBlack") 3572 | _Gui.Add("Text", "xp+15 yp+20 Section", Lang["Myww"] ": ") 3573 | _Gui.Add("Text", "x+0 w80", nW//2) 3574 | _Gui.Add("UpDown", "vMyww Range1-100", nW//2) 3575 | _Gui.Add("Text", "x+15 ys", Lang["Myhh"] ": ") 3576 | _Gui.Add("Text", "x+0 w80", nH//2) 3577 | id:=_Gui.Add("UpDown", "vMyhh Range1-100", nH//2) 3578 | id.GetPos(pX, pY, pW, pH) 3579 | _Gui["MyGroup"].Move(,, pX+pW, pH+30) 3580 | id:=_Gui.Add("Checkbox", "x+100 ys vAddFunc", Lang["AddFunc"] " FindText()") 3581 | id.GetPos(pX, pY, pW, pH) 3582 | pW:=pX+pW-15, pW:=(pW<720?720:pW), w:=pW//5 3583 | _Gui.Add("Button", "xm y+18 w" w " vCutL2", Lang["CutL2"]) 3584 | G_G.Call() 3585 | _Gui.Add("Button", "x+0 wp vCutR2", Lang["CutR2"]) 3586 | G_G.Call() 3587 | _Gui.Add("Button", "x+0 wp vCutU2", Lang["CutU2"]) 3588 | G_G.Call() 3589 | _Gui.Add("Button", "x+0 wp vCutD2", Lang["CutD2"]) 3590 | G_G.Call() 3591 | _Gui.Add("Button", "x+0 wp vUpdate", Lang["Update"]) 3592 | G_G.Call() 3593 | _Gui.SetFont("s6 bold", "Verdana") 3594 | _Gui.Add("Edit", "xm y+10 w" pW " h260 vMyPic -Wrap HScroll") 3595 | _Gui.SetFont("s12 norm", "Verdana") 3596 | w:=pW//3 3597 | _Gui.Add("Button", "xm w" w " vCapture", Lang["Capture"]) 3598 | G_G.Call() 3599 | _Gui.Add("Button", "x+0 wp vTest", Lang["Test"]) 3600 | G_G.Call() 3601 | _Gui.Add("Button", "x+0 wp vCopy", Lang["Copy"]) 3602 | G_G.Call() 3603 | _Gui.Add("Button", "xm y+0 wp vCaptureS", Lang["CaptureS"]) 3604 | G_G.Call() 3605 | _Gui.Add("Button", "x+0 wp vGetRange", Lang["GetRange"]) 3606 | G_G.Call() 3607 | _Gui.Add("Button", "x+0 wp vGetOffset", Lang["GetOffset"]) 3608 | G_G.Call() 3609 | _Gui.Add("Edit", "xm y+10 w130 hp vClipText") 3610 | _Gui.Add("Button", "x+0 vPaste", Lang["Paste"]) 3611 | G_G.Call() 3612 | _Gui.Add("Button", "x+0 vTestClip", Lang["TestClip"]) 3613 | G_G.Call() 3614 | id:=_Gui.Add("Button", "x+0 vGetClipOffset", Lang["GetClipOffset"]) 3615 | G_G.Call() 3616 | id.GetPos(x,, w) 3617 | w:=((pW+15)-(x+w))//2 3618 | _Gui.Add("Edit", "x+0 w" w " hp vOffset") 3619 | _Gui.Add("Button", "x+0 wp vCopyOffset", Lang["CopyOffset"]) 3620 | G_G.Call() 3621 | _Gui.SetFont("cBlue") 3622 | id:=_Gui.Add("Edit", "xm w" pW " h250 vscr -Wrap HScroll"), hscr:=id.Hwnd 3623 | _Gui.Title:=Lang["s4"] 3624 | _Gui.Show("Hide") 3625 | G_.Call("LoadScr") 3626 | OnExit(G_SaveScr) 3627 | return 3628 | Case "LoadScr": 3629 | f:=A_Temp "\~scr1.tmp" 3630 | FileRead, s, % f 3631 | FindText_Main["scr"].Value:=s 3632 | return 3633 | Case "SaveScr": 3634 | f:=A_Temp "\~scr1.tmp" 3635 | s:=FindText_Main["scr"].Value 3636 | Try FileDelete % f 3637 | FileAppend % s, % f 3638 | return 3639 | Case "Capture", "CaptureS": 3640 | _Gui:=FindText_Main 3641 | if show_gui:=WinExist("ahk_id " _Gui.Hwnd) 3642 | this.Hide() 3643 | if (cmd="Capture") 3644 | { 3645 | w:=_Gui["Myww"].Value 3646 | h:=_Gui["Myhh"].Value 3647 | p:=this.GetRange(w, h) 3648 | sx:=p[1], sy:=p[2], sw:=p[3]-p[1]+1, sh:=p[4]-p[2]+1 3649 | , Bind_ID:=p[5], bind_mode:="" 3650 | _Gui:=FindText_Capture 3651 | _Gui["MyTab1"].Choose(1) 3652 | } 3653 | else 3654 | { 3655 | sx:=0, sy:=0, sw:=1, sh:=1, Bind_ID:=WinExist("A"), bind_mode:="" 3656 | _Gui:=FindText_Capture 3657 | _Gui["MyTab1"].Choose(2) 3658 | } 3659 | n:=150000, x:=y:=-n, w:=h:=2*n 3660 | hBM:=this.BitmapFromScreen(x,y,w,h,(arg1=0?0:1)) 3661 | Pics:=[], Pics[hBM]:=1, hBM_x:=hBM_y:=0 3662 | G_.Call("CaptureUpdate") 3663 | G_.Call("PicUpdate") 3664 | Names:=["HBITMAP:*" hBM], s:="" 3665 | Loop Files, % SavePicDir "*.bmp" 3666 | Names.Push(v:=A_LoopFileFullPath), s.="|" RegExReplace(v,"i)^.*\\|\.bmp$") 3667 | _Gui["SelectBox"].Delete() 3668 | _Gui["SelectBox"].Add(StrSplit(Trim(s,"|"),"|")) 3669 | ;------------------------ 3670 | s:="SelGray|SelColor|SelR|SelG|SelB|Threshold|Comment|ColorList" 3671 | Loop Parse, s, | 3672 | _Gui[A_LoopField].Value:="" 3673 | For k,v in ["Similar1","Similar2","Similar3"] 3674 | _Gui[v].Value:=90 3675 | _Gui["Modify"].Value:=Modify:=0 3676 | _Gui["MultiColor"].Value:=MultiColor:=0 3677 | _Gui["FindShape"].Value:=FindShape:=0 3678 | _Gui["GrayDiff"].Value:=50 3679 | _Gui["Gray2Two"].Focus() 3680 | _Gui["Gray2Two"].Opt("+Default") 3681 | _Gui.Show("Center") 3682 | Event:=Result:="" 3683 | DetectHiddenWindows 0 3684 | Critical, Off 3685 | WinWaitClose % "ahk_id " _Gui.Hwnd 3686 | Critical 3687 | ToolTip 3688 | Pics[hBM]:=1, hBM_old:=0 3689 | For k,v in Pics 3690 | Try DllCall("DeleteObject", "Ptr",k) 3691 | Text:=RegExMatch(Result,"O)\|<[^>\n]*>[^$\n]+\$[^""\r\n]+",r)?r[0]:"" 3692 | ;------------------------ 3693 | _Gui:=FindText_Main 3694 | if (bind_mode!="") 3695 | { 3696 | WinGetTitle, tt, ahk_id %Bind_ID% 3697 | WinGetClass, tc, ahk_id %Bind_ID% 3698 | tt:=Trim(SubStr(tt,1,30) (tc ? " ahk_class " tc:"")) 3699 | tt:=StrReplace(RegExReplace(tt,"[;``]","``$0"),"""","""""") 3700 | Result:="`nSetTitleMatchMode 2`nid:=WinExist(""" tt """)" 3701 | . "`nFindText().BindWindow(id" (bind_mode=0 ? "":"," bind_mode) 3702 | . ") `; " Lang["s6"] " FindText().BindWindow(0)`n`n" Result 3703 | } 3704 | if (Event="OK") 3705 | { 3706 | s:="" 3707 | if (!A_IsCompiled) 3708 | Try FileRead, s, %A_LineFile% 3709 | re:="Oi)\n\s*FindText[^\n]+args\*[\s\S]*?Script_End[(){}\s]+}" 3710 | s:=RegExMatch(s, re, r) ? "`n;==========`n" r[0] "`n" : "" 3711 | _Gui["scr"].Value:=Result "`n" s 3712 | _Gui["MyPic"].Value:=Trim(this.ASCII(Result),"`n") 3713 | } 3714 | else if (Event="SplitAdd" || Event="AllAdd") 3715 | { 3716 | s:=_Gui["scr"].Value 3717 | r:=SubStr(s, 1, InStr(s,"=FindText(")) 3718 | i:=j:=0, re:="<[^>\n]*>[^$\n]+\$[^""\r\n]+" 3719 | While j:=RegExMatch(r, re,, j+1) 3720 | i:=InStr(r, "`n", 0, j) 3721 | _Gui["scr"].Value:=SubStr(s,1,i) . Result . SubStr(s,i+1) 3722 | _Gui["MyPic"].Value:=Trim(this.ASCII(Result),"`n") 3723 | } 3724 | if (Event) && RegExMatch(Result, "O)\$\d+\.[\w+/]{1,100}", r) 3725 | this.EditScroll(hscr, "\Q" r[0] "\E") 3726 | Event:=Result:=s:="" 3727 | ;---------------------- 3728 | if (show_gui && arg1="") 3729 | G_Show.Call() 3730 | else Clipboard:=Text 3731 | return Text 3732 | Case "CaptureUpdate": 3733 | nX:=sx, nY:=sy, nW:=sw, nH:=sh 3734 | bits:=this.GetBitsFromScreen(nX,nY,nW,nH,0,zx,zy) 3735 | cors:=[], show:=[], ascii:=[] 3736 | , SelPos:=bg:=color:=Result:="" 3737 | , dx:=dy:=CutLeft:=CutRight:=CutUp:=CutDown:=0 3738 | ListLines % (lls:=A_ListLines)?0:0 3739 | if (nW>0 && nH>0 && bits.Scan0) 3740 | { 3741 | j:=bits.Stride-nW*4, p:=bits.Scan0+(nY-zy)*bits.Stride+(nX-zx)*4-j-4 3742 | Loop % nH + 0*(k:=0) 3743 | Loop % nW + 0*(p+=j) 3744 | show[++k]:=1, cors[k]:=NumGet(0|p+=4,"uint") 3745 | } 3746 | Loop % 25 + 0*(ty:=dy-1)*(k:=0) 3747 | Loop % 71 + 0*(tx:=dx-1)*(ty++) 3748 | this.SC(((++tx)71 3754 | _Gui["MySlider2"].Enabled:=nH>25 3755 | _Gui["MySlider1"].Value:=0 3756 | _Gui["MySlider2"].Value:=0 3757 | return 3758 | Case "PicUpdate": 3759 | Try i:=0, i:=Pics.HasKey(hBM_old) 3760 | Try (!i) && DllCall("DeleteObject", "Ptr",hBM_old) 3761 | this.GetBitmapWH(hBM, hBM_w, hBM_h), hBM_old:=hBM 3762 | G_.Call("PicShow", 1) 3763 | return 3764 | Case "MySlider3", "MySlider4": 3765 | hBM_x:=Round(FindText_Capture["MySlider3"].Value*(hBM_w-Pic_w)/100) 3766 | hBM_y:=Round(FindText_Capture["MySlider4"].Value*(hBM_h-Pic_h)/100) 3767 | G_.Call("PicShow") 3768 | return 3769 | Case "PicShow": 3770 | w:=hBM_w-Pic_w, h:=hBM_h-Pic_h 3771 | , hBM_x:=Max(Min(hBM_x,w),0), hBM_y:=Max(Min(hBM_y,h),0) 3772 | if (w<0 || h<0) 3773 | this.DrawHBM(Pic_hBM, [[0, 0, Pic_w, Pic_h, WindowColor]]) 3774 | this.CopyHBM(Pic_hBM,0,0,hBM,hBM_x,hBM_y,Min(Pic_w,hBM_w),Min(Pic_h,hBM_h)) 3775 | if (arg1) 3776 | G_PicShowOK.Call() 3777 | else 3778 | { 3779 | this.BitmapToWindow(hPic,0,0,Pic_hBM,0,0,Pic_w,Pic_h) 3780 | SetTimer % G_PicShowOK, -1000 3781 | } 3782 | FindText_Capture["MySlider3"].Value:=w>0?Round(hBM_x/w*100):0 3783 | FindText_Capture["MySlider4"].Value:=h>0?Round(hBM_y/h*100):0 3784 | return 3785 | Case "PicShowOK": 3786 | FindText_Capture[hPic].Value:="*w0 *h0 HBITMAP:*" Pic_hBM 3787 | return 3788 | Case "Reset": 3789 | G_.Call("CaptureUpdate") 3790 | return 3791 | Case "LoadPic": 3792 | FindText_Capture.Opt("+OwnDialogs") 3793 | f:=arg1 3794 | if (f="") 3795 | { 3796 | if !FileExist(SavePicDir) 3797 | FileCreateDir % SavePicDir 3798 | f:=SavePicDir "*.bmp" 3799 | Loop Files, % f 3800 | f:=A_LoopFileFullPath 3801 | FileSelectFile, f,, %f%, Select Picture 3802 | } 3803 | if !InStr(f,"HBITMAP:") && !FileExist(f) 3804 | { 3805 | MsgBox, 4096, Tip, % Lang["s17"] 3806 | return 3807 | } 3808 | if !this.ShowPic(f, 0, sx, sy, sw, sh) 3809 | return 3810 | hBM:=this.BitmapFromScreen(sx, sy, sw, sh, 0) 3811 | sw:=Min(sw,71), sh:=Min(sh,25) 3812 | G_.Call("CaptureUpdate") 3813 | G_.Call("PicUpdate") 3814 | return 3815 | Case "SavePic": 3816 | FindText_Capture.Hide() 3817 | this.ScreenShot(), this.ShowPic("HBITMAP:*" hBM) 3818 | Try this.GuiFromHwnd(WinExist("Show Pic")).Opt("+OwnDialogs") 3819 | Loop 3820 | { 3821 | p:=this.GetRange2() 3822 | MsgBox, 4099, Tip, % Lang["s15"] 3823 | IfMsgBox, No 3824 | Continue 3825 | Break 3826 | } 3827 | IfMsgBox, Yes 3828 | G_.Call("ScreenShot", p[1] "|" p[2] "|" p[3] "|" p[4] "|0") 3829 | this.ShowPic() 3830 | return 3831 | Case "SelectBox": 3832 | SelectBox:=FindText_Capture["SelectBox"].Value 3833 | Try f:="", f:=Names[SelectBox] 3834 | if (f!="") 3835 | G_.Call("LoadPic", f) 3836 | return 3837 | Case "ClearAll": 3838 | FindText_Capture.Opt("+OwnDialogs") 3839 | MsgBox, 4100, Tip, % Lang["s19"] 3840 | IfMsgBox, Yes 3841 | { 3842 | FindText_Capture.Hide() 3843 | FileDelete % SavePicDir "*.bmp" 3844 | } 3845 | return 3846 | Case "OpenDir": 3847 | if !FileExist(SavePicDir) 3848 | FileCreateDir % SavePicDir 3849 | Run % SavePicDir 3850 | return 3851 | Case "GetRange": 3852 | _Gui:=FindText_Main 3853 | _Gui.Opt("+LastFound") 3854 | this.Hide() 3855 | p:=this.GetRange2(), v:=p[1] ", " p[2] ", " p[3] ", " p[4] 3856 | s:=_Gui["scr"].Value 3857 | re:="i)(=FindText\([^\n]*?)([^(,\n]*,){4}([^,\n]*,[^,\n]*,[^,\n]*Text)" 3858 | if SubStr(s,1,s~="i)\n\s*FindText[^\n]+args\*")~=re 3859 | { 3860 | s:=RegExReplace(s, re, "$1 " v ",$3",, 1) 3861 | _Gui["scr"].Value:=s 3862 | } 3863 | _Gui["Offset"].Value:=v 3864 | G_Show.Call() 3865 | return 3866 | Case "Test", "TestClip": 3867 | _Gui:=FindText_Main 3868 | _Gui.Opt("+LastFound") 3869 | this.Hide() 3870 | ;---------------------- 3871 | if (cmd="Test") 3872 | s:=_Gui["scr"].Value 3873 | else 3874 | s:=_Gui["ClipText"].Value 3875 | if (cmd="Test") && InStr(s, "MCode(") 3876 | { 3877 | s:="`n#NoEnv`nMenu, Tray, Click, 1`n" s "`nExitApp`n" 3878 | Thread1:=new this.Thread(s) 3879 | DetectHiddenWindows, 1 3880 | WinWait % "ahk_class AutoHotkey ahk_pid " Thread1.pid,, 3 3881 | if (!ErrorLevel) 3882 | WinWaitClose,,, 30 3883 | ; Thread1:="" ; kill the Thread 3884 | } 3885 | else 3886 | { 3887 | t:=A_TickCount, v:=X:=Y:="" 3888 | if RegExMatch(s, "O)<[^>\n]*>[^$\n]+\$[^""\r\n]+", r) 3889 | v:=this.FindText(X, Y, 0,0,0,0, 0,0, r[0]) 3890 | r:=StrSplit(Lang["s8"] "||||", "|") 3891 | MsgBox, 4096, Tip, % r[1] ":`t" (IsObject(v)?v.Length():v) "`n`n" 3892 | . r[2] ":`t" (A_TickCount-t) " " r[3] "`n`n" 3893 | . r[4] ":`t" X ", " Y "`n`n" 3894 | . r[5] ":`t<" (IsObject(v)?v[1].id:"") ">", 3 3895 | Try For i,j in v 3896 | if (i<=2) 3897 | this.MouseTip(j.x, j.y) 3898 | v:="", Clipboard:=X "," Y 3899 | } 3900 | ;---------------------- 3901 | G_Show.Call() 3902 | return 3903 | Case "GetOffset", "GetClipOffset": 3904 | FindText_Main.Hide() 3905 | p:=this.GetRange() 3906 | _Gui:=FindText_Main 3907 | if (cmd="GetOffset") 3908 | s:=_Gui["scr"].Value 3909 | else 3910 | s:=_Gui["ClipText"].Value 3911 | if RegExMatch(s, "O)<[^>\n]*>[^$\n]+\$[^""\r\n]+", r) 3912 | && this.FindText(X, Y, 0,0,0,0, 0,0, r[0]) 3913 | { 3914 | r:=StrReplace("X+" ((p[1]+p[3])//2-X) 3915 | . ", Y+" ((p[2]+p[4])//2-Y), "+-", "-") 3916 | if (cmd="GetOffset") 3917 | { 3918 | re:="i)(\(\)\.\w*Click\w*\()[^,\n]*,[^,)\n]*" 3919 | if SubStr(s,1,s~="i)\n\s*FindText[^\n]+args\*")~=re 3920 | s:=RegExReplace(s, re, "$1" r,, 1) 3921 | _Gui["scr"].Value:=s 3922 | } 3923 | _Gui["Offset"].Value:=r 3924 | } 3925 | s:="", G_Show.Call() 3926 | return 3927 | Case "Paste": 3928 | if RegExMatch(Clipboard, "O)\|?<[^>\n]*>[^$\n]+\$[^""\r\n]+", r) 3929 | { 3930 | FindText_Main["ClipText"].Value:=r[0] 3931 | FindText_Main["MyPic"].Value:=Trim(this.ASCII(r[0]),"`n") 3932 | } 3933 | return 3934 | Case "CopyOffset": 3935 | Clipboard:=FindText_Main["Offset"].Value 3936 | return 3937 | Case "Copy": 3938 | ControlGet, s, Selected,,, ahk_id %hscr% 3939 | if (s="") 3940 | { 3941 | s:=FindText_Main["scr"].Value 3942 | r:=FindText_Main["AddFunc"].Value 3943 | if (r != 1) 3944 | s:=RegExReplace(s, "i)\n\s*FindText[^\n]+args\*[\s\S]*") 3945 | , s:=RegExReplace(s, "i)\n; ok:=FindText[\s\S]*") 3946 | , s:=SubStr(s, (s~="i)\n[ \t]*Text")) 3947 | } 3948 | Clipboard:=RegExReplace(s, "\R", "`r`n") 3949 | ControlFocus,, % "ahk_id " hscr 3950 | return 3951 | Case "Apply": 3952 | _Gui:=FindText_Main 3953 | NowHotkey:=_Gui["NowHotkey"].Value 3954 | SetHotkey1:=_Gui["SetHotkey1"].Value 3955 | SetHotkey2:=_Gui["SetHotkey2"].Text 3956 | if (NowHotkey!="") 3957 | Hotkey, *%NowHotkey%,, Off UseErrorLevel 3958 | k:=SetHotkey1!="" ? SetHotkey1 : SetHotkey2 3959 | if (k!="") 3960 | Hotkey, *%k%, %G_ScreenShot%, On UseErrorLevel 3961 | _Gui["NowHotkey"].Value:=k 3962 | _Gui["SetHotkey1"].Value:="" 3963 | _Gui["SetHotkey2"].Choose(0) 3964 | return 3965 | Case "ScreenShot": 3966 | Critical 3967 | if !FileExist(SavePicDir) 3968 | FileCreateDir % SavePicDir 3969 | Loop 3970 | f:=SavePicDir . Format("{:03d}.bmp",A_Index) 3971 | Until !FileExist(f) 3972 | this.SavePic(f, StrSplit(arg1,"|")*) 3973 | CoordMode, ToolTip 3974 | this.ToolTip(Lang["s9"],, 0,, { bgcolor:"Yellow", color:"Red" 3975 | , size:48, bold:"bold", trans:200, timeout:0.2 }) 3976 | return 3977 | Case "Bind0", "Bind1", "Bind2", "Bind3", "Bind4": 3978 | this.BindWindow(Bind_ID, bind_mode:=SubStr(cmd,5)) 3979 | n:=150000, x:=y:=-n, w:=h:=2*n 3980 | hBM:=this.BitmapFromScreen(x,y,w,h,1) 3981 | G_.Call("PicUpdate") 3982 | FindText_Capture["MyTab1"].Choose(2) 3983 | this.BindWindow(0) 3984 | return 3985 | Case "MySlider1", "MySlider2": 3986 | SetTimer % G_Slider, -10 3987 | return 3988 | Case "Slider": 3989 | Critical 3990 | dx:=nW>71 ? Round(FindText_Capture["MySlider1"].Value*(nW-71)/100):0 3991 | dy:=nH>25 ? Round(FindText_Capture["MySlider2"].Value*(nH-25)/100):0 3992 | if (oldx=dx && oldy=dy) 3993 | return 3994 | ListLines % (lls:=A_ListLines)?0:0 3995 | Loop % 25 + 0*(ty:=dy-1)*(k:=0) 3996 | Loop % 71 + 0*(tx:=dx-1)*(ty++) 3997 | this.SC(((++tx)>=nW || ty>=nH || !show[i:=ty*nW+tx+1] 3998 | ? WindowColor : bg="" ? cors[i] : ascii[i] ? 0:0xFFFFFF), C_[++k]) 3999 | Loop % 71*(oldx!=dx) + 0*(i:=nW*nH+dx)*(k:=71*25) 4000 | this.SC((show[++i]?0xFF0000:0xFFFFAA), C_[++k]) 4001 | ListLines % lls 4002 | oldx:=dx, oldy:=dy 4003 | return 4004 | Case "RepColor", "CutColor": 4005 | if (cmd="RepColor") 4006 | show[k]:=1, c:=(bg="" ? cors[k] : ascii[k] ? 0:0xFFFFFF) 4007 | else 4008 | show[k]:=0, c:=WindowColor 4009 | if (tx:=Mod(k-1,nW)-dx)>=0 && tx<71 && (ty:=(k-1)//nW-dy)>=0 && ty<25 4010 | this.SC(c, C_[ty*71+tx+1]) 4011 | return 4012 | Case "RepL": 4013 | if (CutLeft<=0) || (bg!="" && InStr(color,"**") && CutLeft=1) 4014 | return 4015 | k:=CutLeft-nW, CutLeft-- 4016 | Loop % nH 4017 | k+=nW, (A_Index>CutUp && A_Index=nW) 4021 | return 4022 | CutLeft++, k:=CutLeft-nW 4023 | Loop % nH 4024 | k+=nW, (A_Index>CutUp && A_IndexCutUp && A_Index=nW) 4039 | return 4040 | CutRight++, k:=1-CutRight 4041 | Loop % nH 4042 | k+=nW, (A_Index>CutUp && A_IndexCutLeft && A_Index=nH) 4057 | return 4058 | CutUp++, k:=(CutUp-1)*nW 4059 | Loop % nW 4060 | k++, (A_Index>CutLeft && A_IndexCutLeft && A_Index=nH) 4075 | return 4076 | CutDown++, k:=(nH-CutDown)*nW 4077 | Loop % nW 4078 | k++, (A_Index>CutLeft && A_Index>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 4089 | _Gui:=FindText_Capture 4090 | _Gui["Threshold"].Focus() 4091 | Threshold:=_Gui["Threshold"].Value 4092 | if (Threshold="") 4093 | { 4094 | pp:=[] 4095 | Loop 256 4096 | pp[A_Index-1]:=0 4097 | Loop % nW*nH 4098 | if (show[A_Index]) 4099 | pp[gs[A_Index]]++ 4100 | IP0:=IS0:=0 4101 | Loop 256 4102 | k:=A_Index-1, IP0+=k*pp[k], IS0+=pp[k] 4103 | Threshold:=Floor(IP0/IS0) 4104 | Loop 20 4105 | { 4106 | LastThreshold:=Threshold 4107 | IP1:=IS1:=0 4108 | Loop % LastThreshold+1 4109 | k:=A_Index-1, IP1+=k*pp[k], IS1+=pp[k] 4110 | IP2:=IP0-IP1, IS2:=IS0-IS1 4111 | if (IS1!=0 && IS2!=0) 4112 | Threshold:=Floor((IP1/IS1+IP2/IS2)/2) 4113 | if (Threshold=LastThreshold) 4114 | Break 4115 | } 4116 | _Gui["Threshold"].Value:=Threshold 4117 | } 4118 | Threshold:=Round(Threshold) 4119 | color:="*" Threshold, k:=i:=0 4120 | Loop % nW*nH 4121 | ascii[++k]:=v:=(gs[k]<=Threshold) 4122 | , (show[k] && i:=(v?i+1:i-1)) 4123 | bg:=(i>0 ? "1":"0"), G_.Call("BlackWhite") 4124 | ListLines % lls 4125 | return 4126 | Case "GrayDiff2Two": 4127 | _Gui:=FindText_Capture 4128 | GrayDiff:=_Gui["GrayDiff"].Value 4129 | if (GrayDiff="") 4130 | { 4131 | _Gui.Opt("+OwnDialogs") 4132 | MsgBox, 4096, Tip, % Lang["s11"], 1 4133 | return 4134 | } 4135 | ListLines % (lls:=A_ListLines)?0:0 4136 | gs:=[], k:=0 4137 | Loop % nW*nH 4138 | gs[++k]:=((((c:=cors[k])>>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 4139 | if (CutLeft=0) 4140 | G_.Call("CutL") 4141 | if (CutRight=0) 4142 | G_.Call("CutR") 4143 | if (CutUp=0) 4144 | G_.Call("CutU") 4145 | if (CutDown=0) 4146 | G_.Call("CutD") 4147 | GrayDiff:=Round(GrayDiff) 4148 | color:="**" GrayDiff, k:=i:=0 4149 | Loop % nW*nH 4150 | j:=gs[++k]+GrayDiff 4151 | , ascii[k]:=v:=( gs[k-1]>j || gs[k+1]>j 4152 | || gs[k-nW]>j || gs[k+nW]>j 4153 | || gs[k-nW-1]>j || gs[k-nW+1]>j 4154 | || gs[k+nW-1]>j || gs[k+nW+1]>j ) 4155 | , (show[k] && i:=(v?i+1:i-1)) 4156 | bg:=(i>0 ? "1":"0"), G_.Call("BlackWhite") 4157 | ListLines % lls 4158 | return 4159 | Case "AddColorSim", "AddColorDiff": 4160 | _Gui:=FindText_Capture 4161 | c:=StrReplace(_Gui["SelColor"].Value, "0x") 4162 | if (c="") 4163 | { 4164 | _Gui.Opt("+OwnDialogs") 4165 | MsgBox, 4096, Tip, % Lang["s12"], 1 4166 | return 4167 | } 4168 | s:=_Gui["ColorList"].Value 4169 | if InStr(cmd, "Sim") 4170 | v:=_Gui["Similar1"].Value, v:=c "-" Round(v/100,2) 4171 | else 4172 | v:=_Gui["dRGB2"].Value, v:=c "-" Format("{:06X}",v<<16|v<<8|v) 4173 | s:=RegExReplace("/" s, "/" c "-[^/]*") . "/" v 4174 | _Gui["ColorList"].Value:=Trim(s,"/") 4175 | ControlSend,, {End}, % "ahk_id " _Gui["ColorList"].Hwnd 4176 | G_.Call("Color2Two") 4177 | return 4178 | Case "Undo2": 4179 | _Gui:=FindText_Capture 4180 | s:=_Gui["ColorList"].Value 4181 | s:=RegExReplace("/" s, "/[^/]+$") 4182 | _Gui["ColorList"].Value:=Trim(s,"/") 4183 | ControlSend,, {End}, % "ahk_id " _Gui["ColorList"].Hwnd 4184 | return 4185 | Case "Color2Two": 4186 | _Gui:=FindText_Capture 4187 | color:=RegExReplace(_Gui["ColorList"].Value, "i)\s|0x") 4188 | if (color="") 4189 | { 4190 | _Gui.Opt("+OwnDialogs") 4191 | MsgBox, 4096, Tip, % Lang["s16"], 1 4192 | return 4193 | } 4194 | ListLines % (lls:=A_ListLines)?0:0 4195 | k:=i:=v:=0, arr:=StrSplit(Trim(StrReplace(color,"@","-"), "/"), "/") 4196 | Loop % nW*nH 4197 | { 4198 | c:=cors[++k], rr:=(c>>16)&0xFF, gg:=(c>>8)&0xFF, bb:=c&0xFF 4199 | For k1,v1 in arr 4200 | { 4201 | r:=StrSplit(Trim(v1,"-") "-", "-"), c:=this.ToRGB(r[1]), n:=r[2] 4202 | , r:=((c>>16)&0xFF)-rr, g:=((c>>8)&0xFF)-gg, b:=(c&0xFF)-bb 4203 | if InStr(n, ".") 4204 | { 4205 | n:=this.Floor(n), n:=(n<=0||n>1?0:Floor(9*255*255*(1-n)*(1-n))) 4206 | if v:=(3*r*r+4*g*g+2*b*b<=n) 4207 | Break 4208 | } 4209 | else 4210 | { 4211 | c:=this.Floor("0x" n), dR:=(c>>16)&0xFF, dG:=(c>>8)&0xFF, dB:=c&0xFF 4212 | if v:=(Abs(r)<=dR && Abs(g)<=dG && Abs(b)<=dB) 4213 | Break 4214 | } 4215 | } 4216 | ascii[k]:=v, (show[k] && i:=(v?i+1:i-1)) 4217 | } 4218 | bg:=(i>0 ? "1":"0"), G_.Call("BlackWhite") 4219 | ListLines % lls 4220 | return 4221 | Case "ColorPos2Two": 4222 | _Gui:=FindText_Capture 4223 | c:=_Gui["SelColor"].Value 4224 | if (c="") 4225 | { 4226 | _Gui.Opt("+OwnDialogs") 4227 | MsgBox, 4096, Tip, % Lang["s12"], 1 4228 | return 4229 | } 4230 | n:=_Gui["Similar2"].Value, n:=Round(n/100,2), color:="#" c "-" n 4231 | , n:=(n<=0||n>1?0:Floor(9*255*255*(1-n)*(1-n))) 4232 | , rr:=(c>>16)&0xFF, gg:=(c>>8)&0xFF, bb:=c&0xFF, k:=i:=0 4233 | ListLines % (lls:=A_ListLines)?0:0 4234 | Loop % nW*nH 4235 | c:=cors[++k], r:=((c>>16)&0xFF)-rr, g:=((c>>8)&0xFF)-gg, b:=(c&0xFF)-bb 4236 | , ascii[k]:=v:=3*r*r+4*g*g+2*b*b<=n, (show[k] && i:=(v?i+1:i-1)) 4237 | bg:=(i>0 ? "1":"0"), G_.Call("BlackWhite") 4238 | ListLines % lls 4239 | return 4240 | Case "BlackWhite": 4241 | Loop % 25 + 0*(ty:=dy-1)*(k:=0) 4242 | Loop % 71 + 0*(tx:=dx-1)*(ty++) 4243 | if (k++)*0 + (++tx) StrLen(StrReplace(txt,"1")) ? "1":"0" 4346 | s:="", i:=0, k:=nW*nH+1+CutLeft 4347 | Loop % w:=nW-CutLeft-CutRight 4348 | { 4349 | i++ 4350 | if (!show[k++] && A_Index" color "$" v """`n" 4371 | Comment:=SubStr(Comment, 2) 4372 | } 4373 | } 4374 | Event:=cmd, Result:=s 4375 | _Gui.Hide() 4376 | return 4377 | } 4378 | if (!MultiColor) 4379 | txt:=Format("{:d}.",InStr(txt,"`n")-1) . this.bit2base64(txt) 4380 | else 4381 | { 4382 | n:=_Gui["Similar3"].Value, n:=Round(n/100,2), color:="##" n 4383 | , n:=(n<=0||n>1?0:Floor(9*255*255*(1-n)*(1-n))) 4384 | , arr:=StrSplit(Trim(StrReplace(Result,",","/"),"/"),"/"), s:="", i:=1 4385 | SetFormat, IntegerFast, d 4386 | Loop % arr.Length()//3 4387 | x1:=arr[i++], y1:=arr[i++], c1:=arr[i++], c:="0x" c1 4388 | , (A_Index=1 && (x:=x1, y:=y1, rr:=(c>>16)&0xFF, gg:=(c>>8)&0xFF, bb:=c&0xFF)) 4389 | , r:=((c>>16)&0xFF)-rr, g:=((c>>8)&0xFF)-gg, b:=(c&0xFF)-bb 4390 | , s.="," (x1-x) "/" (y1-y) "/" (FindShape?3*r*r+4*g*g+2*b*b<=n:c1) 4391 | txt:=SubStr(s,2) 4392 | } 4393 | s:="`nText.=""|<" Comment ">" color "$" txt """`n" 4394 | if (cmd="SplitAdd" || cmd="AllAdd") 4395 | { 4396 | Event:=cmd, Result:=s 4397 | _Gui.Hide() 4398 | return 4399 | } 4400 | x:=nX+CutLeft+(nW-CutLeft-CutRight)//2 4401 | y:=nY+CutUp+(nH-CutUp-CutDown)//2 4402 | s:=StrReplace(s, "Text.=", "Text:="), r:=StrSplit(Lang["s8"] "|||||||", "|") 4403 | s:="`; #Include `n" 4404 | . "`nt1:=A_TickCount, Text:=X:=Y:=""""`n" s 4405 | . "`nif (ok:=FindText(X, Y, " x "-150000, " 4406 | . y "-150000, " x "+150000, " y "+150000, 0, 0, Text))" 4407 | . "`n{" 4408 | . "`n `; FindText()." . "Click(" . "X, Y, ""L"")" 4409 | . "`n}`n" 4410 | . "`n`; ok:=FindText(X:=""wait"", Y:=3, 0,0,0,0,0,0,Text) `; " r[7] 4411 | . "`n`; ok:=FindText(X:=""wait0"", Y:=-1, 0,0,0,0,0,0,Text) `; " r[8] 4412 | . "`n`nMsgBox, 4096, Tip, `% """ r[1] ":``t"" (IsObject(ok)?ok.Length():ok)" 4413 | . "`n . ""``n``n" r[2] ":``t"" (A_TickCount-t1) "" " r[3] """" 4414 | . "`n . ""``n``n" r[4] ":``t"" X "", "" Y" 4415 | . "`n . ""``n``n" r[5] ":``t<"" (IsObject(ok)?ok[1].id:"""") "">""`n" 4416 | . "`nTry For i,v in ok `; ok " r[6] " ok:=FindText().ok" 4417 | . "`n if (i<=2)" 4418 | . "`n FindText().MouseTip(ok[i].x, ok[i].y)`n" 4419 | Event:=cmd, Result:=s 4420 | _Gui.Hide() 4421 | return 4422 | Case "SavePic2": 4423 | x:=nX+CutLeft, w:=nW-CutLeft-CutRight 4424 | y:=nY+CutUp, h:=nH-CutUp-CutDown 4425 | G_.Call("ScreenShot", x "|" y "|" (x+w-1) "|" (y+h-1) "|0") 4426 | return 4427 | Case "ShowPic": 4428 | ControlGet, i, CurrentLine,,, ahk_id %hscr% 4429 | ControlGet, s, Line, %i%,, ahk_id %hscr% 4430 | FindText_Main["MyPic"].Value:=Trim(this.ASCII(s),"`n") 4431 | return 4432 | Case "KeyDown": 4433 | Critical 4434 | _Gui:=FindText_Main 4435 | if (WinExist()!=_Gui.Hwnd) 4436 | return 4437 | Try ctrl:="", ctrl:=args[3] 4438 | if (ctrl=hscr) 4439 | SetTimer % G_ShowPic, -150 4440 | else if (ctrl=_Gui["ClipText"].Hwnd) 4441 | { 4442 | s:=_Gui["ClipText"].Value 4443 | _Gui["MyPic"].Value:=Trim(this.ASCII(s),"`n") 4444 | } 4445 | return 4446 | Case "LButtonDown": 4447 | Critical 4448 | if (WinExist()!=FindText_Capture.Hwnd) 4449 | return G_.Call("KeyDown", arg1, args*) 4450 | CoordMode, Mouse 4451 | MouseGetPos, k1, k2,, k6, 2 4452 | if (k6=hPic) 4453 | { 4454 | ListLines % (lls:=A_ListLines)?0:0 4455 | Loop 4456 | { 4457 | Sleep 50 4458 | MouseGetPos, k3, k4 4459 | this.RangeTip(Min(k1,k3), Min(k2,k4) 4460 | , Abs(k1-k3)+1, Abs(k2-k4)+1, (A_MSec<500 ? "Red":"Blue")) 4461 | } 4462 | Until !this.State("LButton") 4463 | ListLines % lls 4464 | this.RangeTip() 4465 | this.GetBitsFromScreen(,,,,0,zx,zy) 4466 | this.ClientToScreen(sx, sy, 0, 0, hPic) 4467 | sx:=Min(k1,k3)-sx+hBM_x+zx, sy:=Min(k2,k4)-sy+hBM_y+zy 4468 | , sw:=Abs(k1-k3)+1, sh:=Abs(k2-k4)+1 4469 | if (sw+sh)<5 4470 | sx-=71//2, sy-=25//2, sw:=71, sh:=25 4471 | G_.Call("CaptureUpdate") 4472 | FindText_Capture["MyTab1"].Choose(1) 4473 | return 4474 | } 4475 | if !(Cid_.HasKey(k6) && k5:=Cid_[k6]) 4476 | return 4477 | if (k5=-1) 4478 | { 4479 | MouseMove, k1+2, k2+2, 0 4480 | MouseGetPos,,,, k6, 2 4481 | MouseMove, k1, k2, 0 4482 | if !(Cid_.HasKey(k6) && k5:=Cid_[k6]) || (k5=-1) 4483 | return 4484 | } 4485 | if (k5>71*25) 4486 | { 4487 | k1:=nW*nH+dx+(k5-71*25) 4488 | this.SC(((show[k1]:=!show[k1])?0xFF0000:0xFFFFAA), k6) 4489 | return 4490 | } 4491 | k3:=Mod(k5-1,71)+dx, k4:=(k5-1)//71+dy 4492 | if (k3>=nW || k4>=nH) 4493 | return 4494 | k1:=k4*nW+k3+1 4495 | if (Modify && bg!="" && show[k1]) 4496 | this.SC(((ascii[k1]:=!ascii[k1])?0:0xFFFFFF), k6) 4497 | else 4498 | { 4499 | k2:=cors[k1], SelPos:=k1 4500 | _Gui:=FindText_Capture 4501 | _Gui["SelGray"].Value:=(((k2>>16)&0xFF)*38+((k2>>8)&0xFF)*75+(k2&0xFF)*15)>>7 4502 | _Gui["SelColor"].Value:=Format("0x{:06X}",k2&0xFFFFFF) 4503 | _Gui["SelR"].Value:=(k2>>16)&0xFF 4504 | _Gui["SelG"].Value:=(k2>>8)&0xFF 4505 | _Gui["SelB"].Value:=k2&0xFF 4506 | } 4507 | if (MultiColor && show[k1]) 4508 | { 4509 | (FindShape && Result="") && G_.Call("ColorPos2Two") 4510 | k2:=Format(",{:d}/{:d}/{:06X}", nX+k3, nY+k4, cors[k1]&0xFFFFFF) 4511 | , Result.=InStr(Result,k2) ? "":k2 4512 | ToolTip % Trim(Result, ",") 4513 | } 4514 | return 4515 | Case "RButtonDown": 4516 | Critical 4517 | MouseGetPos,,,, k2, 2 4518 | if (k2!=hPic) 4519 | return 4520 | CoordMode, Mouse 4521 | MouseGetPos, k1, k2 4522 | k5:=hBM_x, k6:=hBM_y 4523 | ListLines % (lls:=A_ListLines)?0:0 4524 | Loop 4525 | { 4526 | Sleep 10 4527 | MouseGetPos, k3, k4 4528 | hBM_x:=k5+k1-k3, hBM_y:=k6+k2-k4 4529 | G_.Call("PicShow") 4530 | } 4531 | Until !this.State("RButton") 4532 | ListLines % lls 4533 | return 4534 | Case "MouseMove": 4535 | Try ctrl_name:="", ctrl_name:=this.GuiCtrlFromHwnd(args[3]).Name 4536 | if (PrevControl != ctrl_name) 4537 | { 4538 | ToolTip 4539 | PrevControl:=ctrl_name 4540 | Try SetTimer % G_ToolTip, % (PrevControl ? -500:"Off") 4541 | Try SetTimer % G_ToolTipOff, % (PrevControl ? -5500:"Off") 4542 | } 4543 | return 4544 | Case "ToolTip": 4545 | MouseGetPos,,, _TT 4546 | if WinExist("ahk_id " _TT " ahk_class AutoHotkeyGUI") 4547 | Try ToolTip % Tip_Text[PrevControl] 4548 | return 4549 | Case "ToolTipOff": 4550 | ToolTip 4551 | return 4552 | Case "CutL2", "CutR2", "CutU2", "CutD2": 4553 | s:=FindText_Main["MyPic"].Value 4554 | s:=Trim(s,"`n") . "`n", v:=SubStr(cmd,4,1) 4555 | if (v="U") 4556 | s:=RegExReplace(s,"^[^\n]+\n") 4557 | else if (v="D") 4558 | s:=RegExReplace(s,"[^\n]+\n$") 4559 | else if (v="L") 4560 | s:=RegExReplace(s,"m`n)^[^\n]") 4561 | else if (v="R") 4562 | s:=RegExReplace(s,"m`n)[^\n]$") 4563 | FindText_Main["MyPic"].Value:=Trim(s,"`n") 4564 | return 4565 | Case "Update": 4566 | ControlFocus,, % "ahk_id " hscr 4567 | ControlGet, i, CurrentLine,,, ahk_id %hscr% 4568 | ControlGet, s, Line, %i%,, ahk_id %hscr% 4569 | if !RegExMatch(s, "O)(<[^>\n]*>[^$\n]+\$)\d+\.[\w+/]+", r) 4570 | return 4571 | v:=FindText_Main["MyPic"].Value 4572 | v:=Trim(v,"`n") . "`n", w:=Format("{:d}",InStr(v,"`n")-1) 4573 | v:=StrReplace(StrReplace(v,"0","1"),"_","0") 4574 | s:=StrReplace(s, r[0], r[1] . w "." this.bit2base64(v)) 4575 | v:="{End}{Shift Down}{Home}{Shift Up}{Del}" 4576 | ControlSend,, %v%, ahk_id %hscr% 4577 | Control, EditPaste, %s%,, ahk_id %hscr% 4578 | ControlSend,, {Home}, ahk_id %hscr% 4579 | return 4580 | } 4581 | } 4582 | 4583 | Lang(text:="", getLang:=0) 4584 | { 4585 | local 4586 | static init, Lang1, Lang2 4587 | if !VarSetCapacity(init) && (init:="1") 4588 | { 4589 | s:=" 4590 | ( 4591 | Myww = Width = Adjust the width of the capture range 4592 | Myhh = Height = Adjust the height of the capture range 4593 | AddFunc = Add = Additional FindText() in Copy 4594 | NowHotkey = Hotkey = Current screenshot hotkey 4595 | SetHotkey1 = = First sequence Screenshot hotkey 4596 | SetHotkey2 = = Second sequence Screenshot hotkey 4597 | Apply = Apply = Apply new screenshot hotkey 4598 | CutU2 = CutU = Cut the Upper Edge of the text in the edit box below 4599 | CutL2 = CutL = Cut the Left Edge of the text in the edit box below 4600 | CutR2 = CutR = Cut the Right Edge of the text in the edit box below 4601 | CutD2 = CutD = Cut the Lower Edge of the text in the edit box below 4602 | Update = Update = Update the text in the edit box below to the line of Code 4603 | GetRange = GetRange = Get screen range to Clipboard and update the search range of the Code 4604 | GetOffset = GetOffset = Get position offset relative to the Text from the Code and update FindText().Click() 4605 | GetClipOffset = GetOffset2 = Get position offset relative to the Text from the Left Box 4606 | Capture = Capture = Initiate Image Capture Sequence 4607 | CaptureS = CaptureS = Restore the Saved ScreenShot by Hotkey and then start capturing 4608 | Test = Test = Test the Text from the Code to see if it can be found on the screen 4609 | TestClip = Test2 = Test the Text from the Left Box and copy the result to Clipboard 4610 | Paste = Paste = Paste the Text from Clipboard to the Left Box 4611 | CopyOffset = Copy2 = Copy the Offset to Clipboard 4612 | Copy = Copy = Copy the selected or all of the code to the clipboard 4613 | Reset = Reset = Reset to Original Captured Image 4614 | SplitAdd = SplitAdd = Using Markup Segmentation to Generate Text Library 4615 | AllAdd = AllAdd = Append Another FindText Search Text into Previously Generated Code 4616 | Gray2Two = Gray2Two = Converts Image Pixels from Gray Threshold to Black or White 4617 | GrayDiff2Two = GrayDiff2Two = Converts Image Pixels from Gray Difference to Black or White 4618 | Color2Two = Color2Two = Converts Image Pixels from Color List to Black or White 4619 | ColorPos2Two = ColorPos2Two = Converts Image Pixels from Color Position to Black or White 4620 | SelGray = Gray = Gray value of the selected color 4621 | SelColor = Color = The selected color 4622 | SelR = R = Red component of the selected color 4623 | SelG = G = Green component of the selected color 4624 | SelB = B = Blue component of the selected color 4625 | RepU = -U = Undo Cut the Upper Edge by 1 4626 | CutU = U = Cut the Upper Edge by 1 4627 | CutU3 = U3 = Cut the Upper Edge by 3 4628 | RepL = -L = Undo Cut the Left Edge by 1 4629 | CutL = L = Cut the Left Edge by 1 4630 | CutL3 = L3 = Cut the Left Edge by 3 4631 | Auto = Auto = Automatic Cut Edge after image has been converted to black and white 4632 | RepR = -R = Undo Cut the Right Edge by 1 4633 | CutR = R = Cut the Right Edge by 1 4634 | CutR3 = R3 = Cut the Right Edge by 3 4635 | RepD = -D = Undo Cut the Lower Edge by 1 4636 | CutD = D = Cut the Lower Edge by 1 4637 | CutD3 = D3 = Cut the Lower Edge by 3 4638 | Modify = Modify = Allows Modify the Black and White Image 4639 | MultiColor = FindMultiColor = Click multiple colors with the mouse, then Click OK button 4640 | FindShape = FindShape = Click multiple colors, it will be binarized based on the first color 4641 | Undo = Undo = Undo the last selected color 4642 | Undo2 = Undo = Undo the last added color in Color List 4643 | Comment = Comment = Optional Comment used to Label Code ( Within <> ) 4644 | Threshold = Gray Threshold = Gray Threshold which Determines Black or White Pixel Conversion (0-255) 4645 | GrayDiff = Gray Difference = Gray Difference which Determines Black or White Pixel Conversion (0-255) 4646 | Similar1 = Similarity = Adjust color similarity as Equivalent to The Selected Color 4647 | Similar2 = Similarity = Adjust color similarity as Equivalent to The Selected Color 4648 | Similar3 = Similarity = Adjust color similarity as Equivalent to The Selected Color 4649 | AddColorSim = Add = Add Color to Color List and Run Color2Two 4650 | AddColorDiff = Add = Add Color to Color List and Run Color2Two 4651 | ColorList = = Color list for converting black and white images 4652 | DiffRGB = R/G/B = Determine the allowed R/G/B Error (0-255) when Find MultiColor 4653 | DiffRGB2 = R/G/B = Determine the allowed R/G/B Error (0-255) 4654 | Bind0 = BindWin1 = Bind the window and Use GetDCEx() to get the image of background window 4655 | Bind1 = BindWin1+ = Bind the window Use GetDCEx() and Modify the window to support transparency 4656 | Bind2 = BindWin2 = Bind the window and Use PrintWindow() to get the image of background window 4657 | Bind3 = BindWin2+ = Bind the window Use PrintWindow() and Modify the window to support transparency 4658 | Bind4 = BindWin3 = Bind the window and Use PrintWindow(,,3) to get the image of background window 4659 | OK = OK = Create New FindText Code for Testing 4660 | OK2 = OK = Restore this ScreenShot then Capturing 4661 | Cancel = Cancel = Close the Window Don't Do Anything 4662 | Cancel2 = Cancel = Close the Window Don't Do Anything 4663 | ClearAll = ClearAll = Clean up all saved ScreenShots 4664 | OpenDir = OpenDir = Open the saved screenshots directory 4665 | SavePic = SavePic = Select a range and save as a picture 4666 | SavePic2 = SavePic = Save the trimmed original image as a picture 4667 | LoadPic = LoadPic = Load a picture as Capture image 4668 | ClipText = = Displays the Text data from clipboard 4669 | Offset = = Displays the results of GetOffset2 or GetRange 4670 | SelectBox = = Select a screenshot to display in the upper left corner of the screen 4671 | s1 = FindText 4672 | s2 = Gray|GrayDiff|Color|ColorPos|MultiColor 4673 | s3 = Capture Image To Text 4674 | s4 = Capture Image To Text and Find Text Tool 4675 | s5 = Direction keys to fine tune\nFirst click RButton(or Ctrl)\nMove the mouse away\nSecond click RButton(or Ctrl) 4676 | s6 = Unbind Window using 4677 | s7 = Drag a range with LButton(or Ctrl)\nCoordinates are copied to clipboard 4678 | s8 = Found|Time|ms|Pos|Result|value can be get from|Wait 3 seconds for appear|Wait indefinitely for disappear 4679 | s9 = Success 4680 | s10 = The Capture Position|Perspective binding window\nRight click to finish capture 4681 | s11 = Please Set Gray Difference First ! 4682 | s12 = Please select the core color first ! 4683 | s13 = Please convert the image to black or white first ! 4684 | s14 = Can't be used in ColorPos mode, because it can cause position errors 4685 | s15 = Are you sure about the scope of your choice ?\n\nIf not, you can choose again 4686 | s16 = Please add colors to the color list first ! 4687 | s17 = The picture you want to open was not found ! 4688 | s18 = Capture|ScreenShot 4689 | s19 = Are you sure to delete all screenshots ? 4690 | )" 4691 | Lang1:=[], Lang2:=[] 4692 | Loop Parse, s, `n, `r 4693 | if InStr(v:=A_LoopField, "=") 4694 | r:=StrSplit(StrReplace(v "==","\n","`n"), "=", "`t ") 4695 | , Lang1[r[1]]:=r[2], Lang2[r[1]]:=r[3] 4696 | } 4697 | return getLang=1 ? Lang1 : getLang=2 ? Lang2 : Lang1[text] 4698 | } 4699 | 4700 | ;--------------------------------- 4701 | ; Gui-V1-V2 Compatibility Library By FeiYue 4702 | ;--------------------------------- 4703 | 4704 | GuiNew(args*) { 4705 | return new this.GuiCreate(args*) 4706 | } 4707 | 4708 | GuiFromHwnd(hwnd:="AllGuiObj", RecurseParent:=0) { 4709 | static init, AllGuiObj 4710 | if !VarSetCapacity(init) && (init:="1") 4711 | AllGuiObj:=[] 4712 | if (hwnd=="AllGuiObj") 4713 | return AllGuiObj 4714 | if (RecurseParent) 4715 | While hwnd && !AllGuiObj.HasKey(hwnd) 4716 | hwnd:=DllCall("GetParent", "Ptr",hwnd, "Ptr") 4717 | return AllGuiObj[hwnd] 4718 | } 4719 | 4720 | GuiCtrlFromHwnd(hwnd) { 4721 | return this.GuiFromHwnd(hwnd,1)[hwnd] 4722 | } 4723 | 4724 | GuiOnEvent(EventName, args*) { 4725 | return this.GuiFromHwnd(WinExist())["_" EventName].Call(0,args*) 4726 | } 4727 | 4728 | GuiClose(args*) { 4729 | return FindText().GuiOnEvent("Close",args*) 4730 | } 4731 | 4732 | GuiEscape(args*) { 4733 | return FindText().GuiOnEvent("Escape",args*) 4734 | } 4735 | 4736 | GuiSize(args*) { 4737 | return FindText().GuiOnEvent("Size",args*) 4738 | } 4739 | 4740 | GuiContextMenu(args*) { 4741 | return FindText().GuiOnEvent("ContextMenu",args*) 4742 | } 4743 | 4744 | GuiDropFiles(args*) { 4745 | return FindText().GuiOnEvent("DropFiles",0,args*) 4746 | } 4747 | 4748 | Class GuiCreate 4749 | { ;// GuiCreate Class Begin 4750 | 4751 | __New(opts:="", title:="", args*) { 4752 | local 4753 | Gui, New, % opts " +Hwndhwnd +LabelFindTextClass.Gui", % title 4754 | this.Hwnd:=hwnd, this.ClassNN:=[] 4755 | FindText().GuiFromHwnd()[hwnd]:=this 4756 | } 4757 | 4758 | __Delete() { 4759 | this.Destroy() 4760 | } 4761 | 4762 | Destroy() { 4763 | local 4764 | if !(hwnd:=this.Hwnd) 4765 | return 4766 | this.Hwnd:="", FindText().GuiFromHwnd().Delete(hwnd) 4767 | Try Gui, % hwnd ":Destroy" 4768 | For k,v in this 4769 | (v.Hwnd && v.Hwnd:=""), this[k]:="" 4770 | } 4771 | 4772 | OnEvent(EventName, Callback, AddRemove:=1) { 4773 | if IsObject(Callback) 4774 | this["_" EventName]:=Callback 4775 | } 4776 | 4777 | Opt(opts) { 4778 | Gui, % this.Hwnd ":" RegExReplace(opts,"i)[+\-\s]Label\S*") 4779 | } 4780 | 4781 | Add(type, opts:="", text:="") { 4782 | local 4783 | static init, type2class 4784 | if !VarSetCapacity(init) && (init:="1") 4785 | type2class:=[] 4786 | type:=(type="DropDownList"?"DDL":type="Picture"?"Pic":type) 4787 | name:=RegExMatch(opts,"i)(^|[+\-\s])V(?!Scroll\b|ertical\b)\K\S*",r)?r:"" 4788 | opts:=RegExReplace(opts,"i)(^|[+\-\s])V(?!Scroll\b|ertical\b)\S*") 4789 | if IsObject(text) 4790 | { 4791 | s:="" 4792 | For k,v in text 4793 | s.="|" v 4794 | text:=Trim(s, "|") 4795 | } 4796 | Gui, % this.Hwnd ":Add", % type, % opts " +Hwndhwnd", % text 4797 | this.LastHwnd:=hwnd 4798 | if type2class.HasKey(type) 4799 | s:=type2class[type] 4800 | else 4801 | { 4802 | WinGetClass, s, ahk_id %hwnd% 4803 | type2class[type]:=s 4804 | } 4805 | this.ClassNN[s]:=n:=Floor(this.ClassNN[s])+1, classnn:=s . n 4806 | obj:= new this.Control(this.Hwnd, hwnd, type, classnn, name) 4807 | this[hwnd]:=obj, this[classnn]:=obj 4808 | if (name) && !(name~="i)^(Destroy|OnEvent|Opt|Add" 4809 | . "|SetFont|Show|Hide|Move|GetClientPos|GetPos|Maximize" 4810 | . "|Minimize|Restore|Flash|Submit|Hwnd|Name|Title" 4811 | . "|BackColor|MarginX|MarginY|MenuBar|FocusedCtrl)$") 4812 | this[name]:=obj 4813 | return obj 4814 | } 4815 | 4816 | SetFont(opts:="", FontName:="") { 4817 | Gui, % this.Hwnd ":Font", % opts, % FontName 4818 | } 4819 | 4820 | Show(opts:="", args*) { 4821 | Gui, % this.Hwnd ":Show", % opts 4822 | } 4823 | 4824 | Hide() { 4825 | Gui, % this.Hwnd ":Hide" 4826 | } 4827 | 4828 | Move(x:="", y:="", w:="", h:="") { 4829 | local 4830 | this.GetPos(pX, pY, pW, pH) 4831 | x:=(x=""?pX:x), y:=(y=""?pY:y), w:=(w=""?pW:w), h:=(h=""?pH:h) 4832 | DllCall("MoveWindow", "Ptr",this.Hwnd, "int",x, "int",y, "int",w, "int",h, "int",1) 4833 | } 4834 | 4835 | GetClientPos(ByRef x:="", ByRef y:="", ByRef w:="", ByRef h:="") { 4836 | local 4837 | VarSetCapacity(rect, 16, 0) 4838 | , DllCall("GetClientRect", "Ptr",this.Hwnd, "Ptr",&rect) 4839 | , DllCall("ClientToScreen", "Ptr",this.Hwnd, "Ptr",&rect) 4840 | , x:=NumGet(rect, 0, "int"), y:=NumGet(rect, 4, "int") 4841 | , w:=NumGet(rect, 8, "int")-x, h:=NumGet(rect, 12, "int")-y 4842 | } 4843 | 4844 | GetPos(ByRef x:="", ByRef y:="", ByRef w:="", ByRef h:="") { 4845 | local 4846 | VarSetCapacity(rect, 16, 0) 4847 | , DllCall("GetWindowRect", "Ptr",this.Hwnd, "Ptr",&rect) 4848 | , x:=NumGet(rect, 0, "int"), y:=NumGet(rect, 4, "int") 4849 | , w:=NumGet(rect, 8, "int")-x, h:=NumGet(rect, 12, "int")-y 4850 | } 4851 | 4852 | Maximize() { 4853 | Gui, % this.Hwnd ":Maximize" 4854 | } 4855 | 4856 | Minimize() { 4857 | Gui, % this.Hwnd ":Minimize" 4858 | } 4859 | 4860 | Restore() { 4861 | Gui, % this.Hwnd ":Restore" 4862 | } 4863 | 4864 | Flash(k:=1) { 4865 | Gui, % this.Hwnd ":Flash", % k ? "":"Off" 4866 | } 4867 | 4868 | Submit(hide:=1) { 4869 | local 4870 | (hide && this.Hide()), arr:=[] 4871 | For k,v in this 4872 | if k is number 4873 | if (v.Name!="") 4874 | arr[v.Name]:=v.Value 4875 | return arr 4876 | } 4877 | 4878 | BackColor { 4879 | get { 4880 | return this._BackColor 4881 | } 4882 | set { 4883 | this._BackColor:=value 4884 | Gui, % this.Hwnd ":Color", % value 4885 | return value 4886 | } 4887 | } 4888 | 4889 | MarginX { 4890 | get { 4891 | return this._MarginX 4892 | } 4893 | set { 4894 | this._MarginX:=value 4895 | Gui, % this.Hwnd ":Margin", % value 4896 | return value 4897 | } 4898 | } 4899 | 4900 | MarginY { 4901 | get { 4902 | return this._MarginY 4903 | } 4904 | set { 4905 | this._MarginY:=value 4906 | Gui, % this.Hwnd ":Margin",, % value 4907 | return value 4908 | } 4909 | } 4910 | 4911 | MenuBar { 4912 | get { 4913 | return this._MenuBar 4914 | } 4915 | set { 4916 | this._MenuBar:=value 4917 | Gui, % this.Hwnd ":Menu", % value 4918 | return value 4919 | } 4920 | } 4921 | 4922 | Title { 4923 | get { 4924 | local 4925 | VarSetCapacity(v, 260*2) 4926 | DllCall("GetWindowText", "Ptr",this.Hwnd, "Str",v, "Int",260) 4927 | return v 4928 | } 4929 | set { 4930 | DllCall("SetWindowText", "Ptr",this.Hwnd, "Str",value) 4931 | return value 4932 | } 4933 | } 4934 | 4935 | FocusedCtrl { 4936 | get { 4937 | local 4938 | GuiControlGet, v, % this.Hwnd ":Focus" 4939 | return this[v] 4940 | } 4941 | } 4942 | 4943 | Class Control 4944 | { ;// Control Class Begin 4945 | 4946 | __New(GuiHwnd, hwnd, type, classnn, name) { 4947 | this.GuiHwnd:=GuiHwnd, this.Hwnd:=hwnd 4948 | this.Type:=type, this.ClassNN:=classnn, this.Name:=name 4949 | } 4950 | 4951 | Opt(opts) { 4952 | GuiControl, % opts, % this.Hwnd 4953 | } 4954 | 4955 | OnEvent(EventName, Callback, AddRemove:=1) { 4956 | local 4957 | r:=this.OnEvent_G.Bind(this, Callback) 4958 | GuiControl, +g, % this.Hwnd, % r 4959 | } 4960 | 4961 | OnEvent_G(Callback, args*) { 4962 | if IsObject(Callback) 4963 | return %Callback%(this, args*) 4964 | } 4965 | 4966 | GetPos(ByRef x:="", ByRef y:="", ByRef w:="", ByRef h:="") { 4967 | local 4968 | GuiControlGet, p, Pos, % this.Hwnd 4969 | x:=Floor(pX), y:=Floor(pY), w:=Floor(pW), h:=Floor(pH) 4970 | } 4971 | 4972 | Move(x:="", y:="", w:="", h:="") { 4973 | local 4974 | s:=(x=""?"":" x" x) (y=""?"":" y" y) (w=""?"":" w" w) (h=""?"":" h" h) 4975 | GuiControl, Move, % this.Hwnd, % s 4976 | } 4977 | 4978 | Redraw() { 4979 | GuiControl, MoveDraw, % this.Hwnd 4980 | } 4981 | 4982 | Focus() { 4983 | Try GuiControl, Focus, % this.Hwnd 4984 | } 4985 | 4986 | UseTab(Name:="", Exact:="", index:="") { 4987 | Gui, % this.GuiHwnd ":Tab", % Name, % index, % Exact?"Exact":"" 4988 | } 4989 | 4990 | SetFont(opts:="", FontName:="") { 4991 | Gui, % this.GuiHwnd ":Font", % opts, % FontName 4992 | GuiControl, Font, % this.Hwnd 4993 | } 4994 | 4995 | Add(text) { 4996 | local 4997 | if IsObject(text) 4998 | { 4999 | s:="" 5000 | For k,v in text 5001 | s.="|" v 5002 | text:=Trim(s, "|") 5003 | } 5004 | GuiControl,, % this.Hwnd, % text 5005 | } 5006 | 5007 | Delete(N:="") { 5008 | if (N="") 5009 | GuiControl,, % this.Hwnd, | 5010 | else 5011 | this.Choose(N), this.Choose(0) 5012 | } 5013 | 5014 | Choose(N) { 5015 | if N is number 5016 | GuiControl, Choose, % this.Hwnd, % N 5017 | else 5018 | GuiControl, ChooseString, % this.Hwnd, % N 5019 | } 5020 | 5021 | Gui { 5022 | get { 5023 | return FindText().GuiFromHwnd(this.GuiHwnd) 5024 | } 5025 | } 5026 | 5027 | Enabled { 5028 | get { 5029 | local 5030 | GuiControlGet, v, Enabled, % this.Hwnd 5031 | return v 5032 | } 5033 | set { 5034 | GuiControl, % "Enable" (!!value), % this.Hwnd 5035 | return value 5036 | } 5037 | } 5038 | 5039 | Visible { 5040 | get { 5041 | local 5042 | GuiControlGet, v, Visible, % this.Hwnd 5043 | return v 5044 | } 5045 | set { 5046 | GuiControl, % "Show" (!!value), % this.Hwnd 5047 | return value 5048 | } 5049 | } 5050 | 5051 | Focused { 5052 | get { 5053 | local 5054 | GuiControlGet, v, % this.GuiHwnd ":Focus" 5055 | return (v=this.ClassNN) 5056 | } 5057 | } 5058 | 5059 | Value { 5060 | get { 5061 | local 5062 | if (this.Type~="i)^(ListBox|DDL|ComboBox|Tab)$") 5063 | this.Opt("+AltSubmit") 5064 | GuiControlGet, v,, % this.Hwnd 5065 | return v 5066 | } 5067 | set { 5068 | if (this.Type~="i)^(ListBox|DDL|ComboBox|Tab)$") 5069 | GuiControl, Choose, % this.Hwnd, % value 5070 | else 5071 | GuiControl,, % this.Hwnd, % value 5072 | return value 5073 | } 5074 | } 5075 | 5076 | Text { 5077 | get { 5078 | local 5079 | if (this.Type~="i)^(ListBox|DDL|ComboBox|Tab)$") 5080 | this.Opt("-AltSubmit") 5081 | GuiControlGet, v,, % this.Hwnd 5082 | return v 5083 | } 5084 | set { 5085 | if (this.Type~="i)^(ListBox|DDL|ComboBox|Tab)$") 5086 | GuiControl, ChooseString, % this.Hwnd, % value 5087 | else 5088 | GuiControl,, % this.Hwnd, % value 5089 | return value 5090 | } 5091 | } 5092 | 5093 | } ;// Control Class End 5094 | 5095 | } ;// GuiCreate Class End 5096 | 5097 | Script_End() { 5098 | } 5099 | 5100 | } 5101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 免责声明: 3 | 4 | 这是ahk按键脚本,而不是外挂,没有注入和修改数据,只是模拟键盘鼠标,所以说不会被封。目前脚本发布至今没有因使用脚本被封号的案例,但仍有风险,勇士对按键脚本的态度可能改变,所以如果造成封号或其他问题,本工具作者不承担任何责任。 5 | 6 | --- 7 | 8 | [视频教程](https://www.bilibili.com/video/BV1ZxxmeDEdn/) 9 | 10 | 11 | 12 | 1.请确保游戏分辨率设置为1280x720 13 | 14 | 2.自定义战斗界面如果有自定义,使用脚本时请还原为默认(部分角色自动战斗需要识别按键状态来出招,改变按键位置会导致出招异常。游戏中有4个按键布局预设) 15 | 16 | 3.初次使用请在托盘图标右键→快捷键设置:设置快捷键与你游戏内快捷键对应。默认状态下与游戏默认按键相同,如果没改过默认按键可跳过这步。 17 | 18 | 4.多维刷分要求解锁20难度,解锁角色真红,解锁信标:赏金猎人、孤狼之道、残酷天平。(考虑到大部分玩家都已解锁,增加这些设置能让刷分速度大幅提高。) 19 | 20 | 5.多维如果运行不正确,退出深空之眼脚本,用管理员权限试半识别模式.exe,若仍不能正常运行,试用不识别模式.exe(不识别模式只模拟点击和延时,战斗固定设置1分钟,所以战斗完会卡在选择珍宝画面不动一会儿请耐心等待。)。 21 | 22 | 如果以上操作多维仍不可以正常刷分,尝试在windows显示设置中将缩放调整到100%,再行尝试。或将游戏画面设置调整为:帧数60,阴影等级高,后处理高,抗锯齿开,垂直同步开,超分辨率1.0 23 | 24 | --- 25 | 默认设置:可在托盘菜单自行更改键位 26 | 27 | 小键盘1:金乌自动出招 28 | 29 | 小键盘2:多维变量自动刷分 30 | 31 | 小键盘3:陵光自动出招 32 | 33 | 小键盘4:托特/哈迪斯/雷前鬼/水姆自动出招 34 | 35 | 小键盘5:娜美自动出招 36 | 37 | 小键盘6:薇儿/光赫拉/瓦吉特自动出招(薇儿的自动战斗适用于潜质觉醒中所有薇儿变体的自动战斗,包括神能训练,意志训练,技巧训练,侵蚀抵抗)。 38 | 39 | 小键盘7:闲暇时刻自动烤肉 40 | 41 | 小键盘9:简易按键连点器(右ctrl+任意键=连点该键) 42 | 43 | Ctrl+小键盘1:梵天自动出招,注意:队友帕尔瓦蒂必须放2号位(最左边),且不安装惊澜芯片,否则会扰乱输出循环 44 | 45 | Ctrl+小键盘2:诗寇蒂自动出招 46 | 47 | 小键盘0:停止运行中的操作 48 | 49 | 自动刷熟练度:点开游戏键位设置,将继续挑战快捷键设置为j键,选择历战回响第一关,从第一层开始按6自动刷角色熟练度。 50 | --------------------------------------------------------------------------------