; 每隔10分钟定时全自动单击阿_里_云_盘全部开始下载按钮的AHK脚本程序文件_快捷键Ctrl+F8_2024年5月29日 ; 用法:运行阿里云盘并添加好文件夹下载传输任务之后运行此AutoHotkey脚本并同时按下两个快捷键热键 <Ctrl> 和 <F8>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 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 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 | ; 每隔10分钟定时全自动单击阿_里_云_盘全部开始下载按钮的AHK脚本程序文件_快捷键Ctrl+F8_2024年5月29日 ; 2024年5月29日 18:29:23第1次审阅修订 -- aahk -- 测试通过热键重启下载和定时重启下载,防止下载任务的速度减慢或卡死 ; 2024年6月2日 18:46:45第2次审阅修订 -- aahk -- 增添“TrayIcon_Clean() 批量清理系统托盘上残留的多余的图标”功能 ; 用法:运行阿里云盘并添加好文件夹下载传输任务之后运行此AutoHotkey脚本并同时按下两个快捷键热键 <Ctrl> 和 <F8> ; SetTimer版 ; 推荐使用SetTimer , 尽量少用或不用 loop ; 用FeiYue制作的FindText屏幕抓字生成字库工具与找字函数最新版本9.5来编写一个阿里云盘下载速度保持脚本2024年5月22日 ; 注意:抓图测试失败时可以尝试使用FindText的“截屏抓图”功能 ; 也可以根据此脚本仿制迅雷BT磁力百度网盘OneDrive天翼云盘115网盘的下载速度保持脚本 ; 假如每日资源数据文件下载量没有达标时请检查并调整 Windows Server 2022 服务器 的硬件配置和系统软件设置环境 ; 注意:尽量在 Windows Server 2022 服务器 对应的硬件平台和系统软件平台中运行此脚本和阿里云盘迅雷BT磁力百度网盘OneDrive天翼云盘115网盘下载软件 ; 因为 Windows Server 2022 服务器 更稳定可靠,不易宕机死机卡死,从而确保此脚本守护下的下载软件能够 7 X 24小时 全天候 不间断的高速下载文件资料 ; 在 https: //www.autoahk.com/ AHK精品社区网站搜索关键字“FindText”可以找到屏幕找字函数用法的帮助教程学习资料 ; 在哔哩哔哩手机APP搜索并且筛选关键字“FindText”可以找到屏幕找字函数用法的帮助视频教程学习资料 ; ========== 一些 AutoHotkey 相关的网址链接 ========== ; AHK官网 : https: //www.autohotkey.com/ ; AHK官方中文子论坛:http: //ahkscript.org/boards/viewforum.php?f=26 ; AHK精品社区 AutoAHK : https: //www.autoahk.com/ ; AHK中文化项目 : https: //sourceforge.net/projects/ahkcn/ ; AutoHotkey从入门到精通(V1&V2) – AutoAHK : https: //www.autoahk.com/archives/9458 ; AutoHotKey下载、安装及环境配置 : https: //www.autoahk.com/archives/15416 ; AHK中文帮助文档 : https: //www.autoahk.com/archives/2499 ; SciTE4AutoHotkey-Plus 最适合中文与新人用户的 AHK IDE : Github 实时更新 https: //github.com/telppa/SciTE4AutoHotkey-Plus/archive/refs/heads/master.zip ; SciTE4AutoHotkey-Plus 最适合中文与新人用户的 AHK IDE : Github (累积更新) https: //github.com/telppa/SciTE4AutoHotkey-Plus/releases "Releases" ; SciTE4AutoHotkey-Plus 最适合中文与新人用户的 AHK IDE : 蓝奏云 (累积更新) https: //ahk.lanzouy.com/i5g931cfodgh "蓝奏云" ; Adventure-CN AHK中文开发环境 : https: //www.autoahk.com/archives/15290 ; 【函数】FindText中文版- 屏幕抓字生成字库工具与找字函数 : https: //www.autoahk.com/archives/28493 ; FindText 深度教程 v1.2? : https: //www.autoahk.com/archives/41636 ; FindText函数实战课程:找图神器亮剑 – AutoAHK : https: //www.autoahk.com/archives/39249 ; 【函数】FindText 中文版 V2 版本 – AutoAHK : https: //www.autoahk.com/archives/44766 ; 屏幕缩放、DPI 和使脚本在不同的计算机中工作 – AutoAHK : https: //www.autoahk.com/archives/48461 ; 定时重启阿里云盘下载任务 : https: //www.autoahk.com/archives/48998 ; 定时重启阿里云盘下载任务备份副本 : https: //www.cnblogs.com/delphixx/p/18205801 ; AutoHotkey V2极速入门 自动化脚本神器_哔哩哔哩_bilibili : https: //www.bilibili.com/video/BV1x2421w7Fd/ ; Autohotkey三分钟极速入门教程,提升效率神器脚本_哔哩哔哩_bilibili : https: //www.bilibili.com/video/BV1tK411T7kY/ ; AutoHotkey 以一当百,让你的电脑好用1400%_哔哩哔哩_bilibili : https: //www.bilibili.com/video/BV1Tz4y1Z7tj/ ; ============================================================ #SingleInstance force #Persistent #WinActivateForce DetectHiddenWindows,On SetTitleMatchMode,2 ; #Include <FindText> ; 自定义快捷键 Ctrl + F9 ,用于立即测试脚本全屏找字和点击按钮是否有效 ; ^F9::clickali() ; SetHotkey1, Sleep,234 Hotkey,^F8,clickali ; SetTimer 每隔10分钟,让软件下载一会儿资源数据文件 ; 10分钟*60秒/分钟*1000毫秒/秒=600000 Sleep,234 SetTimer,clickali,600000 return clickali() { ; 关闭并重新启动阿里云盘,防止程序长期下载后下载速度减慢,卡死 ; 关闭阿里云盘窗口并终止阿里云盘程序进程 ; 为了防止此脚本被此脚本中的WinClose代码错误的关闭,所以此处关闭窗口不用窗口标题 ; WinClose, 阿里云盘 ; Sleep,500 ; WinClose, ahk_class Chrome_WidgetWin_1 WinClose, 阿里云盘 ahk_class Chrome_WidgetWin_1 ahk_exe aDrive.exe Sleep,234 ; 关闭阿里云盘窗口并终止阿里云盘程序进程 ; WinKill, 阿里云盘 ; Sleep,2000 ; WinKill, ahk_class Chrome_WidgetWin_1 WinKill, 阿里云盘 ahk_class Chrome_WidgetWin_1 ahk_exe aDrive.exe Sleep,234 Process,Close,aDrive.exe Sleep,234 ; WinClose ; WinKill ; Process,Close ; 启动阿里云盘程序进程并激活阿里云盘窗口 Process,Exist,aDrive.exe Sleep,234 if (%ErrorLevel%=0) { Sleep,234 Run,C:\Users\Administrator\AppData\local\Programs\aDrive\aDrive.exe Sleep,5000 } ; Process,Exist, ; if (%ErrorLevel%=0) ; { ; } ; IfWinNotExist, ; { ; } ; Run ; WinActivate ; WinGet, WinRARwinid, ID,WinRAR 简体中文版安装,WinRAR 关联文件 ; DllCall( "SwitchToThisWindow" , "UInt" , WinRARwinid, "UInt" , 1) ; IfWinActive,WinRAR 简体中文版安装,WinRAR 关联文件 t1:=A_TickCount, Text:=X:=Y:= "" ; 激活最下面的匹配窗口,由于WinActivate对阿里云盘无效,所以此处用WinActivateBottom loop,3 { #WinActivateForce DetectHiddenWindows,On SetTitleMatchMode,2 ; WinWait, 阿里云盘 ahk_class Chrome_WidgetWin_1 ahk_exe aDrive.exe WinActivateBottom, 阿里云盘 WinActivateBottom, ahk_class Chrome_WidgetWin_1 ; 无效WinActivateBottom, ahk_exe aDrive.exe WinActivateBottom, 阿里云盘 ahk_class Chrome_WidgetWin_1 ahk_exe aDrive.exe ; WinGet, aliwinid, ID,阿里云盘 ; 无效DllCall( "SwitchToThisWindow" , "UInt" , aliwinid, "UInt" , 1) } WinWait, 阿里云盘 ahk_class Chrome_WidgetWin_1 ahk_exe aDrive.exe,,9 WinWaitActive, 阿里云盘 ahk_class Chrome_WidgetWin_1 ahk_exe aDrive.exe,,9 MsgBox,,FindTextNow,FindTextNow,1 CoordMode,Mouse, Screen MouseMove,A_ScreenWidth/2,A_ScreenHeight/2 Sleep,234 ToolTip,全部暂停状态下的传 输按钮 ; 查找阿里云盘的全部暂停状态下的传输按钮并点击,(不同状态下的传输按钮的图标不同,所以两种状态下的按钮都需要点击一下) Text:= "|<>*184$22.0Dk03zk0y3k703Us07300AMQkNXn1iTA2lgkD0n0w3A3kAyB0nlq3C6MAkMk033U0Q703UDVw0Dz007k2" if (ok:=FindText(X, Y, 454-150000, 239-150000, 454+150000, 239+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,传 输按钮 ; 查找阿里云盘的传输按钮并点击 Text:= "|<>*193$10.10A1kD1yDzTwDUw3UA0UU" if (ok:=FindText(X, Y, 454-150000, 239-150000, 454+150000, 239+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,选中状态下的下 载按钮 ; 查找阿里云盘的选中状态下的下载按钮并点击 Text:= "|<>*165$18.0A00A00A00A00A0CAQMA6kA3kA3lhXlzXkz3kS3kA3k03k03k03M06DzwU" if (ok:=FindText(X, Y, 454-150000, 239-150000, 454+150000, 239+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,下 载按钮 ; 查找阿里云盘的下载按钮并点击 Text:= "|<>*178$18.0A00A00A00A00A0CAQMA6kA3kA3lhXlzXkz3kS3kA3k03k03k03M06DzwU" if (ok:=FindText(X, Y, 454-150000, 239-150000, 454+150000, 239+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,下 载按钮 ; 查找阿里云盘的下载按钮的文字部分并点击 Text:= "|<>*149$28.zzkWk20TcU808U0UDzw3U480/1zm0X2VE26Tb0808M0U0xY20SOE80/6U" if (ok:=FindText(X, Y, 454-150000, 239-150000, 454+150000, 239+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,全部 暂停按钮 ; 查找阿里云盘的全部暂停按钮并点击 Text:= "|<>*183$48.1U4T8T0E1ETkzkDz68FGIT8086+ITYNwzzzq4YM00U0Fz0jz0UTFDwA1DyFF84/y0UFSDw8E0UTE848ETzFEDw9kU" if (ok:=FindText(X, Y, 1425-150000, 333-150000, 1425+150000, 333+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,部 暂按钮 ; 查找阿里云盘的全部暂停按钮并点击 Text:= "|<>**50$24.4T8TTkzkFGIT+ITYzq4Y0Fz0TFDwF184FCDwT084FEDwU" if (ok:=FindText(X, Y, 1425-150000, 333-150000, 1425+150000, 333+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 loop,2 { ToolTip,全部 开始按钮 ; 查找阿里云盘的全部开始按钮并点击 Text:= "|<>*185$48.1U4TTy8E1ETk488E68FG480Y86+I48z2zzzqzzHy0U0F48I10UTF485yDyFF48R20UFS48B20UTE88HyTzFEE8V2U" if (ok:=FindText(X, Y, 1212-150000, 254-150000, 1212+150000, 254+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 ToolTip,部 开 按钮 ; 查找阿里云盘的全部开始按钮并点击,这次查找 “部开” 这两个字,多次查找和点击,防止因鼠标光标偏移造成罕见的小概率的按钮没有点到 Text:= "|<>*185$24.4TTyTk48FG48+I48zqzz0F48TF48FF48FS48TE88FEE8U" if (ok:=FindText(X, Y, 1212-150000, 254-150000, 1212+150000, 254+150000, 0.05, 0.05, Text)) { CoordMode, Mouse,Screen MouseMove, X, Y FindText().Click(X, Y, "L" ) } Sleep,234 } Sleep,234 ToolTip,清理任务栏托盘图标 ; 批量清理系统托盘上残留的多余的图标 TrayIcon_Clean() ; MouseMove,10,A_ScreenHeight*0.98148 ; MouseMove,2500,0,60 , R ; loop,3 ; { ; Text:= "|<>**30$15.3w1kkM16C4XQokWY2EUGY3IU9W36QlEsP0663UDkU" ; if (ok:=FindText(X, Y, 1592-150000, 1060-150000, 1592+150000, 1060+150000,0.0001, 0.0001, Text)) ; { ;;; FindText().Click(X, Y, "L" ) ; CoordMode, Mouse,Screen ; MouseMove, X, Y ; MouseMove,300,0, , R ; MouseMove, -600,0, , R ; } ; } Sleep,234 ToolTip Sleep,234 MouseMove,A_ScreenWidth/2,A_ScreenHeight/2 } ; ok:=FindText(X:= "wait" , Y:=3, 0,0,0,0,0,0,Text) ; 等待3秒等图像出现 ; ok:=FindText(X:= "wait0" , Y:=-1, 0,0,0,0,0,0,Text) ; 无限等待等图像消失 ; MsgBox, 4096, Tip, % "找到:`t" (IsObject(ok)?ok.Length():ok) ; . "`n`n时间:`t" (A_TickCount-t1) " 毫秒" ; . "`n`n位置:`t" X ", " Y ; . "`n`n结果:`t<" (IsObject(ok)?ok[1].id: "" ) ">" ; Try For i,v in ok ; ok 值可以这样获取 ok:=FindText().ok ; if (i<=2) ; FindText().MouseTip(ok[i].x, ok[i].y) ;========== FindText(ByRef x:= "FindTextClass" , ByRef y:= "" , args*) { static init, obj if (!VarSetCapacity(init) && init:= "1" ) obj:= new FindTextClass() return (x== "FindTextClass" && !args.Length()) ? obj : obj.FindText(x, y, args*) } class FindTextClass { ; // Class Begin __New() { this .bits:={ Scan0: 0, hBM: 0, oldzw: 0, oldzh: 0 } this .bind:={ id: 0, mode: 0, oldStyle: 0 } this .Lib:=[] this .Cursor:=0 } __Delete() { if ( this .bits.hBM) DllCall( "DeleteObject" , "Ptr" , this .bits.hBM) } New() { return new FindTextClass() } help() { return " ( ;-------------------------------- ; FindText - 屏幕找字函数 ; 版本 : 9.5 (2024-04-27) ;-------------------------------- ; 返回变量:=FindText( ; OutputX --> 保存返回的X坐标的变量名称 ; , OutputY --> 保存返回的Y坐标的变量名称 ; , X1 --> 查找范围的左上角X坐标 ; , Y1 --> 查找范围的左上角Y坐标 ; , X2 --> 查找范围的右下角X坐标 ; , Y2 --> 查找范围的右下角Y坐标 ; , err1 --> 文字的黑点容错百分率(0.1=10%) ; , err0 --> 背景的白点容错百分率(0.1=10%) ; , Text --> 由工具生成的查找图像的数据,可以一次查找多个,用“|”分隔 ; , ScreenShot --> 是否截屏,为0则使用上一次的截屏数据 ; , FindAll --> 是否搜索所有位置,为0则找到一个位置就返回 ; , JoinText --> 如果想组合查找,可以为1,或者是要查找单词的数组 ; , offsetX --> 组合图像的每个字和前一个字的最大横向间隔 ; , offsetY --> 组合图像的每个字和前一个字的最大高低间隔 ; , dir --> 查找的方向,有上、下、左、右、中心9种 ; , zoomW --> 图像宽度的缩放百分率(1.0=100%) ; , zoomH --> 图像高度的缩放百分率(1.0=100%) ; ) ; ; 返回变量 --> 如果没找到结果会返回0。否则返回一个二级数组, ; 第一级是每个结果对象,第二级是结果对象的具体信息对象: ; { 1:左上角X, 2:左上角Y, 3:图像宽度W, 4:图像高度H ; , x:中心点X, y:中心点Y, id:图像识别文本 } ; 坐标都是相对于屏幕,颜色使用RGB格式 ; ; 如果 OutputX 等于 'wait' 或 'wait1' 意味着等待图像出现, ; 如果 OutputX 等于 'wait0' 意味着等待图像消失 ; 此时 OutputY 设置等待时间的秒数,如果小于0则无限等待 ; 如果超时则返回0,意味着失败,如果等待图像出现成功,则返回位置数组 ; 如果等待图像消失成功,则返回 1(注意这里的等待功能仅适用于静态图像) ; 例1: FindText(X:= 'wait' , Y:=3, 0,0,0,0,0,0,Text) ; 等待3秒等图像出现 ; 例2: FindText(X:= 'wait0' , Y:=-1, 0,0,0,0,0,0,Text) ; 无限等待等图像消失 ; ; <FindMultiColor> <FindColor> : 找色 是仅有一个点的 找多色 ; Text:= '|<>##DRDGDB $ 0/0/RRGGBB1-DRDGDB1/RRGGBB2, xn/yn/-RRGGBB3/RRGGBB4, ...' ; '##' 之后的颜色 (0xDRDGDB) 是所有颜色的默认偏色(各个分量允许的变化值) ; 初始点 (0,0) 匹配 0xRRGGBB1(+/-0xDRDGDB1) 或者 0xRRGGBB2(+/-0xDRDGDB), ; 点 (xn,yn) 匹配 排除 0xRRGGBB3(+/-0xDRDGDB) 和排除 0xRRGGBB4(+/-0xDRDGDB) ; 点坐标后面以 '-' 开头表示要排除后面的所有颜色,其他颜色都匹配 ; 每个点最多允许匹配10组颜色 (xn/yn/RRGGBB1/.../RRGGBB10) ; ; <FindPic> : Text 参数需要手动输入 ; Text:= '|<>##DRDGDB-RRGGBB1-RRGGBB2... $ d:\a.bmp' ; 0xRRGGBB1(+/-0xDRDGDB)... 都是透明色,不参与匹配 ; ;-------------------------------- )" } FindText(ByRef OutputX:= "" , ByRef OutputY:= "" , x1:=0, y1:=0, x2:=0, y2:=0, err1:=0, err0:=0, text:= "" , ScreenShot:=1, FindAll:=1, JoinText:=0, offsetX:=20, offsetY:=10 , dir:=1, zoomW:=1, zoomH:=1) { local if (OutputX ~= "i)^\s*wait[10]?\s*$" ) { found:=!InStr(OutputX, "0" ), time:=Round(OutputY,15) , timeout:=A_TickCount+Round(time*1000) loop { ok:= this .FindText(,, x1, y1, x2, y2, err1, err0, text, ScreenShot , FindAll, JoinText, offsetX, offsetY, dir, zoomW, zoomH) if (found && ok) { OutputX:=ok[1].x, OutputY:=ok[1].y return ok } if (!found && !ok) return 1 if (time>=0 && A_TickCount>=timeout) break Sleep 50 } return 0 } SetBatchLines, % (bch:=A_BatchLines)? "-1" : "-1" x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2) if (x1=0 && y1=0 && x2=0 && y2=0) n:=150000, x:=y:=-n, w:=h:=2*n else x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 bits:= this .GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy), x-=zx, y-=zy , this .ok:=0, info:=[] loop Parse, text, | if IsObject(j:= this .PicInfo(A_LoopField)) info.Push(j) if (w<1 || h<1 || !(num:=info.Length()) || !bits.Scan0) { SetBatchLines, %bch% return 0 } arr:=[], info2:=[], k:=0, s:= "" , mode:=(IsObject(JoinText) ? 2 : JoinText ? 1 : 0) For i,j in info { k:=Max(k, (j[7]=5 && j[8]=0 ? j[9] : j[2]*j[3])) if (mode) v:=(mode=2 ? j[10] : i) . "" , s.= "|" v , (!info2.HasKey(v) && info2[v]:=[]), (v!= "" && info2[v].Push(j)) } sx:=x, sy:=y, sw:=w, sh:=h , JoinText:=(mode=1 ? [s] : JoinText) , VarSetCapacity(s1, k*4), VarSetCapacity(s0, k*4) , VarSetCapacity(ss, sw*(sh+2)) , allpos_max:=(FindAll || JoinText ? 10240 : 1) , ini:={ sx:sx, sy:sy, sw:sw, sh:sh, zx:zx, zy:zy , mode:mode, bits:bits, ss:&ss, s1:&s1, s0:&s0 , err1:err1, err0:err0, allpos_max:allpos_max , zoomW:zoomW, zoomH:zoomH } loop 2 { if (err1=0 && err0=0) && (num>1 || A_Index>1) ini.err1:=err1:=0.05, ini.err0:=err0:=0.05 if (!JoinText) { VarSetCapacity(allpos, allpos_max*4), allpos_ptr:=&allpos For i,j in info loop % this .PicFind(ini, j, dir, sx, sy, sw, sh, allpos_ptr) { pos:=NumGet(allpos, 4*(A_Index-1), "uint" ) , x:=(pos&0xFFFF)+zx, y:=(pos>>16)+zy , w:=Floor(j[2]*zoomW), h:=Floor(j[3]*zoomH), comment:=j[10] , arr.Push({1:x, 2:y, 3:w, 4:h, x:x+w //2, y:y+h//2, id:comment}) if (!FindAll) break 3 } } else For k,v in JoinText { v:=StrSplit(Trim(RegExReplace(v, "\s*\|[|\s]*" , "|" ), "|" ) , (InStr(v, "|" )? "|" : "" ), " `t" ) , this .JoinText(arr, ini, info2, v, 1, offsetX, offsetY , FindAll, dir, 0, 0, 0, sx, sy, sw, sh) if (!FindAll && arr.Length()) break 2 } if (err1!=0 || err0!=0 || arr.Length() || info[1][4] || info[1][7]=5) break } SetBatchLines, %bch% if (arr.Length()) { OutputX:=arr[1].x, OutputY:=arr[1].y, this .ok:=arr return arr } return 0 } ; 组合文本参数可以用数组 <==> [ "abc" , "xyz" , "a1|a2|a3" ] JoinText(arr, ini, info2, text, index, offsetX, offsetY , FindAll, dir, minX, minY, maxY, sx, sy, sw, sh) { local if !(Len:=text.Length()) return 0 VarSetCapacity(allpos, ini.allpos_max*4), allpos_ptr:=&allpos , zoomW:=ini.zoomW, zoomH:=ini.zoomH, mode:=ini.mode For i,j in info2[text[index]] if (mode!=2 || text[index]==j[10]) loop % this .PicFind(ini, j, dir, sx, sy, (index=1 ? sw : Min(sx+offsetX+Floor(j[2]*zoomW),ini.sx+ini.sw)-sx), sh, allpos_ptr) { pos:=NumGet(allpos, 4*(A_Index-1), "uint" ) , x:=pos&0xFFFF, y:=pos>>16 , w:=Floor(j[2]*zoomW), h:=Floor(j[3]*zoomH) , (index=1 && (minX:=x, minY:=y, maxY:=y+h)) , minY1:=Min(y, minY), maxY1:=Max(y+h, maxY), sx1:=x+w if (index<Len) { sy1:=Max(minY1-offsetY, ini.sy) , sh1:=Min(maxY1+offsetY, ini.sy+ini.sh)-sy1 if this .JoinText(arr, ini, info2, text, index+1, offsetX, offsetY , FindAll, 5, minX, minY1, maxY1, sx1, sy1, 0, sh1) && (index>1 || !FindAll) return 1 } else { comment:= "" For k,v in text comment.=(mode=2 ? v : info2[v][1][10]) x:=minX+ini.zx, y:=minY1+ini.zy, w:=sx1-minX, h:=maxY1-minY1 , arr.Push({1:x, 2:y, 3:w, 4:h, x:x+w //2, y:y+h//2, id:comment}) if (index>1 || !FindAll) return 1 } } return 0 } PicFind(ini, j, dir, sx, sy, sw, sh, allpos_ptr) { local static MyFunc:= "" if (!MyFunc) { x32:= "VVdWU4HslAAAAIO8JKgAAAAFi6wkrAAAAIu8JOAAAAAPhH8HAACLhCTkAAAAhcAP" . "jgQOAAAxwImsJKwAAADHBCQAAAAAx0QkFAAAAADHRCQMAAAAAInFx0QkGAAAAACQ" . "i4Qk3AAAAItMJBgx9jHbAciF@4lEJAh@PemQAAAAZpAPr4QkyAAAAInBifCZ9@8B" . "wYtEJAiAPBgxdEyLhCTYAAAAg8MBA7Qk+AAAAIkMqIPFATnfdFSLBCSZ97wk5AAA" . "AIO8JKgAAAAEdbUPr4QkvAAAAInBifCZ9@+NDIGLRCQIgDwYMXW0i0QkDIuUJNQA" . "AACDwwEDtCT4AAAAiQyCg8ABOd+JRCQMdawBfCQYg0QkFAGLjCT8AAAAi0QkFAEM" . "JDmEJOQAAAAPhTL@@@+LTCQMu62L22iJ7g+vjCToAAAAiWwkMIusJKwAAACJyMH5" . "H@frwfoMKcqLjCTsAAAAiVQkNA+vzonIwfkf9+vB+gwpyolUJDiDvCSoAAAABA+E" . "TwgAAIuEJLwAAACLvCTAAAAAD6+EJMQAAACLlCTIAAAAi4wkqAAAAPfahcmNBLiL" . "vCS8AAAAjTyXiXwkIA+FTQIAAInqienHRCQcAAAAAMHqEMdEJCgAAAAAD7b6i5Qk" . "zAAAAIl8JAgPtv2J6Yl8JBQPtvmJfCQYi7wkyAAAAMHnAoXSiXwkPA+OyAAAAIms" . "JKwAAACLvCTIAAAAhf8PjpEAAACLtCS4AAAAi2wkKAOsJNAAAAABxgNEJDyJRCQs" . "A4QkuAAAAIkEJI22AAAAAA+2TgKLXCQID7ZGAQ+2FitEJBQrVCQYic8B2SnfjZkA" . "BAAAD6@AD6@fweALD6@fAcO4@gUAACnID6@CD6@QAdM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AOUQkJH0Jg+4BD4j9+@@@SYPBAUU5zA+PbP@@" . "@+mf+@@@gXwkeP@@@wCLjCT4AAAAD4cC@@@@6Qf@@@+LjCT4AAAA6Xn7@@+QkJCQ" this .MCode(MyFunc, StrReplace((A_PtrSize=8?x64:x32), "@" , "/" )) } text:=j[1], w:=j[2], h:=j[3] , err1:=(j[4] ? j[5] : ini.err1) , err0:=(j[4] ? j[6] : ini.err0) , mode:=j[7], color:=j[8], n:=j[9] return (!ini.bits.Scan0) ? 0 : DllCall(&MyFunc , "int" ,mode, "uint" ,color, "uint" ,n, "int" ,dir , "Ptr" ,ini.bits.Scan0, "int" ,ini.bits.Stride , "int" ,sx, "int" ,sy, "int" ,sw, "int" ,sh , "Ptr" ,ini.ss, "Ptr" ,ini.s1, "Ptr" ,ini.s0 , (mode=5 ? "Ptr" : "AStr" ),text, "int" ,w, "int" ,h , "int" ,Floor(err1*10000), "int" ,Floor(err0*10000) , "Ptr" ,allpos_ptr, "int" ,ini.allpos_max , "int" ,Floor(w*ini.zoomW), "int" ,Floor(h*ini.zoomH)) } code() { return " ( //***** 机器码的 C语言 源代码 ***** int __attribute__((__stdcall__)) PicFind( int mode, unsigned int c, unsigned int n, int dir , unsigned char * Bmp, int Stride , int sx, int sy, int sw, int sh , unsigned char * ss, unsigned int * s1, unsigned int * s0 , unsigned char * text, int w, int h, int err1, int err0 , unsigned int * allpos, int allpos_max , int new_w, int new_h ) { int ok, o, i, j, k, v, e1, e0, len1, len0, max; int x, y, x1, y1, x2, y2, x3, y3; int r, g, b, rr, gg, bb, dR, dG, dB; int ii, jj, RunDir, DirCount, RunCount, AllCount1, AllCount2; unsigned int c1, c2; unsigned char * gs; unsigned int * cors; ok=0; o=0; len1=0; len0=0; //---------------------- if (mode==5) { if (k=(c!=0)) // FindPic { cors=(unsigned int *)(text+w*h*4); r=(c>>16)&0xFF; g=(c>>8)&0xFF; b=c&0xFF; dR=r*r; dG=g*g; dB=b*b; for (y=0; y<h; y++) { for (x=0; x<w; x++, o+=4) { rr=text[2+o]; gg=text[1+o]; bb=text[o]; for (i=0; i<n; i++) { c=cors[i]; r=((c>>16)&0xFF)-rr; g=((c>>8)&0xFF)-gg; b=(c&0xFF)-bb; if (r*r<=dR && g*g<=dG && b*b<=dB) goto NoMatch1; } s1[len1]=(y*new_h/h)*Stride+(x*new_w/w)*4; s0[len1++]=(rr<<16)|(gg<<8)|bb; NoMatch1:; } } } else // FindMultiColor or FindColor { cors=(unsigned int *)text; for (; len1<n; len1++, o+=22) { c=cors[o]; y=c>>16; x=c&0xFFFF; s1[len1]=(y*new_h/h)*Stride+(x*new_w/w)*4; s0[len1]=o+cors[o+1]*2; } cors+=2; } goto StartLookUp; } //---------------------- // 生成查表需要的表格 for (y=0; y<h; y++) { for (x=0; x<w; x++) { if (mode==4) i=(y*new_h/h)*Stride+(x*new_w/w)*4; else i=(y*new_h/h)*sw+(x*new_w/w); if (text[o++]== '1' ) s1[len1++]=i; else s0[len0++]=i; } } //---------------------- // 颜色位置模式 // 仅用于多色验证码的识别 if (mode==4) { y=c>>16; x=c&0xFFFF; c=(y*new_h/h)*Stride+(x*new_w/w)*4; goto StartLookUp; } //---------------------- // 生成二值化图像 o=sy*Stride+sx*4; j=Stride-sw*4; i=0; if (mode==0) // 颜色相似二值化 { rr=(c>>16)&0xFF; gg=(c>>8)&0xFF; bb=c&0xFF; for (y=0; y<sh; y++, o+=j) for (x=0; x<sw; x++, o+=4, i++) { r=Bmp[2+o]-rr; g=Bmp[1+o]-gg; b=Bmp[o]-bb; v=r+rr+rr; ss[i]=((1024+v)*r*r+2048*g*g+(1534-v)*b*b<=n) ? 1:0; } } else if (mode==1) // 灰度阈值二值化 { c=(c+1)<<7; for (y=0; y<sh; y++, o+=j) for (x=0; x<sw; x++, o+=4, i++) ss[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15<c) ? 1:0; } else if (mode==2) // 灰度差值二值化 { gs=ss+sw*2; for (y=0; y<sh; y++, o+=j) { for (x=0; x<sw; x++, o+=4, i++) gs[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15)>>7; } for (i=0, y=0; y<sh; y++) for (x=0; x<sw; x++, i++) { if (x==0 || y==0 || x==sw-1 || y==sh-1) ss[i]=2; else { n=gs[i]+c; ss[i]=(gs[i-1]>n || gs[i+1]>n || gs[i-sw]>n || gs[i+sw]>n || gs[i-sw-1]>n || gs[i-sw+1]>n || gs[i+sw-1]>n || gs[i+sw+1]>n) ? 1:0; } } } else // (mode==3) 颜色分量二值化 { rr=(c>>16)&0xFF; gg=(c>>8)&0xFF; bb=c&0xFF; r=(n>>16)&0xFF; g=(n>>8)&0xFF; b=n&0xFF; dR=r*r; dG=g*g; dB=b*b; for (y=0; y<sh; y++, o+=j) for (x=0; x<sw; x++, o+=4, i++) { r=Bmp[2+o]-rr; g=Bmp[1+o]-gg; b=Bmp[o]-bb; ss[i]=(r*r<=dR && g*g<=dG && b*b<=dB) ? 1:0; } } //---------------------- StartLookUp: err1=len1*err1/10000; err0=len0*err0/10000; if (err1>=len1) len1=0; if (err0>=len0) len0=0; max=(len1>len0) ? len1 : len0; if (mode==5 || mode==4) { x1=sx; y1=sy; sx=0; sy=0; } else { x1=0; y1=0; } x2=x1+sw-new_w; y2=y1+sh-new_h; // 1 ==> ( Left to Right ) Top to Bottom // 2 ==> ( Right to Left ) Top to Bottom // 3 ==> ( Left to Right ) Bottom to Top // 4 ==> ( Right to Left ) Bottom to Top // 5 ==> ( Top to Bottom ) Left to Right // 6 ==> ( Bottom to Top ) Left to Right // 7 ==> ( Top to Bottom ) Right to Left // 8 ==> ( Bottom to Top ) Right to Left // 9 ==> Center to Four Sides if (dir==9) { x=(x1+x2)/2; y=(y1+y2)/2; i=x2-x1+1; j=y2-y1+1; AllCount1=i*j; i=(i>j) ? i+8 : j+8; AllCount2=i*i; RunCount=0; DirCount=1; RunDir=0; for (ii=0; RunCount<AllCount1 && ii<AllCount2; ii++) { for (jj=0; jj<DirCount; jj++) { if (x>=x1 && x<=x2 && y>=y1 && y<=y2) { RunCount++; goto FindPos; FindPos_GoBak:; } if (RunDir==0) y--; else if (RunDir==1) x++; else if (RunDir==2) y++; else if (RunDir==3) x--; } if (RunDir & 1) DirCount++; RunDir = (++RunDir) & 3; } goto Return1; } if (dir<1 || dir>8) dir=1; if (--dir>3) { r=y1; y1=x1; x1=r; r=y2; y2=x2; x2=r; } for (y3=y1; y3<=y2; y3++) { for (x3=x1; x3<=x2; x3++) { y=(dir & 2) ? y1+y2-y3 : y3; x=(dir & 1) ? x1+x2-x3 : x3; if (dir>3) { r=y; y=x; x=r; } //---------------------- FindPos: e1=err1; e0=err0; if (mode==5) { o=y*Stride+x*4; if (k) { for (i=0; i<max; i++) { j=o+s1[i]; c=s0[i]; r=Bmp[2+j]-((c>>16)&0xFF); g=Bmp[1+j]-((c>>8)&0xFF); b=Bmp[j]-(c&0xFF); if ((r*r>dR || g*g>dG || b*b>dB) && (--e1)<0) goto NoMatch; } } else { for (i=0; i<max; i++) { j=o+s1[i]; rr=Bmp[2+j]; gg=Bmp[1+j]; bb=Bmp[j]; for (j=i*22, v=cors[j]>0xFFFFFF, n=s0[i]; j<n;) { c1=cors[j++]; c2=cors[j++]; r=((c1>>16)&0xFF)-rr; g=((c1>>8)&0xFF)-gg; b=(c1&0xFF)-bb; dR=(c2>>16)&0xFF; dG=(c2>>8)&0xFF; dB=c2&0xFF; if (r*r<=dR*dR && g*g<=dG*dG && b*b<=dB*dB) { if (v) goto NoMatch2; goto MatchOK; } } if (v) goto MatchOK; NoMatch2:; if ((--e1)<0) goto NoMatch; MatchOK:; } } } else if (mode==4) { o=y*Stride+x*4; j=o+c; rr=Bmp[2+j]; gg=Bmp[1+j]; bb=Bmp[j]; for (i=0; i<max; i++) { if (i<len1) { j=o+s1[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb; v=r+rr+rr; if ((1024+v)*r*r+2048*g*g+(1534-v)*b*b>n && (--e1)<0) goto NoMatch; } if (i<len0) { j=o+s0[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb; v=r+rr+rr; if ((1024+v)*r*r+2048*g*g+(1534-v)*b*b<=n && (--e0)<0) goto NoMatch; } } } else { o=y*sw+x; for (i=0; i<max; i++) { if (i<len1 && ss[o+s1[i]]==0 && (--e1)<0) goto NoMatch; if (i<len0 && ss[o+s0[i]]==1 && (--e0)<0) goto NoMatch; } // 清空已经找到的图像 for (i=0; i<len1; i++) ss[o+s1[i]]=0; } ok++; if (allpos!=0) { allpos[ok-1]=(sy+y)<<16|(sx+x); if (ok>=allpos_max) goto Return1; } NoMatch:; if (dir==9) goto FindPos_GoBak; } } //---------------------- Return1: return ok; } )" } PicInfo(text) { local if !InStr(text, "$" ) return static init, info, bmp if (!VarSetCapacity(init) && init:= "1" ) info:=[], bmp:=[] key:=(r:=StrLen(text))<10000 ? text : DllCall( "ntdll\RtlComputeCrc32" , "uint" ,0 , "Ptr" ,&text, "uint" ,r*(1+!!A_IsUnicode), "uint" ) if info.HasKey(key) return info[key] v:=text, comment:= "" , seterr:=err1:=err0:=0 ; You Can Add Comment Text within The <> if RegExMatch(v, "O)<([^>\n]*)>" , r) v:=StrReplace(v,r[0]), comment:=Trim(r[1]) ; You can Add two fault-tolerant in the [], separated by commas if RegExMatch(v, "O)\[([^\]\n]*)]" , r) { v:=StrReplace(v,r[0]), r:=StrSplit(r[1] "," , "," ) , seterr:=1, err1:=r[1], err0:=r[2] } color:=SubStr(v,1,InStr(v, "$" )-1), v:=Trim(SubStr(v,InStr(v, "$" )+1)) mode:=InStr(color, "##" ) ? 5 : InStr(color, "#" ) ? 4 : InStr(color, "-" ) ? 3 : InStr(color, "**" ) ? 2 : InStr(color, "*" ) ? 1 : 0 color:=RegExReplace(color, "[*#\s]" ) (mode=0 || mode=3 || mode=5) && color:=StrReplace(color, "0x" ) if (mode=5) { if !(v~= "/[\s\-\w]+/[\s\-\w,/]+$" ) { ; <FindPic> : Text 参数需要手动输入 ; Text:= '|<>##DRDGDB-RRGGBB1-RRGGBB2... $ d:\a.bmp' ; 0xRRGGBB1(+/-0xDRDGDB)... 都是透明色,不参与匹配 if !(hBM:=LoadPicture(v)) return this .GetBitmapWH(hBM, w, h) if (w<1 || h<1) return hBM2:= this .CreateDIBSection(w, h, 32, Scan0) this .CopyHBM(hBM2, 0, 0, hBM, 0, 0, w, h) DllCall( "DeleteObject" , "Ptr" ,hBM) if (!Scan0) return ; 所有用于搜索的图片都缓存了 StrReplace(color, "-" ,, n) bmp.Push(buf:= this .Buffer(w*h*4+n*4)), v:=buf.Ptr DllCall( "RtlMoveMemory" , "Ptr" ,v, "Ptr" ,Scan0, "Ptr" ,w*h*4) DllCall( "DeleteObject" , "Ptr" ,hBM2) p:=v+w*h*4-4 , tab:=Object( "Black" , "000000" , "White" , "FFFFFF" , "Red" , "FF0000" , "Green" , "008000" , "Blue" , "0000FF" , "Yellow" , "FFFF00" , "Silver" , "C0C0C0" , "Gray" , "808080" , "Teal" , "008080" , "Navy" , "000080" , "Aqua" , "00FFFF" , "Olive" , "808000" , "Lime" , "00FF00" , "Fuchsia" , "FF00FF" , "Purple" , "800080" , "Maroon" , "800000" ) For k1,v1 in StrSplit(color, "-" ) if (k1>1) NumPut(Floor( "0x" (tab.HasKey(v1)?tab[v1]:v1)), 0|p+=4, "uint" ) color:=Floor( "0x" StrSplit(color "-" , "-" )[1])|0x1000000 } else { ; <FindMultiColor> <FindColor> : 找色 是仅有一个点的 找多色 ; Text:= '|<>##DRDGDB $ 0/0/RRGGBB1-DRDGDB1/RRGGBB2, xn/yn/-RRGGBB3/RRGGBB4, ...' ; '##' 之后的颜色 (0xDRDGDB) 是所有颜色的默认偏色(各个分量允许的变化值) ; 初始点 (0,0) 匹配 0xRRGGBB1(+/-0xDRDGDB1) 或者 0xRRGGBB2(+/-0xDRDGDB), ; 点 (xn,yn) 匹配 排除 0xRRGGBB3(+/-0xDRDGDB) 和排除 0xRRGGBB4(+/-0xDRDGDB) ; 点坐标后面以 '-' 开头表示要排除后面的所有颜色,其他颜色都匹配 ; 每个点最多允许匹配10组颜色 (xn/yn/RRGGBB1/.../RRGGBB10) arr:=StrSplit(Trim(RegExReplace(v, "i)\s|0x" ), "," ), "," ) if !(n:=arr.Length()) return bmp.Push(buf:= this .Buffer(n*22*4)), v:=buf.Ptr , color:=StrSplit(color "-" , "-" )[1] For k1,v1 in arr { r:=StrSplit(v1 "/" , "/" ) , x:=Floor(r[1]), y:=Floor(r[2]) , (A_Index=1) ? (x1:=x2:=x, y1:=y2:=y) : (x1:=Min(x1,x), x2:=Max(x2,x) , y1:=Min(y1,y), y2:=Max(y2,y)) } For k1,v1 in arr { r:=StrSplit(v1 "/" , "/" ) , x:=Floor(r[1])-x1, y:=Floor(r[2])-y1 , n1:=Min(Max(r.Length()-3, 0), 10) , NumPut(y<<16|x, 0|p:=v+(A_Index-1)*22*4, "uint" ) , NumPut(n1, 0|p+=4, "uint" ) Loop % n1 k1:=(InStr(v1:=r[2+A_Index], "-" )=1 ? 0x1000000:0) , c:=StrSplit(Trim(v1, "-" ) "-" color, "-" ) , NumPut(Floor( "0x" c[1])&0xFFFFFF|k1, 0|p+=4, "uint" ) , NumPut(Floor( "0x" c[2]), 0|p+=4, "uint" ) } color:=0, w:=x2-x1+1, h:=y2-y1+1 } } else { r:=StrSplit(v "." , "." ), w:=Floor(r[1]) , v:= this .base64tobit(r[2]), h:=StrLen(v) //w if (w<1 || h<1 || StrLen(v)!=w*h) return if (mode=3) { r:=StrSplit(color, "-" ) , color:=Floor( "0x" r[1]), n:=Floor( "0x" r[2]) } else { r:=StrSplit(color "@1" , "@" ) , color:=Floor((mode=0? "0x" : "" ) r[1]), n:=r[2] , n:=(n<=0||n>1?1:n), n:=Floor(4606*255*255*(1-n)*(1-n)) , (mode=4) && color:=((color-1) //w)<<16|Mod(color-1,w) } } return info[key]:=[v, w, h, seterr, err1, err0, mode, color, n, comment] } Buffer(size, FillByte:= "" ) { local buf:={}, buf.SetCapacity( "a" , size), p:=buf.GetAddress( "a" ) , (FillByte!= "" && DllCall( "RtlFillMemory" , "Ptr" ,p, "Ptr" ,size, "uchar" ,FillByte)) , buf.Ptr:=p, buf.Size:=size return buf } GetBitsFromScreen(ByRef x:=0, ByRef y:=0, ByRef w:=0, ByRef h:=0 , ScreenShot:=1, ByRef zx:=0, ByRef zy:=0, ByRef zw:=0, ByRef zh:=0) { local static CAPTUREBLT:= "" (!IsObject( this .bits) && this .bits:={Scan0:0, hBM:0, oldzw:0, oldzh:0}) , bits:= this .bits if (!ScreenShot && bits.Scan0) { zx:=bits.zx, zy:=bits.zy, zw:=bits.zw, zh:=bits.zh , w:=Min(x+w,zx+zw), x:=Max(x,zx), w-=x , h:=Min(y+h,zy+zh), y:=Max(y,zy), h-=y return bits } bch:=A_BatchLines, cri:=A_IsCritical Critical if (id:= this .BindWindow(0,0,1)) { WinGet, id, ID, ahk_id %id% WinGetPos, zx, zy, zw, zh, ahk_id %id% } if (!id) { SysGet, zx, 76 SysGet, zy, 77 SysGet, zw, 78 SysGet, zh, 79 } this .UpdateBits(bits, zx, zy, zw, zh) , w:=Min(x+w,zx+zw), x:=Max(x,zx), w-=x , h:=Min(y+h,zy+zh), y:=Max(y,zy), h-=y if (!ScreenShot || w<1 || h<1 || !bits.hBM) { Critical, %cri% SetBatchLines, %bch% return bits } if IsFunc(k:= "GetBitsFromScreen2" ) && %k%(bits, x-zx, y-zy, w, h) { ; Each small range of data obtained from DXGI must be ; copied to the screenshot cache using FindText().CopyBits() zx:=bits.zx, zy:=bits.zy, zw:=bits.zw, zh:=bits.zh Critical, %cri% SetBatchLines, %bch% return bits } if (CAPTUREBLT= "" ) ; thanks Descolada { DllCall( "Dwmapi\DwmIsCompositionEnabled" , "Int*" ,i:=0) CAPTUREBLT:=i ? 0 : 0x40000000 } mDC:=DllCall( "CreateCompatibleDC" , "Ptr" ,0, "Ptr" ) oBM:=DllCall( "SelectObject" , "Ptr" ,mDC, "Ptr" ,bits.hBM, "Ptr" ) if (id) { if (mode:= this .BindWindow(0,0,0,1))<2 { hDC:=DllCall( "GetDCEx" , "Ptr" ,id, "Ptr" ,0, "int" ,3, "Ptr" ) DllCall( "BitBlt" , "Ptr" ,mDC, "int" ,x-zx, "int" ,y-zy, "int" ,w, "int" ,h , "Ptr" ,hDC, "int" ,x-zx, "int" ,y-zy, "uint" ,0xCC0020|CAPTUREBLT) DllCall( "ReleaseDC" , "Ptr" ,id, "Ptr" ,hDC) } else { hBM2:= this .CreateDIBSection(zw, zh) mDC2:=DllCall( "CreateCompatibleDC" , "Ptr" ,0, "Ptr" ) oBM2:=DllCall( "SelectObject" , "Ptr" ,mDC2, "Ptr" ,hBM2, "Ptr" ) DllCall( "PrintWindow" , "Ptr" ,id, "Ptr" ,mDC2, "uint" ,(mode>3)*3) DllCall( "BitBlt" , "Ptr" ,mDC, "int" ,x-zx, "int" ,y-zy, "int" ,w, "int" ,h , "Ptr" ,mDC2, "int" ,x-zx, "int" ,y-zy, "uint" ,0xCC0020) DllCall( "SelectObject" , "Ptr" ,mDC2, "Ptr" ,oBM2) DllCall( "DeleteDC" , "Ptr" ,mDC2) DllCall( "DeleteObject" , "Ptr" ,hBM2) } } else { hDC:=DllCall( "GetWindowDC" , "Ptr" ,id:=DllCall( "GetDesktopWindow" , "Ptr" ), "Ptr" ) DllCall( "BitBlt" , "Ptr" ,mDC, "int" ,x-zx, "int" ,y-zy, "int" ,w, "int" ,h , "Ptr" ,hDC, "int" ,x, "int" ,y, "uint" ,0xCC0020|CAPTUREBLT) DllCall( "ReleaseDC" , "Ptr" ,id, "Ptr" ,hDC) } if this .CaptureCursor(0,0,0,0,0,1) this .CaptureCursor(mDC, zx, zy, zw, zh) DllCall( "SelectObject" , "Ptr" ,mDC, "Ptr" ,oBM) DllCall( "DeleteDC" , "Ptr" ,mDC) Critical, %cri% SetBatchLines, %bch% return bits } UpdateBits(bits, zx, zy, zw, zh) { local if (zw>bits.oldzw || zh>bits.oldzh || !bits.hBM) { Try DllCall( "DeleteObject" , "Ptr" ,bits.hBM) bits.hBM:= this .CreateDIBSection(zw, zh, bpp:=32, ppvBits) , bits.Scan0:=(!bits.hBM ? 0:ppvBits) , bits.Stride:=((zw*bpp+31) //32)*4 , bits.oldzw:=zw, bits.oldzh:=zh } bits.zx:=zx, bits.zy:=zy, bits.zw:=zw, bits.zh:=zh } CreateDIBSection(w, h, bpp:=32, ByRef ppvBits:=0) { local VarSetCapacity(bi, 40, 0), NumPut(40, bi, 0, "int" ) , NumPut(w, bi, 4, "int" ), NumPut(-h, bi, 8, "int" ) , NumPut(1, bi, 12, "short" ), NumPut(bpp, bi, 14, "short" ) return DllCall( "CreateDIBSection" , "Ptr" ,0, "Ptr" ,&bi , "int" ,0, "Ptr*" ,ppvBits:=0, "Ptr" ,0, "int" ,0, "Ptr" ) } GetBitmapWH(hBM, ByRef w, ByRef h) { local VarSetCapacity(bm, size:=(A_PtrSize=8 ? 32:24)) , DllCall( "GetObject" , "Ptr" ,hBM, "int" ,size, "Ptr" ,&bm) , w:=NumGet(bm,4, "int" ), h:=Abs(NumGet(bm,8, "int" )) } CopyHBM(hBM1, x1, y1, hBM2, x2, y2, w, h, Clear:=0, trans:=0, alpha:=255) { local if (w<1 || h<1 || !hBM1 || !hBM2) return mDC1:=DllCall( "CreateCompatibleDC" , "Ptr" ,0, "Ptr" ) oBM1:=DllCall( "SelectObject" , "Ptr" ,mDC1, "Ptr" ,hBM1, "Ptr" ) mDC2:=DllCall( "CreateCompatibleDC" , "Ptr" ,0, "Ptr" ) oBM2:=DllCall( "SelectObject" , "Ptr" ,mDC2, "Ptr" ,hBM2, "Ptr" ) if (trans) DllCall( "GdiAlphaBlend" , "Ptr" ,mDC1, "int" ,x1, "int" ,y1, "int" ,w, "int" ,h , "Ptr" ,mDC2, "int" ,x2, "int" ,y2, "int" ,w, "int" ,h, "uint" ,alpha<<16) else DllCall( "BitBlt" , "Ptr" ,mDC1, "int" ,x1, "int" ,y1, "int" ,w, "int" ,h , "Ptr" ,mDC2, "int" ,x2, "int" ,y2, "uint" ,0xCC0020) if (Clear) DllCall( "BitBlt" , "Ptr" ,mDC1, "int" ,x1, "int" ,y1, "int" ,w, "int" ,h , "Ptr" ,mDC1, "int" ,x1, "int" ,y1, "uint" ,MERGECOPY:=0xC000CA) DllCall( "SelectObject" , "Ptr" ,mDC1, "Ptr" ,oBM1) DllCall( "DeleteDC" , "Ptr" ,mDC1) DllCall( "SelectObject" , "Ptr" ,mDC2, "Ptr" ,oBM2) DllCall( "DeleteDC" , "Ptr" ,mDC2) } CopyBits(Scan01,Stride1,x1,y1,Scan02,Stride2,x2,y2,w,h,Reverse:=0) { local if (w<1 || h<1 || !Scan01 || !Scan02) return static init, MFCopyImage if (!VarSetCapacity(init) && init:= "1" ) { MFCopyImage:=DllCall( "GetProcAddress" , "Ptr" , DllCall( "LoadLibrary" , "Str" , "Mfplat.dll" , "Ptr" ) , "AStr" , "MFCopyImage" , "Ptr" ) } if (MFCopyImage && !Reverse) ; thanks QQ:任性 { return DllCall(MFCopyImage , "Ptr" ,Scan01+y1*Stride1+x1*4, "int" ,Stride1 , "Ptr" ,Scan02+y2*Stride2+x2*4, "int" ,Stride2 , "uint" ,w*4, "uint" ,h) } ListLines % (lls:=A_ListLines)?0:0 SetBatchLines, % (bch:=A_BatchLines)? "-1" : "-1" p1:=Scan01+(y1-1)*Stride1+x1*4 , p2:=Scan02+(y2-1)*Stride2+x2*4, w*=4 if (Reverse) p2+=(h+1)*Stride2, Stride2:=-Stride2 Loop % h DllCall( "RtlMoveMemory" , "Ptr" ,p1+=Stride1, "Ptr" ,p2+=Stride2, "Ptr" ,w) SetBatchLines, %bch% ListLines %lls% } DrawHBM(hBM, lines) { local mDC:=DllCall( "CreateCompatibleDC" , "Ptr" ,0, "Ptr" ) oBM:=DllCall( "SelectObject" , "Ptr" ,mDC, "Ptr" ,hBM, "Ptr" ) oldc:= "" , brush:=0, VarSetCapacity(rect, 16) For k,v in lines ; [ [x, y, w, h, color] ] if IsObject(v) { if (oldc!=v[5]) { oldc:=v[5], BGR:=(oldc&0xFF)<<16|oldc&0xFF00|(oldc>>16)&0xFF DllCall( "DeleteObject" , "Ptr" ,brush) brush:=DllCall( "CreateSolidBrush" , "UInt" ,BGR, "Ptr" ) } DllCall( "SetRect" , "Ptr" ,&rect, "int" ,v[1], "int" ,v[2] , "int" ,v[1]+v[3], "int" ,v[2]+v[4]) DllCall( "FillRect" , "Ptr" ,mDC, "Ptr" ,&rect, "Ptr" ,brush) } DllCall( "DeleteObject" , "Ptr" ,brush) DllCall( "SelectObject" , "Ptr" ,mDC, "Ptr" ,oBM) DllCall( "DeleteObject" , "Ptr" ,mDC) } ; 绑定窗口从而可以后台查找这个窗口的图像 ; 相当于始终在前台。解绑窗口使用 FindText().BindWindow(0) BindWindow(bind_id:=0, bind_mode:=0, get_id:=0, get_mode:=0) { local (!IsObject( this .bind) && this .bind:={id:0, mode:0, oldStyle:0}) , bind:= this .bind if (get_id) return bind.id if (get_mode) return bind.mode if (bind_id) { bind.id:=bind_id, bind.mode:=bind_mode, bind.oldStyle:=0 if (bind_mode & 1) { WinGet, i, ExStyle, ahk_id %bind_id% bind.oldStyle:=i WinSet, Transparent, 255, ahk_id %bind_id% Loop 30 { Sleep 100 WinGet, i, Transparent, ahk_id %bind_id% } Until (i=255) } } else { bind_id:=bind.id if (bind.mode & 1) WinSet, ExStyle, % bind.oldStyle, ahk_id %bind_id% bind.id:=0, bind.mode:=0, bind.oldStyle:=0 } } ; 使用 FindText().CaptureCursor(1) 设置抓图时捕获鼠标 ; 使用 FindText().CaptureCursor(0) 取消抓图时捕获鼠标 CaptureCursor(hDC:=0, zx:=0, zy:=0, zw:=0, zh:=0, get_cursor:=0) { local if (get_cursor) return this .Cursor if (hDC=1 || hDC=0) && (zw=0) { this .Cursor:=hDC return } VarSetCapacity(mi, 40, 0), NumPut(16+A_PtrSize, mi, "int" ) DllCall( "GetCursorInfo" , "Ptr" ,&mi) bShow:=NumGet(mi, 4, "int" ) hCursor:=NumGet(mi, 8, "Ptr" ) x:=NumGet(mi, 8+A_PtrSize, "int" ) y:=NumGet(mi, 12+A_PtrSize, "int" ) if (!bShow) || (x<zx || y<zy || x>=zx+zw || y>=zy+zh) return VarSetCapacity(ni, 40, 0) DllCall( "GetIconInfo" , "Ptr" ,hCursor, "Ptr" ,&ni) xCenter:=NumGet(ni, 4, "int" ) yCenter:=NumGet(ni, 8, "int" ) hBMMask:=NumGet(ni, (A_PtrSize=8?16:12), "Ptr" ) hBMColor:=NumGet(ni, (A_PtrSize=8?24:16), "Ptr" ) DllCall( "DrawIconEx" , "Ptr" ,hDC , "int" ,x-xCenter-zx, "int" ,y-yCenter-zy, "Ptr" ,hCursor , "int" ,0, "int" ,0, "int" ,0, "int" ,0, "int" ,3) DllCall( "DeleteObject" , "Ptr" ,hBMMask) DllCall( "DeleteObject" , "Ptr" ,hBMColor) } MCode(ByRef code, hex) { local flag:=((hex~= "[^\s\da-fA-F]" )?1:4), hex:=RegExReplace(hex, "[\s=]" ) VarSetCapacity(code, len:=(flag=1 ? StrLen(hex) //4*3+3 : StrLen(hex)//2)) DllCall( "crypt32\CryptStringToBinary" , "Str" ,hex, "uint" ,0 , "uint" ,flag, "Ptr" ,&code, "uint*" ,len, "Ptr" ,0, "Ptr" ,0) DllCall( "VirtualProtect" , "Ptr" ,&code, "Ptr" ,len, "uint" ,0x40, "Ptr*" ,0) } bin2hex(addr, size, base64:=1) { local flag:=(base64 ? 1|0x40000000 : 4|0x0000000C) Loop 2 p:=(A_Index=1 ? 0 : VarSetCapacity(hex,len*2)*0 + &hex) , DllCall( "Crypt32\CryptBinaryToString" , "Ptr" ,addr, "uint" ,size , "uint" ,flag, "Ptr" ,p, "uint*" ,len:=0) return RegExReplace(StrGet(p, len), "\s+" ) } base64tobit(s) { local ListLines % (lls:=A_ListLines)?0:0 Chars:= "0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" SetFormat, IntegerFast, d Loop Parse, Chars if InStr(s, A_LoopField, 1) s:=RegExReplace(s, "[" A_LoopField "]" , ((i:=A_Index-1)>>5&1) . (i>>4&1) . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)) s:=RegExReplace(RegExReplace(s, "[^01]+" ), "10*$" ) ListLines %lls% return s } bit2base64(s) { local ListLines % (lls:=A_ListLines)?0:0 s:=RegExReplace(s, "[^01]+" ) s.=SubStr( "100000" ,1,6-Mod(StrLen(s),6)) s:=RegExReplace(s, ".{6}" , "|$0" ) Chars:= "0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" SetFormat, IntegerFast, d Loop Parse, Chars s:=StrReplace(s, "|" . ((i:=A_Index-1)>>5&1) . (i>>4&1) . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1), A_LoopField) ListLines %lls% return s } ASCII(s) { local if RegExMatch(s, "O)\$(\d+)\.([\w+/]+)" , r) { s:=RegExReplace( this .base64tobit(r[2]), ".{" r[1] "}" , "$0`n" ) s:=StrReplace(StrReplace(s, "0" , "_" ), "1" , "0" ) } else s:= "" return s } ; 可以在脚本的开头用 FindText().PicLib(Text,1) 导入字库, ; 然后使用 FindText().PicLib( "说明文字1|说明文字2|..." ) 获取字库中的数据 PicLib(comments, add_to_Lib:=0, index:=1) { local (!IsObject( this .Lib) && this .Lib:=[]), Lib:= this .Lib , (!Lib.HasKey(index) && Lib[index]:=[]), Lib:=Lib[index] if (add_to_Lib) { re:= "O)<([^>\n]*)>[^$\n]+\$[^" "\r\n]+" Loop Parse, comments, | if RegExMatch(A_LoopField, re, r) { s1:=Trim(r[1]), s2:= "" Loop Parse, s1 s2.= "_" . Format( "{:d}" ,Ord(A_LoopField)) Lib[s2]:=r[0] } Lib[ "" ]:= "" } else { Text:= "" Loop Parse, comments, | { s1:=Trim(A_LoopField), s2:= "" Loop Parse, s1 s2.= "_" . Format( "{:d}" ,Ord(A_LoopField)) if Lib.HasKey(s2) Text.= "|" . Lib[s2] } return Text } } ; 分割字符串为单个文字并获取数据 PicN(Number, index:=1) { return this .PicLib(RegExReplace(Number, "." , "|$0" ), 0, index) } ; 使用 FindText().PicX(Text) 可以将文字分割成多个单字的组合,从而适应间隔变化 ; 但是不能用于“颜色位置二值化”模式, 因为位置是与整体图像相关的 PicX(Text) { local if !RegExMatch(Text, "O)(<[^$\n]+)\$(\d+)\.([\w+/]+)" , r) return Text v:= this .base64tobit(r[3]), Text:= "" c:=StrLen(StrReplace(v, "0" ))<=StrLen(v) //2 ? "1":"0" txt:=RegExReplace(v, ".{" r[2] "}" , "$0`n" ) While InStr(txt,c) { While !(txt~= "m`n)^" c) txt:=RegExReplace(txt, "m`n)^." ) i:=0 While (txt~= "m`n)^.{" i "}" c) i:=Format( "{:d}" ,i+1) v:=RegExReplace(txt, "m`n)^(.{" i "}).*" , "$1" ) txt:=RegExReplace(txt, "m`n)^.{" i "}" ) if (v!= "" ) Text.= "|" r[1] "$" i "." this .bit2base64(v) } return Text } ; 截屏,作为后续操作要用的“上一次的截屏” ScreenShot(x1:=0, y1:=0, x2:=0, y2:=0) { this .FindText(,, x1, y1, x2, y2) } ; 从“上一次的截屏”中快速获取指定坐标的RGB颜色 ; 如果坐标超出了屏幕范围,将返回白色 GetColor(x, y, fmt:=1) { local bits:= this .GetBitsFromScreen(,,,,0,zx,zy,zw,zh) , c:=(x<zx || x>=zx+zw || y<zy || y>=zy+zh || !bits.Scan0) ? 0xFFFFFF : NumGet(bits.Scan0+(y-zy)*bits.Stride+(x-zx)*4, "uint" ) return (fmt ? Format( "0x{:06X}" ,c&0xFFFFFF) : c) } ; 在“上一次的截屏”中设置点的RGB颜色 SetColor(x, y, color:=0x000000) { local bits:= this .GetBitsFromScreen(,,,,0,zx,zy,zw,zh) if !(x<zx || x>=zx+zw || y<zy || y>=zy+zh || !bits.Scan0) NumPut(color, bits.Scan0+(y-zy)*bits.Stride+(x-zx)*4, "uint" ) } ; 根据 FindText() 的结果识别一行文字或验证码 ; offsetX 为两个文字的最大间隔,超过会插入*号 ; offsetY 为两个文字的最大高度差 ; overlapW 用于设置覆盖的宽度 ; 最后返回数组:{text:识别结果, x:结果左上角X, y:结果左上角Y, w:宽, h:高} Ocr(ok, offsetX:=20, offsetY:=20, overlapW:=0) { local ocr_Text:=ocr_X:=ocr_Y:=min_X:=dx:= "" For k,v in ok x:=v.1 , min_X:=(A_Index=1 || x<min_X ? x : min_X) , max_X:=(A_Index=1 || x>max_X ? x : max_X) While (min_X!= "" && min_X<=max_X) { LeftX:= "" For k,v in ok { x:=v.1, y:=v.2 if (x<min_X) || (ocr_Y!= "" && Abs(y-ocr_Y)>offsetY) Continue ; Get the leftmost X coordinates if (LeftX= "" || x<LeftX) LeftX:=x, LeftY:=y, LeftW:=v.3, LeftH:=v.4, LeftOCR:=v.id } if (LeftX= "" ) Break if (ocr_X= "" ) ocr_X:=LeftX, min_Y:=LeftY, max_Y:=LeftY+LeftH ; If the interval exceeds the set value, add "*" to the result ocr_Text.=(ocr_Text!= "" && LeftX>dx ? "*" : "" ) . LeftOCR ; Update for next search min_X:=LeftX+LeftW-(overlapW>LeftW //2 ? LeftW//2:overlapW) , dx:=LeftX+LeftW+offsetX, ocr_Y:=LeftY , (LeftY<min_Y && min_Y:=LeftY) , (LeftY+LeftH>max_Y && max_Y:=LeftY+LeftH) } if (ocr_X= "" ) ocr_X:=0, min_Y:=0, min_X:=0, max_Y:=0 return {text:ocr_Text, x:ocr_X, y:min_Y , w: min_X-ocr_X, h: max_Y-min_Y} } ; 按照从左到右、从上到下的顺序排序FindText()的结果 ; 忽略轻微的Y坐标差距,返回排序后的数组对象 Sort(ok, dy:=10) { local if !IsObject(ok) return ok s:= "" , n:=150000, ypos:=[] For k,v in ok { x:=v.x, y:=v.y, add:=1 For k1,v1 in ypos if Abs(y-v1)<=dy { y:=v1, add:=0 Break } if (add) ypos.Push(y) s.=(y*n+x) "." k "|" } s:=Trim(s, "|" ) Sort, s, N D| ok2:=[] Loop Parse, s, | ok2.Push( ok[StrSplit(A_LoopField, "." )[2]] ) return ok2 } ; 以指定点为中心,按从近到远排序FindText()的结果,返回排序后的数组 Sort2(ok, px, py) { local if !IsObject(ok) return ok s:= "" For k,v in ok s.=((v.x-px)**2+(v.y-py)**2) "." k "|" s:=Trim(s, "|" ) Sort, s, N D| ok2:=[] Loop Parse, s, | ok2.Push( ok[StrSplit(A_LoopField, "." )[2]] ) return ok2 } ; 按指定的查找方向,排序FindText()的结果,返回排序后的数组 Sort3(ok, dir:=1) { local if !IsObject(ok) return ok s:= "" , n:=150000 For k,v in ok x:=v.1, y:=v.2 , s.=(dir=1 ? y*n+x : dir=2 ? y*n-x : dir=3 ? -y*n+x : dir=4 ? -y*n-x : dir=5 ? x*n+y : dir=6 ? x*n-y : dir=7 ? -x*n+y : dir=8 ? -x*n-y : y*n+x) "." k "|" s:=Trim(s, "|" ) Sort, s, N D| ok2:=[] Loop Parse, s, | ok2.Push( ok[StrSplit(A_LoopField, "." )[2]] ) return ok2 } ; 提示某个坐标的位置,或远程控制中当前鼠标的位置 MouseTip(x:= "" , y:= "" , w:=10, h:=10, d:=3) { local if (x= "" ) { VarSetCapacity(pt,16,0), DllCall( "GetCursorPos" , "Ptr" ,&pt) x:=NumGet(pt,0, "uint" ), y:=NumGet(pt,4, "uint" ) } Loop 4 { this .RangeTip(x-w, y-h, 2*w+1, 2*h+1, (A_Index & 1 ? "Red" : "Blue" ), d) Sleep 500 } this .RangeTip() } ; 显示范围的边框,类似于 ToolTip RangeTip(x:= "" , y:= "" , w:= "" , h:= "" , color:= "Red" , d:=3) { local static id:= "" ListLines % (lls:=A_ListLines)?0:0 if (x= "" ) { id:=0 Loop 4 Gui, Range_%A_Index%: Destroy ListLines % lls return } if (!id) { Loop 4 Gui, Range_%A_Index%: +Hwndid +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000 } x:=Floor(x), y:=Floor(y), w:=Floor(w), h:=Floor(h), d:=Floor(d) Loop 4 { i:=A_Index , x1:=(i=2 ? x+w : x-d) , y1:=(i=3 ? y+h : y-d) , w1:=(i=1 || i=3 ? w+2*d : d) , h1:=(i=2 || i=4 ? h+2*d : d) Gui, Range_%i%: Color, %color% Gui, Range_%i%: Show, NA x%x1% y%y1% w%w1% h%h1% } ListLines % lls } ; 用鼠标左右键选取屏幕范围 GetRange(ww:=25, hh:=8, key:= "RButton" ) { local static Gui_Off:= "" , hk if (!Gui_Off) Gui_Off:= this .GetRange.Bind( this , "Off" ) if (ww= "Off" ) return hk:=Trim(A_ThisHotkey, "*" ) ;--------------------- Gui, GetRange_HotkeyIf: Destroy Gui, GetRange_HotkeyIf: -Caption +ToolWindow +E0x80000 Gui, GetRange_HotkeyIf: Show, NA x0 y0 w0 h0, GetRange_HotkeyIf ;--------------------- Hotkey, IfWinExist, GetRange_HotkeyIf keys:=key "|Up|Down|Left|Right" For k,v in StrSplit(keys, "|" ) { KeyWait, %v% Hotkey, *%v%, %Gui_Off%, On UseErrorLevel } KeyWait, Ctrl Hotkey, IfWinExist ;--------------------- Critical % (cri:=A_IsCritical)? "Off" : "Off" CoordMode, Mouse tip:= this .Lang( "s5" ) hk:= "" , oldx:=oldy:= "" , keydown:=0 Loop { Sleep 50 MouseGetPos, x, y if (hk=key) || GetKeyState(key, "P" ) || GetKeyState( "Ctrl" , "P" ) { keydown++ if (keydown=1) MouseGetPos, x1, y1, Bind_ID KeyWait, % key KeyWait, Ctrl hk:= "" if (keydown>1) Break } else if (hk= "Up" ) || GetKeyState( "Up" , "P" ) (hh>1 && hh--), hk:= "" else if (hk= "Down" ) || GetKeyState( "Down" , "P" ) hh++, hk:= "" else if (hk= "Left" ) || GetKeyState( "Left" , "P" ) (ww>1 && ww--), hk:= "" else if (hk= "Right" ) || GetKeyState( "Right" , "P" ) ww++, hk:= "" this .RangeTip((keydown?x1:x)-ww, (keydown?y1:y)-hh , 2*ww+1, 2*hh+1, (A_MSec<500? "Red" : "Blue" )) if (oldx=x && oldy=y) Continue oldx:=x, oldy:=y ToolTip % "x: " (keydown?x1:x) " y: " (keydown?y1:y) "`n" tip } ToolTip this .RangeTip() Hotkey, IfWinExist, GetRange_HotkeyIf For k,v in StrSplit(keys, "|" ) Hotkey, *%v%, %Gui_Off%, Off UseErrorLevel Hotkey, IfWinExist Gui, GetRange_HotkeyIf: Destroy Critical %cri% return [x1-ww, y1-hh, x1+ww, y1+hh, Bind_ID] } ; 截屏到剪贴板或者文件,或者仅获取范围 SnapShot(ScreenShot:=1, key:= "LButton" ) { local static Gui_Off:= "" , hk if (!Gui_Off) Gui_Off:= this .SnapShot.Bind( this , "Off" ) if (ScreenShot= "Off" ) return hk:=Trim(A_ThisHotkey, "*" ) n:=150000, x:=y:=-n, w:=h:=2*n hBM:= this .BitmapFromScreen(x,y,w,h,ScreenShot,zx,zy,zw,zh) ;--------------- Gui, SnapShot_HotkeyIf: Destroy Gui, SnapShot_HotkeyIf: +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000 Gui, SnapShot_HotkeyIf: Margin, 0, 0 Gui, SnapShot_HotkeyIf: Add, Pic, w%zw% h%zh%, % "HBITMAP:*" hBM Gui, SnapShot_HotkeyIf: Show, NA x%zx% y%zy% w%zw% h%zh%, SnapShot_HotkeyIf ;--------------- Gui, SnapShot_Box: Destroy Gui, SnapShot_Box: +Hwndbox_id +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000 Gui, SnapShot_Box: Margin, 0, 0 Gui, SnapShot_Box: Font, s12 For k,v in StrSplit( this .Lang( "s15" ), "|" ) Gui, SnapShot_Box: Add, Button, % (k=1 ? "" : "x+0" ) " Hwndid" , %v% GuiControlGet, p, SnapShot_Box: Pos, %id% box_w:=pX+pW+10, box_h:=pH+10 Gui, SnapShot_Box: Show, Hide, SnapShot_Box ;--------------- Hotkey, IfWinExist, SnapShot_HotkeyIf keys:=key "|RButton|Esc|Up|Down|Left|Right" For k,v in StrSplit(keys, "|" ) { KeyWait, %v% Hotkey, *%v%, %Gui_Off%, On UseErrorLevel } Hotkey, IfWinExist ;--------------- Critical % (cri:=A_IsCritical)? "Off" : "Off" CoordMode, Mouse Loop { ; // For ReTry tip:= this .Lang( "s16" ) hk:= "" , oldx:=oldy:= "" , ok:=0, d:=10, oldt:=0, oldf:= "" x:=y:=w:=h:=0 Loop { Sleep 50 if (hk= "RButton" ) || (hk= "Esc" ) || GetKeyState( "RButton" , "P" ) || GetKeyState( "Esc" , "P" ) Break 2 MouseGetPos, x1, y1 if (oldx=x1 && oldy=y1) Continue oldx:=x1, oldy:=y1 ToolTip % "x: " x1 " y: " y1 " w: 0 h: 0`n" tip } Until (hk=key) || GetKeyState(key, "P" ) Loop { Sleep 50 MouseGetPos, x2, y2 x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x1-x2)+1, h:=Abs(y1-y2)+1 this .RangeTip(x, y, w, h, (A_MSec<500 ? "Red" : "Blue" )) if (oldx=x2 && oldy=y2) Continue oldx:=x2, oldy:=y2 ToolTip % "x: " x " y: " y " w: " w " h: " h "`n" tip } Until !GetKeyState(key, "P" ) hk:= "" Loop { Sleep 50 MouseGetPos, x3, y3 x1:=x, y1:=y, x2:=x+w-1, y2:=y+h-1 , d1:=Abs(x3-x1)<=d, d2:=Abs(x3-x2)<=d , d3:=Abs(y3-y1)<=d, d4:=Abs(y3-y2)<=d , d5:=x3>x1+d && x3<x2-d, d6:=y3>y1+d && y3<y2-d , f:=(d1 && d3 ? 1 : d2 && d3 ? 2 : d1 && d4 ? 3 : d2 && d4 ? 4 : d5 && d3 ? 5 : d5 && d4 ? 6 : d6 && d1 ? 7 : d6 && d2 ? 8 : d5 && d6 ? 9 : 0) if (oldf!=f) oldf:=f, this .SetCursor(f=1 || f=4 ? "SIZENWSE" : f=2 || f=3 ? "SIZENESW" : f=5 || f=6 ? "SIZENS" : f=7 || f=8 ? "SIZEWE" : f=9 ? "SIZEALL" : "ARROW" ) ;-------------- if (hk= "Up" ) || GetKeyState( "Up" , "P" ) hk:= "" , y-- else if (hk= "Down" ) || GetKeyState( "Down" , "P" ) hk:= "" , y++ else if (hk= "Left" ) || GetKeyState( "Left" , "P" ) hk:= "" , x-- else if (hk= "Right" ) || GetKeyState( "Right" , "P" ) hk:= "" , x++ else if (hk= "RButton" ) || (hk= "Esc" ) || GetKeyState( "RButton" , "P" ) || GetKeyState( "Esc" , "P" ) Break else if (hk=key) || GetKeyState(key, "P" ) { MouseGetPos,,, id, mc if (id=box_id) && (mc= "Button1" ) { KeyWait, % key this .RangeTip(), this .SetCursor() Gui, SnapShot_Box: Hide Continue 2 } if (id=box_id) && (ok:=mc= "Button2" ? 2 : mc= "Button4" ? 1:100) Break Gui, SnapShot_Box: Hide ToolTip Loop { Sleep 50 MouseGetPos, x4, y4 x1:=x, y1:=y, x2:=x+w-1, y2:=y+h-1, dx:=x4-x3, dy:=y4-y3 , (f=1 ? (x1+=dx, y1+=dy) : f=2 ? (x2+=dx, y1+=dy) : f=3 ? (x1+=dx, y2+=dy) : f=4 ? (x2+=dx, y2+=dy) : f=5 ? y1+=dy : f=6 ? y2+=dy : f=7 ? x1+=dx : f=8 ? x2+=dx : f=9 ? (x1+=dx, y1+=dy, x2+=dx, y2+=dy) : 0) , (f ? this .RangeTip(Min(x1,x2), Min(y1,y2), Abs(x1-x2)+1, Abs(y1-y2)+1 , (A_MSec<500 ? "Red" : "Blue" )) : 0) } Until !GetKeyState(key, "P" ) hk:= "" , x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x1-x2)+1, h:=Abs(y1-y2)+1 if (f=9) && Abs(dx)<2 && Abs(dy)<2 && (ok:=(-oldt)+(oldt:=A_TickCount)<400) Break } this .RangeTip(x, y, w, h, (A_MSec<500 ? "Red" : "Blue" )) x1:=x+w-box_w, (x1<10 && x1:=10), (x1>zx+zw-box_w && x1:=zx+zw-box_w) , y1:=y+h+10, (y1>zy+zh-box_h && y1:=y-box_h), (y1<10 && y1:=10) Gui, SnapShot_Box: Show, NA x%x1% y%y1% ;------------- if (oldx=x3 && oldy=y3) Continue oldx:=x3, oldy:=y3 ToolTip % "x: " x " y: " y " w: " w " h: " h "`n" tip } Break } ; // For ReTry Hotkey, IfWinExist, SnapShot_HotkeyIf For k,v in StrSplit(keys, "|" ) { KeyWait, %v% Hotkey, *%v%, %Gui_Off%, Off UseErrorLevel } Hotkey, IfWinExist ToolTip this .RangeTip() this .SetCursor() Gui, SnapShot_Box: Destroy Gui, SnapShot_HotkeyIf: Destroy Critical %cri% ;--------------- w:=Min(x+w,zx+zw), x:=Max(x,zx), w-=x h:=Min(y+h,zy+zh), y:=Max(y,zy), h-=y if (ok=1) this .SaveBitmapToFile(0, hBM, x-zx, y-zy, w, h) else if (ok=2) { FileSelectFile, f, S18, %A_Desktop%\1.bmp, SaveAs, Image (*.bmp) this .SaveBitmapToFile(f, hBM, x-zx, y-zy, w, h) } DllCall( "DeleteObject" , "Ptr" ,hBM) return [x, y, x+w-1, y+h-1] } SetCursor(cursor:= "" , args*) { local static init, tab if (!VarSetCapacity(init) && init:= "1" ) { tab:=[], OnExit( this .SetCursor.Bind( this , "" )), this .SetCursor() s:= "ARROW,32512, SIZENWSE,32642, SIZENESW,32643" . ", SIZEWE,32644, SIZENS,32645, SIZEALL,32646" . ", IBEAM,32513, WAIT,32514, CROSS,32515, UPARROW,32516" . ", NO,32648, HAND,32649, APPSTARTING,32650, HELP,32651" For i,v in StrSplit(s, "," , " " ) (i&1) ? (k:=v) : (tab[k]:=DllCall( "CopyImage" , "Ptr" , DllCall( "LoadCursor" , "Ptr" ,0, "Ptr" ,v, "Ptr" ) , "int" ,2, "int" ,0, "int" ,0, "int" ,0, "Ptr" )) } if (cursor!= "" ) && tab.HasKey(cursor) DllCall( "SetSystemCursor" , "Ptr" , DllCall( "CopyImage" , "Ptr" ,tab[cursor] , "int" ,2, "int" ,0, "int" ,0, "int" ,0, "Ptr" ), "int" ,32512) else DllCall( "SystemParametersInfo" , "int" ,0x57, "int" ,0, "Ptr" ,0, "int" ,0) } BitmapFromScreen(ByRef x:=0, ByRef y:=0, ByRef w:=0, ByRef h:=0 , ScreenShot:=1, ByRef zx:=0, ByRef zy:=0, ByRef zw:=0, ByRef zh:=0) { local bits:= this .GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy,zw,zh) if (w<1 || h<1 || !bits.hBM) return hBM:= this .CreateDIBSection(w, h) this .CopyHBM(hBM, 0, 0, bits.hBM, x-zx, y-zy, w, h, 1) return hBM } ; 快速保存截图为BMP文件,可用于调试 ; 如果 file = 0 或 "" ,会保存到剪贴板 SavePic(file:=0, x1:=0, y1:=0, x2:=0, y2:=0, ScreenShot:=1) { local x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2) if (x1=0 && y1=0 && x2=0 && y2=0) n:=150000, x:=y:=-n, w:=h:=2*n else x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 hBM:= this .BitmapFromScreen(x, y, w, h, ScreenShot) this .SaveBitmapToFile(file, hBM) DllCall( "DeleteObject" , "Ptr" ,hBM) } ; 保存图像到文件,如果 file = 0 或者 "" ,保存到剪贴板 ; 参数可以是位图句柄或者文件路径,例如: "c:\a.bmp" SaveBitmapToFile(file, hBM_or_file, x:=0, y:=0, w:=0, h:=0) { local if hBM_or_file is Number hBM_or_file:= "HBITMAP:*" hBM_or_file if !hBM:=DllCall( "CopyImage" , "Ptr" ,LoadPicture(hBM_or_file) , "int" ,0, "int" ,0, "int" ,0, "uint" ,0x2008) return if (file) || (w!=0 && h!=0) { (w=0 || h=0) && this .GetBitmapWH(hBM, w, h) hBM2:= this .CreateDIBSection(w, -h, bpp:=(file ? 24 : 32)) this .CopyHBM(hBM2, 0, 0, hBM, x, y, w, h) DllCall( "DeleteObject" , "Ptr" ,hBM), hBM:=hBM2 } VarSetCapacity(dib, dib_size:=(A_PtrSize=8 ? 104:84)) , DllCall( "GetObject" , "Ptr" ,hBM, "int" ,dib_size, "Ptr" ,&dib) , pbi:=&dib+(bitmap_size:=A_PtrSize=8 ? 32:24) , size:=NumGet(pbi+20, "uint" ), pBits:=NumGet(pbi-A_PtrSize, "Ptr" ) if (!file) { hdib:=DllCall( "GlobalAlloc" , "uint" ,2, "Ptr" ,40+size, "Ptr" ) pdib:=DllCall( "GlobalLock" , "Ptr" ,hdib, "Ptr" ) DllCall( "RtlMoveMemory" , "Ptr" ,pdib, "Ptr" ,pbi, "Ptr" ,40) DllCall( "RtlMoveMemory" , "Ptr" ,pdib+40, "Ptr" ,pBits, "Ptr" ,size) DllCall( "GlobalUnlock" , "Ptr" ,hdib) DllCall( "OpenClipboard" , "Ptr" ,0) DllCall( "EmptyClipboard" ) if !DllCall( "SetClipboardData" , "uint" ,8, "Ptr" ,hdib) DllCall( "GlobalFree" , "Ptr" ,hdib) DllCall( "CloseClipboard" ) } else { if InStr(file, "\") && !FileExist(dir:=RegExReplace(file," [^\\]*$")) Try FileCreateDir, % dir VarSetCapacity(bf, 14, 0), NumPut(0x4D42, bf, "short" ) NumPut(54+size, bf, 2, "uint" ), NumPut(54, bf, 10, "uint" ) f:=FileOpen(file, "w" ), f.RawWrite(bf, 14) , f.RawWrite(pbi+0, 40), f.RawWrite(pBits+0, size), f.Close() } DllCall( "DeleteObject" , "Ptr" ,hBM) } ; 显示保存的图像 ShowPic(file:= "" , show:=1, ByRef x:= "" , ByRef y:= "" , ByRef w:= "" , ByRef h:= "" ) { local if (file= "" ) { this .ShowScreenShot() return } if !(hBM:=LoadPicture(file)) return this .GetBitmapWH(hBM, w, h) bits:= this .GetBitsFromScreen(,,,,0,x,y,zw,zh) this .UpdateBits(bits, x, y, Max(w,zw), Max(h,zh)) this .CopyHBM(bits.hBM, 0, 0, hBM, 0, 0, w, h) DllCall( "DeleteObject" , "Ptr" ,hBM) if (show) this .ShowScreenShot(x, y, x+w-1, y+h-1, 0) } ; 显示内存中的屏幕截图用于调试 ShowScreenShot(x1:=0, y1:=0, x2:=0, y2:=0, ScreenShot:=1) { local static hPic, oldx, oldy, oldw, oldh x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2) if (x1=0 && y1=0 && x2=0 && y2=0) { Gui, FindText_Screen: Destroy return } x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 if !hBM:= this .BitmapFromScreen(x,y,w,h,ScreenShot) return ;--------------- Gui, FindText_Screen: +LastFoundExist IfWinNotExist { ; WS_EX_NOACTIVATE:=0x08000000 Gui, FindText_Screen: +AlwaysOnTop -Caption +ToolWindow -DPIScale +E0x08000000 Gui, FindText_Screen: Margin, 0, 0 Gui, FindText_Screen: Add, Pic, HwndhPic w%w% h%h% Gui, FindText_Screen: Show, NA x%x% y%y% w%w% h%h%, Show Pic oldx:=x, oldy:=y, oldw:=w, oldh:=h } else if (oldx!=x || oldy!=y || oldw!=w || oldh!=h) { if (oldw!=w || oldh!=h) GuiControl, FindText_Screen: Move, %hPic%, w%w% h%h% Gui, FindText_Screen: Show, NA x%x% y%y% w%w% h%h% oldx:=x, oldy:=y, oldw:=w, oldh:=h } this .BitmapToWindow(hPic, 0, 0, hBM, 0, 0, w, h) DllCall( "DeleteObject" , "Ptr" ,hBM) } BitmapToWindow(hwnd, x1, y1, hBM, x2, y2, w, h) { local mDC:=DllCall( "CreateCompatibleDC" , "Ptr" ,0, "Ptr" ) oBM:=DllCall( "SelectObject" , "Ptr" ,mDC, "Ptr" ,hBM, "Ptr" ) hDC:=DllCall( "GetDC" , "Ptr" ,hwnd, "Ptr" ) DllCall( "BitBlt" , "Ptr" ,hDC, "int" ,x1, "int" ,y1, "int" ,w, "int" ,h , "Ptr" ,mDC, "int" ,x2, "int" ,y2, "uint" ,0xCC0020) DllCall( "ReleaseDC" , "Ptr" ,hwnd, "Ptr" ,hDC) DllCall( "SelectObject" , "Ptr" ,mDC, "Ptr" ,oBM) DllCall( "DeleteDC" , "Ptr" ,mDC) } ; 快速获取屏幕图像的搜索文本数据 GetTextFromScreen(x1, y1, x2, y2, Threshold:= "" , ScreenShot:=1, ByRef rx:= "" , ByRef ry:= "" , cut:=1) { local SetBatchLines, % (bch:=A_BatchLines)? "-1" : "-1" x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 bits:= this .GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy) if (w<1 || h<1 || !bits.Scan0) { SetBatchLines, %bch% return } ListLines % (lls:=A_ListLines)?0:0 gray:=[], j:=bits.Stride-w*4, p:=bits.Scan0+(y-zy)*bits.Stride+(x-zx)*4-4-j Loop % h + 0*(k:=0) Loop % w + 0*(p+=j) c:=NumGet(0|p+=4, "uint" ) , gray[++k]:=(((c>>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 if InStr(Threshold, "**" ) { Threshold:=StrReplace(Threshold, "*" ) if (Threshold= "" ) Threshold:=50 s:= "" , sw:=w, w-=2, h-=2, x++, y++ Loop % h + 0*(y1:=0) Loop % w + 0*(y1++) i:=y1*sw+A_Index+1, j:=gray[i]+Threshold , s.=( gray[i-1]>j || gray[i+1]>j || gray[i-sw]>j || gray[i+sw]>j || gray[i-sw-1]>j || gray[i-sw+1]>j || gray[i+sw-1]>j || gray[i+sw+1]>j ) ? "1" : "0" Threshold:= "**" Threshold } else { Threshold:=StrReplace(Threshold, "*" ) if (Threshold= "" ) { pp:=[] Loop 256 pp[A_Index-1]:=0 Loop % w*h pp[gray[A_Index]]++ IP0:=IS0:=0 Loop 256 k:=A_Index-1, IP0+=k*pp[k], IS0+=pp[k] Threshold:=Floor(IP0/IS0) Loop 20 { LastThreshold:=Threshold IP1:=IS1:=0 Loop % LastThreshold+1 k:=A_Index-1, IP1+=k*pp[k], IS1+=pp[k] IP2:=IP0-IP1, IS2:=IS0-IS1 if (IS1!=0 && IS2!=0) Threshold:=Floor((IP1/IS1+IP2/IS2)/2) if (Threshold=LastThreshold) Break } } s:= "" Loop % w*h s.=gray[A_Index]<=Threshold ? "1" : "0" Threshold:= "*" Threshold } ListLines % lls ;-------------------- w:=Format( "{:d}" ,w), CutUp:=CutDown:=0 if (cut=1) { re1:= "(^0{" w "}|^1{" w "})" re2:= "(0{" w "}$|1{" w "}$)" While (s~=re1) s:=RegExReplace(s,re1), CutUp++ While (s~=re2) s:=RegExReplace(s,re2), CutDown++ } rx:=x+w //2, ry:=y+CutUp+(h-CutUp-CutDown)//2 s:= "|<>" Threshold "$" w "." this .bit2base64(s) ;-------------------- SetBatchLines, %bch% return s } ; 等待几秒钟直到屏幕图像改变,需要先调用FindText().ScreenShot() WaitChange(time:=-1, x1:=0, y1:=0, x2:=0, y2:=0) { local hash:= this .GetPicHash(x1, y1, x2, y2, 0) timeout:=A_TickCount+Round(time*1000) Loop { if (hash!= this .GetPicHash(x1, y1, x2, y2, 1)) return 1 if (time>=0 && A_TickCount>=timeout) Break Sleep 10 } return 0 } ; 等待屏幕图像稳定下来 WaitNotChange(time:=1, timeout:=30, x1:=0, y1:=0, x2:=0, y2:=0) { local oldhash:= "" , timeout:=A_TickCount+Round(timeout*1000) Loop { hash:= this .GetPicHash(x1, y1, x2, y2, 1), t:=A_TickCount if (hash!=oldhash) oldhash:=hash, timeout2:=t+Round(time*1000) if (t>=timeout2) return 1 if (t>=timeout) return 0 Sleep 100 } } GetPicHash(x1:=0, y1:=0, x2:=0, y2:=0, ScreenShot:=1) { local static init:=DllCall( "LoadLibrary" , "Str" , "ntdll" , "Ptr" ) x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2) if (x1=0 && y1=0 && x2=0 && y2=0) n:=150000, x:=y:=-n, w:=h:=2*n else x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 bits:= this .GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy), x-=zx, y-=zy if (w<1 || h<1 || !bits.Scan0) return 0 hash:=0, Stride:=bits.Stride, p:=bits.Scan0+(y-1)*Stride+x*4, w*=4 ListLines % (lls:=A_ListLines)?0:0 Loop % h hash:=(hash*31+DllCall( "ntdll\RtlComputeCrc32" , "uint" ,0 , "Ptr" ,p+=Stride, "uint" ,w, "uint" ))&0xFFFFFFFF ListLines % lls return hash } WindowToScreen(ByRef x, ByRef y, x1, y1, id:= "" ) { local if (!id) WinGet, id, ID, A VarSetCapacity(rect, 16, 0) , DllCall( "GetWindowRect" , "Ptr" ,id, "Ptr" ,&rect) , x:=x1+NumGet(rect, "int" ), y:=y1+NumGet(rect,4, "int" ) } ScreenToWindow(ByRef x, ByRef y, x1, y1, id:= "" ) { local this .WindowToScreen(dx, dy, 0, 0, id), x:=x1-dx, y:=y1-dy } ClientToScreen(ByRef x, ByRef y, x1, y1, id:= "" ) { local if (!id) WinGet, id, ID, A VarSetCapacity(pt, 8, 0), NumPut(0, pt, "int64" ) , DllCall( "ClientToScreen" , "Ptr" ,id, "Ptr" ,&pt) , x:=x1+NumGet(pt, "int" ), y:=y1+NumGet(pt,4, "int" ) } ScreenToClient(ByRef x, ByRef y, x1, y1, id:= "" ) { local this .ClientToScreen(dx, dy, 0, 0, id), x:=x1-dx, y:=y1-dy } ; 不像 FindText 总是使用屏幕坐标,它使用与内置命令 ; ImageSearch 一样的 CoordMode 设置的坐标模式 ; 图片文件参数可以使用 "*n *TransRRGGBB-RRGGBB-White... d:\a.bmp" ImageSearch(ByRef rx:= "" , ByRef ry:= "" , x1:=0, y1:=0, x2:=0, y2:=0 , ImageFile:= "" , ScreenShot:=1, FindAll:=0) { local dx:=dy:=0 if (A_CoordModePixel= "Window" ) this .WindowToScreen(dx, dy, 0, 0) else if (A_CoordModePixel= "Client" ) this .ClientToScreen(dx, dy, 0, 0) text:= "" Loop Parse, ImageFile, | if (v:=Trim(A_LoopField))!= "" { text.=InStr(v, "$" ) ? "|" v : "|##" . (RegExMatch(v, "O)(^|\s)\*(\d+)\s" , r) ? Format( "{:06X}" , r[2]<<16|r[2]<<8|r[2]) : "000000" ) . (RegExMatch(v, "Oi)(^|\s)\*Trans([\-\w]+)\s" , r) ? "-" . Trim(r[2], "-" ) : "" ) . "$" . Trim(RegExReplace(v, "(?<=^|\s)\*\S+" )) } x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2) if (x1=0 && y1=0 && x2=0 && y2=0) n:=150000, x1:=y1:=-n, x2:=y2:=n if (ok:= this .FindText(,, x1+dx, y1+dy, x2+dx, y2+dy , 0, 0, text, ScreenShot, FindAll)) { For k,v in ok ; you can use ok:=FindText().ok v.1-=dx, v.2-=dy, v.x-=dx, v.y-=dy rx:=ok[1].1, ry:=ok[1].2, ErrorLevel:=0 return ok } else { rx:=ry:= "" , ErrorLevel:=1 return 0 } } ; 不像 FindText 总是使用屏幕坐标,它使用与内置命令 ; PixelSearch 一样的 CoordMode 设置的坐标模式 ; 颜色参数可以是 "RRGGBB-DRDGDB|RRGGBB-DRDGDB" , Variation 取值 0-255 PixelSearch(ByRef rx:= "" , ByRef ry:= "" , x1:=0, y1:=0, x2:=0, y2:=0 , ColorID:= "" , Variation:=0, ScreenShot:=1, FindAll:=0) { local n:=Floor(Variation), text:=Format( "##{:06X}$0/0" , n<<16|n<<8|n) Loop Parse, ColorID, | if (v:=Trim(A_LoopField))!= "" text.= "/" v return this .ImageSearch(rx, ry, x1, y1, x2, y2, text, ScreenShot, FindAll) } ; 屏幕坐标指示的范围内的某些颜色的像素计数 ; 颜色参数可以是 "RRGGBB-DRDGDB|RRGGBB-DRDGDB" , Variation 取值 0-255 PixelCount(x1:=0, y1:=0, x2:=0, y2:=0, ColorID:= "" , Variation:=0, ScreenShot:=1) { local SetBatchLines, % (bch:=A_BatchLines)? "-1" : "-1" x1:=Floor(x1), y1:=Floor(y1), x2:=Floor(x2), y2:=Floor(y2) if (x1=0 && y1=0 && x2=0 && y2=0) n:=150000, x:=y:=-n, w:=h:=2*n else x:=Min(x1,x2), y:=Min(y1,y2), w:=Abs(x2-x1)+1, h:=Abs(y2-y1)+1 bits:= this .GetBitsFromScreen(x,y,w,h,ScreenShot,zx,zy), x-=zx, y-=zy sum:=0, VarSetCapacity(s1,4), VarSetCapacity(s0,4) , ini:={ bits:bits, ss:0, s1:&s1, s0:&s0 , err1:0, err0:0, allpos_max:0, zoomW:1, zoomH:1 } , n:=Floor(Variation), text:=Format( "##{:06X}$0/0" , n<<16|n<<8|n) Loop Parse, ColorID, | if (v:=Trim(A_LoopField))!= "" text.= "/" v if (w>0 && h>0 && bits.Scan0) && IsObject(j:= this .PicInfo(text)) sum:= this .PicFind(ini, j, 1, x, y, w, h, 0) SetBatchLines, %bch% return sum } Click(x:= "" , y:= "" , other1:= "" , other2:= "" , GoBack:=0) { local CoordMode, Mouse, % (bak:=A_CoordModeMouse)? "Screen" : "Screen" if GoBack MouseGetPos, oldx, oldy MouseMove, x, y, 0 Click % x "," y "," other1 "," other2 if GoBack MouseMove, oldx, oldy, 0 CoordMode, Mouse, %bak% } ; 使用 ControlClick 代替 Click, 使用屏幕坐标,如果用于后台请提供 hwnd ControlClick(x, y, WhichButton:= "" , ClickCount:=1, Opt:= "" , hwnd:= "" ) { local if !hwnd hwnd:=DllCall( "WindowFromPoint" , "int64" ,y<<32|x&0xFFFFFFFF, "Ptr" ) VarSetCapacity(pt,8,0), ScreenX:=x, ScreenY:=y Loop { NumPut(0,pt, "int64" ), DllCall( "ClientToScreen" , "Ptr" ,hwnd, "Ptr" ,&pt) , x:=ScreenX-NumGet(pt, "int" ), y:=ScreenY-NumGet(pt,4, "int" ) , id:=DllCall( "ChildWindowFromPoint" , "Ptr" ,hwnd, "int64" ,y<<32|x, "Ptr" ) if (!id || id=hwnd) Break else hwnd:=id } DetectHiddenWindows, % (bak:=A_DetectHiddenWindows)?1:1 PostMessage, 0x200, 0, y<<16|x,, ahk_id %hwnd% ; WM_MOUSEMOVE SetControlDelay -1 ControlClick, x%x% y%y%, ahk_id %hwnd%,, %WhichButton%, %ClickCount%, NA Pos %Opt% DetectHiddenWindows, % bak } ; 动态运行AHK代码作为新线程 Class Thread { __New(args*) { this .pid:= this .Exec(args*) } __Delete() { Process, Close, % this .pid } Exec(s, Ahk:= "" , args:= "" ) ; required AHK v1.1.34+ and Ahk2Exe Use .exe { local Ahk:=Ahk ? Ahk : A_IsCompiled ? A_ScriptFullPath : A_AhkPath s:= "`nDllCall(" "SetWindowText" "," "Ptr" ",A_ScriptHwnd," "Str" "," "<AHK>" ")`n" . "`nSetBatchLines,-1`n" . s, s:=RegExReplace(s, "\R" , "`r`n" ) Try { shell:=ComObjCreate( "WScript.Shell" ) oExec:=shell.Exec( "" "" Ahk "" " /script /force /CP0 * " args) oExec.StdIn.Write(s) oExec.StdIn.Close(), pid:=oExec.ProcessID } Catch { f:=A_Temp "\~ahk.tmp" s:= "`r`nTry FileDelete " f "`r`n" s Try FileDelete %f% FileAppend %s%, %f% r:= this .Clear.Bind( this ) SetTimer %r%, -3000 Run "%Ahk%" /script /force /CP0 "%f%" %args%,, UseErrorLevel, pid } return pid } Clear() { Try FileDelete % A_Temp "\~ahk.tmp" SetTimer,, Off } } ; FindText().QPC() 用法类似于 A_TickCount QPC() { static f:= "" , c (!f) && DllCall( "QueryPerformanceFrequency" , "Int*" ,f)+(f/=1000) return (!DllCall( "QueryPerformanceCounter" , "Int64*" ,c))*0+(c/f) } ; FindText().ToolTip() 用法类似于 ToolTip ToolTip(s:= "" , x:= "" , y:= "" , num:=1, arg:= "" ) { local static init, ini, timer if (!VarSetCapacity(init) && init:= "1" ) ini:=[], timer:=[] f:= "ToolTip_" . Floor(num) if (s= "" ) { ini[f]:= "" Gui, %f%: Destroy return } ;----------------- r1:=A_CoordModeToolTip r2:=A_CoordModeMouse CoordMode Mouse, Screen MouseGetPos x1, y1 CoordMode Mouse, %r1% MouseGetPos x2, y2 CoordMode Mouse, %r2% (x!= "" && x:= "x" (Floor(x)+x1-x2)) , (y!= "" && y:= "y" (Floor(y)+y1-y2)) , (x= "" && y= "" && x:= "x" (x1+16) " y" (y1+16)) ;----------------- bgcolor:=arg.bgcolor!= "" ? arg.bgcolor : "FAFBFC" color:=arg.color!= "" ? arg.color : "Black" font:=arg.font ? arg.font : "Consolas" size:=arg.size ? arg.size : "10" bold:=arg.bold ? arg.bold : "" trans:=arg.trans!= "" ? arg.trans & 255 : 255 timeout:=arg.timeout!= "" ? arg.timeout : "" ;----------------- r:=bgcolor "|" color "|" font "|" size "|" bold "|" trans "|" s if (!ini.HasKey(f) || ini[f]!=r) { ini[f]:=r Gui, %f%: Destroy ; WS_EX_LAYERED:=0x80000, WS_EX_TRANSPARENT:=0x20 Gui, %f%: +AlwaysOnTop -Caption +ToolWindow -DPIScale +Hwndid +E0x80020 Gui, %f%: Margin, 2, 2 Gui, %f%: Color, %bgcolor% Gui, %f%: Font, c%color% s%size% %bold%, %font% Gui, %f%: Add, Text,, %s% Gui, %f%: Show, Hide, %f% ;------------------ DetectHiddenWindows, % (bak:=A_DetectHiddenWindows)?1:1 WinSet, Transparent, %trans%, ahk_id %id% DetectHiddenWindows, % bak } Gui, %f%: +AlwaysOnTop Gui, %f%: Show, % "NA " x " " y if (timeout) { (!timer.HasKey(f) && timer[f]:= this .ToolTip.Bind( this , "" , "" , "" ,num)) , r:=timer[f] SetTimer, %r%, % -Round(Abs(timeout*1000))-1 } } ; FindText().ObjView() 查看对象的值用于调试 ObjView(obj, keyname:= "" ) { local if IsObject(obj) ; thanks lexikos's type(v) { s:= "" For k,v in obj s.= this .ObjView(v, keyname "[" (StrLen(k)>1000 || [k].GetCapacity(1) ? "" "" k "" "" :k) "]" ) } else s:=keyname ": " (StrLen(obj)>1000 || [obj].GetCapacity(1) ? "" "" obj "" "" :obj) "`n" if (keyname!= "" ) return s ;------------------ Gui, Gui_DeBug: Destroy Gui, Gui_DeBug: +LastFound +AlwaysOnTop Gui, Gui_DeBug: Add, Button, y270 w350 gCancel Default, OK Gui, Gui_DeBug: Add, Edit, xp y10 w350 h250 -Wrap -WantReturn GuiControl, Gui_DeBug:, Edit1, %s% Gui, Gui_DeBug: Show,, Debug view object values DetectHiddenWindows, 0 WinWaitClose, % "ahk_id " WinExist() Gui, Gui_DeBug: Destroy } EditScroll(hEdit, regex:= "" , line:=0, pos:=0) { local ControlGetText, s,, ahk_id %hEdit% pos:=(regex!= "" ) ? InStr(SubStr(s,1,s~=regex), "`n" ,0,0) : (line>1) ? InStr(s, "`n" ,0,1,line-1) : pos SendMessage, 0xB1, pos, pos,, ahk_id %hEdit% SendMessage, 0xB7,,,, ahk_id %hEdit% } ; 从编译后的程序中获取脚本 GetScript() ; thanks TAC109 { local if (!A_IsCompiled) return For i,ahk in [ "#1" , ">AUTOHOTKEY SCRIPT<" ] if (rc:=DllCall( "FindResource" , "Ptr" ,0, "Str" ,ahk, "Ptr" ,10, "Ptr" )) && (sz:=DllCall( "SizeofResource" , "Ptr" ,0, "Ptr" ,rc, "Uint" )) && (pt:=DllCall( "LoadResource" , "Ptr" ,0, "Ptr" ,rc, "Ptr" )) && (pt:=DllCall( "LockResource" , "Ptr" ,pt, "Ptr" )) && (DllCall( "VirtualProtect" , "Ptr" ,pt, "Ptr" ,sz, "UInt" ,0x4, "UInt*" ,0)) && (InStr(StrGet(pt, 20, "utf-8" ), "<COMPILER" )) return this .FormatScript(StrGet(pt, sz, "utf-8" )) } FormatScript(s, space:= "" , tab:= " " ) { local ListLines % (lls:=A_ListLines)?0:0 VarSetCapacity(ss, StrLen(s)*2), n:=0, w:=StrLen(tab) , space2:=StrReplace(Format( "{:020d}" ,0), "0" , tab) Loop Parse, s, `n, `r { v:=Trim(A_LoopField), n2:=n if RegExMatch(v, "O)^\s*[{}][\s{}]*|\{\s*$|\{\s+;" , r) n+=w*(StrLen(RegExReplace(r[0], "[^{]" )) -StrLen(RegExReplace(r[0], "[^}]" ))), n2:=Min(n,n2) ss.=Space . SubStr(space2,1,n2) . v . "`r`n" } ListLines %lls% return SubStr(ss,1,-2) } ; 获取最后添加的Gui控件的Hwnd,前提是 Gui +LastFound LastCtrl() { local WinGet, s, ControlListHwnd return SubStr(s, InStr(s, "`n" ,0,0)+1) } ; 隐藏窗口,前提是 Gui +LastFound Hide(id:= "" ) { if (id ? WinExist( "ahk_id " id) : WinExist()) { WinMinimize WinHide ToolTip DetectHiddenWindows, 0 WinWaitClose, % "ahk_id " WinExist() } } ;==== Optional GUI interface ==== Gui(cmd, arg1:= "" , args*) { local static local bch, cri, lls ListLines, % InStr( "MouseMove|ToolTipOff" ,cmd)?0:A_ListLines static init if (!VarSetCapacity(init) && init:= "1" ) { SavePicDir:=A_Temp "\Ahk_ScreenShot\" Gui_ := this .Gui.Bind( this ) Gui_G := this .Gui.Bind( this , "G" ) Gui_Run := this .Gui.Bind( this , "Run" ) Gui_Off := this .Gui.Bind( this , "Off" ) Gui_Show := this .Gui.Bind( this , "Show" ) Gui_KeyDown := this .Gui.Bind( this , "KeyDown" ) Gui_LButtonDown := this .Gui.Bind( this , "LButtonDown" ) Gui_RButtonDown := this .Gui.Bind( this , "RButtonDown" ) Gui_MouseMove := this .Gui.Bind( this , "MouseMove" ) Gui_ScreenShot := this .Gui.Bind( this , "ScreenShot" ) Gui_ShowPic := this .Gui.Bind( this , "ShowPic" ) Gui_Slider := this .Gui.Bind( this , "Slider" ) Gui_ToolTip := this .Gui.Bind( this , "ToolTip" ) Gui_ToolTipOff := this .Gui.Bind( this , "ToolTipOff" ) Gui_SaveScr := this .Gui.Bind( this , "SaveScr" ) bch:=A_BatchLines, cri:=A_IsCritical Critical #NoEnv Lang:= this .Lang(,1), Tip_Text:= this .Lang(,2) %Gui_%( "MakeCaptureWindow" ) %Gui_%( "MakeMainWindow" ) OnMessage(0x100, Gui_KeyDown) OnMessage(0x201, Gui_LButtonDown) OnMessage(0x204, Gui_RButtonDown) OnMessage(0x200, Gui_MouseMove) Menu, Tray, Add Menu, Tray, Add, % Lang[ "s1" ], %Gui_Show% if (!A_IsCompiled && A_LineFile=A_ScriptFullPath) { Menu, Tray, Default, % Lang[ "s1" ] Menu, Tray, Click, 1 Menu, Tray, Icon, Shell32.dll, 23 } Critical, %cri% SetBatchLines, %bch% Gui, New, +LastFound Gui, Destroy ;------------------- Pics:=PrevControl:=x:=y:=oldx:=oldy:= "" , oldt:=0 } Switch cmd { Case "Off" : return hk:=Trim(A_ThisHotkey, "*" ) Case "G" : id:= this .LastCtrl() GuiControl, +g, %id%, %Gui_Run% return Case "Run" : Critical %Gui_%(A_GuiControl) return Case "Show" : Gui, FindText_Main: Default Gui, Show, % arg1 ? "Center" : "" GuiControl, Focus, %hscr% return Case "Cancel" , "Cancel2" : WinHide return Case "MakeCaptureWindow" : WindowColor:= "0xDDEEFF" Gui, FindText_Capture: New Gui, +LastFound +AlwaysOnTop -DPIScale Gui, Margin, 15, 15 Gui, Color, %WindowColor% Gui, Font, s12, Verdana Gui, Add, Tab3, vMyTab1 -Wrap, % Lang[ "s18" ] Gui, Tab, 1 C_:=[], nW:=71, nH:=25, w:=h:=12, pW:=nW*(w+1)-1, pH:=(nH+1)*(h+1)-1 Gui, -Theme ListLines % (lls:=A_ListLines)?0:0 Loop % nW*(nH+1) { i:=A_Index, j:=i=1 ? "Section" : Mod(i,nW)=1 ? "xs y+1" : "x+1" Gui, Add, Progress, %j% w%w% h%h% Hwndid -E0x20000 Smooth C_[i]:=id } ListLines % lls Gui, +Theme Gui, Add, Slider, xs w%pW% vMySlider1 +Center Page20 Line10 NoTicks AltSubmit %Gui_G%() Gui, Add, Slider, ys h%pH% vMySlider2 +Center Page20 Line10 NoTicks AltSubmit +Vertical %Gui_G%() Gui, Tab, 2 pW-=120+15 Gui, Add, Text, w%pW% h%pH% Hwndparent_id +Border Section Gui, Add, Slider, xs w%pW% vMySlider3 +Center Page20 Line10 NoTicks AltSubmit %Gui_G%() Gui, Add, Slider, ys h%pH% vMySlider4 +Center Page20 Line10 NoTicks AltSubmit +Vertical %Gui_G%() Gui, Add, ListBox, % "ys w120 h200 vSelectBox AltSubmit 0x100" %Gui_G%() Gui, Add, Button, y+0 wp vClearAll, % Lang[ "ClearAll" ] %Gui_G%() Gui, Add, Button, y+0 wp vOpenDir, % Lang[ "OpenDir" ] %Gui_G%() Gui, Add, Button, y+0 wp vLoadPic, % Lang[ "LoadPic" ] %Gui_G%() Gui, Add, Button, y+0 wp vSavePic, % Lang[ "SavePic" ] %Gui_G%() Gui, Tab MySlider1:=MySlider2:=MySlider3:=MySlider4:=dx:=dy:=0 ;-------------- Gui, Add, Button, xm Hidden Section, % Lang[ "Auto" ] GuiControlGet, p, Pos, % this .LastCtrl() w:=Round(pW*0.75), i:=Round(w*3+15+pW*0.5-w*1.5) Gui, Add, Button, xm+%i% yp w%w% hp -Wrap vRepU, % Lang[ "RepU" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutU, % Lang[ "CutU" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutU3, % Lang[ "CutU3" ] %Gui_G%() Gui, Add, Button, xm wp hp -Wrap vRepL, % Lang[ "RepL" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutL, % Lang[ "CutL" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutL3, % Lang[ "CutL3" ] %Gui_G%() Gui, Add, Button, x+15 w%pW% hp -Wrap vAuto, % Lang[ "Auto" ] %Gui_G%() Gui, Add, Button, x+15 w%w% hp -Wrap vRepR, % Lang[ "RepR" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutR, % Lang[ "CutR" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutR3, % Lang[ "CutR3" ] %Gui_G%() Gui, Add, Button, xm+%i% wp hp -Wrap vRepD, % Lang[ "RepD" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutD, % Lang[ "CutD" ] %Gui_G%() Gui, Add, Button, x+0 wp hp -Wrap vCutD3, % Lang[ "CutD3" ] %Gui_G%() ;-------------- Gui, Add, Text, x+60 ys+3 Section, % Lang[ "SelGray" ] Gui, Add, Edit, x+3 yp-3 w60 vSelGray ReadOnly Gui, Add, Text, x+15 ys, % Lang[ "SelColor" ] Gui, Add, Edit, x+3 yp-3 w150 vSelColor ReadOnly Gui, Add, Text, x+15 ys, % Lang[ "SelR" ] Gui, Add, Edit, x+3 yp-3 w60 vSelR ReadOnly Gui, Add, Text, x+5 ys, % Lang[ "SelG" ] Gui, Add, Edit, x+3 yp-3 w60 vSelG ReadOnly Gui, Add, Text, x+5 ys, % Lang[ "SelB" ] Gui, Add, Edit, x+3 yp-3 w60 vSelB ReadOnly ;-------------- x:=w*6+pW+15*4 Gui, Add, Tab3, x%x% y+15 -Wrap, % Lang[ "s2" ] Gui, Tab, 1 Gui, Add, Text, x+15 y+15, % Lang[ "Threshold" ] Gui, Add, Edit, x+15 w100 vThreshold Gui, Add, Button, x+15 yp-3 vGray2Two, % Lang[ "Gray2Two" ] %Gui_G%() Gui, Tab, 2 Gui, Add, Text, x+15 y+15, % Lang[ "GrayDiff" ] Gui, Add, Edit, x+15 w100 vGrayDiff, 50 Gui, Add, Button, x+15 yp-3 vGrayDiff2Two, % Lang[ "GrayDiff2Two" ] %Gui_G%() Gui, Tab, 3 Gui, Add, Text, x+15 y+15, % Lang[ "Similar1" ] " 0" Gui, Add, Slider, x+0 w120 vSimilar1 +Center Page1 NoTicks ToolTip, 100 %Gui_G%() Gui, Add, Text, x+0, 100 Gui, Add, Button, x+15 yp-3 vColor2Two, % Lang[ "Color2Two" ] %Gui_G%() Gui, Tab, 4 Gui, Add, Text, x+15 y+15, % Lang[ "Similar2" ] " 0" Gui, Add, Slider, x+0 w120 vSimilar2 +Center Page1 NoTicks ToolTip, 100 %Gui_G%() Gui, Add, Text, x+0, 100 Gui, Add, Button, x+15 yp-3 vColorPos2Two, % Lang[ "ColorPos2Two" ] %Gui_G%() Gui, Tab, 5 Gui, Add, Text, x+10 y+15, % Lang[ "DiffR" ] Gui, Add, Edit, x+5 w80 vDiffR Limit3 Gui, Add, UpDown, vdR Range0-255 Wrap Gui, Add, Text, x+5, % Lang[ "DiffG" ] Gui, Add, Edit, x+5 w80 vDiffG Limit3 Gui, Add, UpDown, vdG Range0-255 Wrap Gui, Add, Text, x+5, % Lang[ "DiffB" ] Gui, Add, Edit, x+5 w80 vDiffB Limit3 Gui, Add, UpDown, vdB Range0-255 Wrap Gui, Add, Button, x+15 yp-3 vColorDiff2Two, % Lang[ "ColorDiff2Two" ] %Gui_G%() Gui, Tab, 6 Gui, Add, Text, x+10 y+15, % Lang[ "DiffRGB" ] Gui, Add, Edit, x+5 w80 vDiffRGB Limit3 Gui, Add, UpDown, vdRGB Range0-255 Wrap Gui, Add, Checkbox, x+15 yp+5 vMultiColor, % Lang[ "MultiColor" ] %Gui_G%() Gui, Add, Button, x+15 yp-5 vUndo, % Lang[ "Undo" ] %Gui_G%() Gui, Tab ;-------------- Gui, Add, Button, xm vReset, % Lang[ "Reset" ] %Gui_G%() Gui, Add, Checkbox, x+15 yp+5 vModify, % Lang[ "Modify" ] %Gui_G%() Gui, Add, Text, x+30, % Lang[ "Comment" ] Gui, Add, Edit, x+5 yp-2 w150 vComment Gui, Add, Button, x+10 yp-3 vSplitAdd, % Lang[ "SplitAdd" ] %Gui_G%() Gui, Add, Button, x+10 vAllAdd, % Lang[ "AllAdd" ] %Gui_G%() Gui, Add, Button, x+30 wp vOK, % Lang[ "OK" ] %Gui_G%() Gui, Add, Button, x+10 wp vCancel, % Lang[ "Cancel" ] %Gui_G%() Gui, Add, Button, xm vBind0, % Lang[ "Bind0" ] %Gui_G%() Gui, Add, Button, x+10 vBind1, % Lang[ "Bind1" ] %Gui_G%() Gui, Add, Button, x+10 vBind2, % Lang[ "Bind2" ] %Gui_G%() Gui, Add, Button, x+10 vBind3, % Lang[ "Bind3" ] %Gui_G%() Gui, Add, Button, x+10 vBind4, % Lang[ "Bind4" ] %Gui_G%() Gui, Add, Button, x+60 vSavePic2, % Lang[ "SavePic2" ] %Gui_G%() Gui, Show, Hide, % Lang[ "s3" ] ;-------------------- Gui, FindText_SubPic: New ; Don't use +AlwaysOnTop Gui, +Parent%parent_id% -Caption +ToolWindow -DPIScale Gui, Margin, 0, 0 Gui, Color, White Gui, Add, Pic, x0 y0 w500 h500 +Hwndsub_hpic Gui, Show, Hide, SubPic return Case "MakeMainWindow" : Gui, FindText_Main: New Gui, +LastFound +AlwaysOnTop -DPIScale Gui, Margin, 15, 10 Gui, Color, %WindowColor% Gui, Font, s12, Verdana Gui, Add, Text, xm, % Lang[ "NowHotkey" ] Gui, Add, Edit, x+5 w160 vNowHotkey ReadOnly Gui, Add, Hotkey, x+5 w160 vSetHotkey1 s:= "F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|LWin|MButton" . "|ScrollLock|CapsLock|Ins|Esc|BS|Del|Tab|Home|End|PgUp|PgDn" . "|NumpadDot|NumpadSub|NumpadAdd|NumpadDiv|NumpadMult" Gui, Add, DDL, x+5 w160 vSetHotkey2, % s Gui, Add, Button, x+15 vApply, % Lang[ "Apply" ] %Gui_G%() Gui, Add, GroupBox, xm y+0 w280 h55 vMyGroup cBlack Gui, Add, Text, xp+15 yp+20 Section, % Lang[ "Myww" ] ": " Gui, Add, Text, x+0 w80, % nW //2 Gui, Add, UpDown, vMyww Range1-100, % nW //2 Gui, Add, Text, x+15 ys, % Lang[ "Myhh" ] ": " Gui, Add, Text, x+0 w80, % nH //2 Gui, Add, UpDown, vMyhh Range1-100, % nH //2 GuiControlGet, p, Pos, % this .LastCtrl() GuiControl, Move, MyGroup, % "w" (pX+pW) " h" (pH+30) Gui, Add, Checkbox, x+100 ys vAddFunc, % Lang[ "AddFunc" ] " FindText()" GuiControlGet, p, Pos, % this .LastCtrl() pW:=pX+pW-15, pW:=(pW<720?720:pW), w:=pW //5 Gui, Add, Button, xm y+18 w%w% vCutL2, % Lang[ "CutL2" ] %Gui_G%() Gui, Add, Button, x+0 wp vCutR2, % Lang[ "CutR2" ] %Gui_G%() Gui, Add, Button, x+0 wp vCutU2, % Lang[ "CutU2" ] %Gui_G%() Gui, Add, Button, x+0 wp vCutD2, % Lang[ "CutD2" ] %Gui_G%() Gui, Add, Button, x+0 wp vUpdate, % Lang[ "Update" ] %Gui_G%() Gui, Font, s6 bold, Verdana Gui, Add, Edit, xm y+10 w%pW% h260 vMyPic -Wrap HScroll Gui, Font, s12 norm, Verdana w:=pW //3 Gui, Add, Button, xm w%w% vCapture, % Lang[ "Capture" ] %Gui_G%() Gui, Add, Button, x+0 wp vTest, % Lang[ "Test" ] %Gui_G%() Gui, Add, Button, x+0 wp vCopy, % Lang[ "Copy" ] %Gui_G%() Gui, Add, Button, xm y+0 wp vCaptureS, % Lang[ "CaptureS" ] %Gui_G%() Gui, Add, Button, x+0 wp vGetRange, % Lang[ "GetRange" ] %Gui_G%() Gui, Add, Button, x+0 wp vGetOffset, % Lang[ "GetOffset" ] %Gui_G%() Gui, Add, Edit, xm y+10 w130 hp vClipText Gui, Add, Button, x+0 vPaste, % Lang[ "Paste" ] %Gui_G%() Gui, Add, Button, x+0 vTestClip, % Lang[ "TestClip" ] %Gui_G%() Gui, Add, Button, x+0 vGetClipOffset, % Lang[ "GetClipOffset" ] %Gui_G%() r:=pW GuiControlGet, p, Pos, % this .LastCtrl() w:=((r+15)-(pX+pW)) //2, pW:=r Gui, Add, Edit, x+0 w%w% hp vOffset Gui, Add, Button, x+0 wp vCopyOffset, % Lang[ "CopyOffset" ] %Gui_G%() Gui, Font, cBlue Gui, Add, Edit, xm w%pW% h250 vscr Hwndhscr -Wrap HScroll Gui, Show, Hide, % Lang[ "s4" ] %Gui_%( "LoadScr" ) OnExit(Gui_SaveScr) return Case "LoadScr" : f:=A_Temp "\~scr1.tmp" FileRead, s, %f% GuiControl, FindText_Main:, scr, %s% return Case "SaveScr" : f:=A_Temp "\~scr1.tmp" GuiControlGet, s, FindText_Main:, scr FileDelete, %f% FileAppend, %s%, %f% return Case "Capture" , "CaptureS" : Gui, FindText_Main: +Hwndid if WinExist()!=id return this .GetRange() this .Hide() if !InStr(cmd, "CaptureS" ) { Gui, FindText_Main: Default GuiControlGet, w,, Myww GuiControlGet, h,, Myhh p:= this .GetRange(w, h) sx:=p[1], sy:=p[2], sw:=p[3]-p[1]+1, sh:=p[4]-p[2]+1 , Bind_ID:=p[5], bind_mode:= "" Gui, FindText_Capture: Default GuiControl, Choose, MyTab1, 1 } else { sx:=0, sy:=0, sw:=1, sh:=1, Bind_ID:=WinExist( "A" ), bind_mode:= "" Gui, FindText_Capture: Default GuiControl, Choose, MyTab1, 2 } this .ScreenShot() n:=150000, x:=y:=-n, w:=h:=2*n hBM:= this .BitmapFromScreen(x,y,w,h,0) %Gui_%( "CaptureUpdate" ) %Gui_%( "PicUpdate" ) Names:=[], s:= "" Loop Files, % SavePicDir "*.bmp" Names.Push(v:=A_LoopFileFullPath), s.= "|" RegExReplace(v, "i)^.*\\|\.bmp$" ) GuiControl,, SelectBox, % "|" Trim(s, "|" ) ;---------------------- Loop Parse, % "SelGray|SelColor|SelR|SelG|SelB|Threshold|Comment" , | GuiControl,, % A_LoopField GuiControl,, Modify, % Modify:=0 GuiControl,, MultiColor, % MultiColor:=0 GuiControl,, GrayDiff, 50 GuiControl, Focus, Gray2Two GuiControl, +Default, Gray2Two Gui, +LastFound Gui, Show, Center Event:=Result:= "" DetectHiddenWindows, 0 Critical, Off WinWaitClose, % "ahk_id " WinExist() Critical ToolTip Gui, FindText_SubPic: Hide Gui, FindText_Main: Default ;-------------------------------- if (bind_mode!= "" ) { WinGetTitle, tt, ahk_id %Bind_ID% WinGetClass, tc, ahk_id %Bind_ID% tt:=Trim(SubStr(tt,1,30) (tc ? " ahk_class " tc: "" )) tt:=StrReplace(RegExReplace(tt, "[;``]" , "``$0" ), "" "" , "" "" "" ) Result:= "`nSetTitleMatchMode 2`nid:=WinExist(" "" tt "" ")" . "`nFindText().BindWindow(id" (bind_mode=0 ? "" : "," bind_mode) . ") `; " Lang[ "s6" ] " FindText().BindWindow(0)`n`n" Result } if (Event= "OK" ) { if (!A_IsCompiled) FileRead, s, %A_LineFile% else s:= this .GetScript() re:= "Oi)\n\s*FindText[^\n]+args\*[\s\S]*?Script_End[(){\s]+}" if RegExMatch(s, re, r) s:= "`n;==========`n" r[0] "`n" GuiControl,, scr, % Result "`n" s GuiControl,, MyPic, % Trim( this .ASCII(Result), "`n" ) } else if (Event= "SplitAdd" ) || (Event= "AllAdd" ) { GuiControlGet, s,, scr r:=SubStr(s, 1, InStr(s, "=FindText(" )) i:=j:=0, re:= "<[^>\n]*>[^$\n]+\$[^" "\r\n]+" While j:=RegExMatch(r, re,, j+1) i:=InStr(r, "`n" , 0, j) GuiControl,, scr, % SubStr(s,1,i) . Result . SubStr(s,i+1) GuiControl,, MyPic, % Trim( this .ASCII(Result), "`n" ) } if (Event) && RegExMatch(Result, "O)\$\d+\.[\w+/]{1,100}" , r) this .EditScroll(hscr, "\Q" r[0] "\E" ) Event:=Result:=s:= "" ;---------------------- %Gui_Show%() return Case "CaptureUpdate" : nX:=sx, nY:=sy, nW:=sw, nH:=sh bits:= this .GetBitsFromScreen(nX,nY,nW,nH,0,zx,zy) cors:=[], show:=[], ascii:=[] , SelPos:=bg:=color:= "" , dx:=dy:=CutLeft:=CutRight:=CutUp:=CutDown:=0 ListLines % (lls:=A_ListLines)?0:0 if (nW>0 && nH>0 && bits.Scan0) { j:=bits.Stride-nW*4, p:=bits.Scan0+(nY-zy)*bits.Stride+(nX-zx)*4-4-j Loop % nH + 0*(k:=0) Loop % nW + 0*(p+=j) show[++k]:=1, cors[k]:=NumGet(0|p+=4, "uint" ) } Loop % 25 + 0*(ty:=dy-1)*(k:=0) Loop % 71 + 0*(tx:=dx-1)*(ty++) { c:=(++tx)<nW && ty<nH ? cors[ty*nW+tx+1] : WindowColor SendMessage,0x2001,0,(c&0xFF)<<16|c&0xFF00|(c>>16)&0xFF,,% "ahk_id " C_[++k] } Loop % 71 + 0*(k:=71*25) SendMessage,0x2001,0,0xAAFFFF,,% "ahk_id " C_[++k] ListLines % lls Gui, FindText_Capture: Default GuiControl, % "Enable" (nW>71), MySlider1 GuiControl, % "Enable" (nH>25), MySlider2 GuiControl,, MySlider1, % MySlider1:=0 GuiControl,, MySlider2, % MySlider2:=0 return Case "PicUpdate" : GuiControl, FindText_SubPic:, %sub_hpic%, % "*w0 *h0 HBITMAP:" hBM Gui, FindText_Capture: Default GuiControl,, MySlider3, % MySlider3:=0 GuiControl,, MySlider4, % MySlider4:=0 %Gui_%( "MySlider3" ) return Case "MySlider3" , "MySlider4" : GuiControlGet, p, FindText_Capture: Pos, % parent_id w:=pW, h:=pH GuiControlGet, p, FindText_SubPic: Pos, % sub_hpic x:=pW>w ? -Round((pW-w)*MySlider3/100) : 0 y:=pH>h ? -Round((pH-h)*MySlider4/100) : 0 Gui, FindText_SubPic: Show, NA x%x% y%y% w%pW% h%pH% return Case "Reset" : %Gui_%( "CaptureUpdate" ) return Case "LoadPic" : Gui, FindText_Capture: +OwnDialogs f:=arg1 if (f= "" ) { if !FileExist(SavePicDir) FileCreateDir, % SavePicDir f:=SavePicDir "*.bmp" Loop Files, % f f:=A_LoopFileFullPath FileSelectFile, f,, %f%, Select Picture } if !FileExist(f) { MsgBox, 4096, Tip, % Lang[ "s17" ] " !" , 1 return } this .ShowPic(f, 0, sx, sy, sw, sh) hBM:= this .BitmapFromScreen(sx, sy, sw, sh, 0) sw:=Min(sw,200), sh:=Min(sh,200) %Gui_%( "CaptureUpdate" ) %Gui_%( "PicUpdate" ) return Case "SavePic" : Gui, FindText_Capture: Default GuiControlGet, SelectBox f:=Names[SelectBox] Gui, Hide this .ShowPic(f) pos:= this .SnapShot(0) %Gui_%( "ScreenShot" , pos[1] "|" pos[2] "|" pos[3] "|" pos[4] "|0" ) this .ShowPic() return Case "SelectBox" : Gui, FindText_Capture: Default GuiControlGet, SelectBox f:=Names[SelectBox] if (f!= "" ) %Gui_%( "LoadPic" , f) return Case "ClearAll" : Gui, FindText_Capture: Hide FileDelete, % SavePicDir "*.bmp" return Case "OpenDir" : Gui, FindText_Capture: Minimize if !FileExist(SavePicDir) FileCreateDir, % SavePicDir Run, % SavePicDir return Case "GetRange" : Gui, FindText_Main: +LastFound this .Hide() p:= this .SnapShot(), v:=p[1] ", " p[2] ", " p[3] ", " p[4] Gui, FindText_Main: Default GuiControlGet, s,, scr re:= "i)(=FindText\([^\n]*?)([^(,\n]*,){4}([^,\n]*,[^,\n]*,[^,\n]*Text)" if SubStr(s,1,s~= "i)\n\s*FindText[^\n]+args\*" )~=re { s:=RegExReplace(s, re, "$1 " v ",$3" ,, 1) GuiControl,, scr, %s% } GuiControl,, Offset, %v% %Gui_Show%() return Case "Test" , "TestClip" : Gui, FindText_Main: Default Gui, +LastFound this .Hide() ;---------------------- if (cmd= "Test" ) GuiControlGet, s,, scr else GuiControlGet, s,, ClipText if (cmd= "Test" ) && InStr(s, "MCode(" ) { s:= "`n#NoEnv`nMenu, Tray, Click, 1`n" s "`nExitApp`n" Thread1:= new this .Thread(s) DetectHiddenWindows, 1 WinWait, % "ahk_class AutoHotkey ahk_pid " Thread1.pid,, 3 if (!ErrorLevel) WinWaitClose,,, 30 ; Thread1:= "" ; kill the Thread } else { t:=A_TickCount, v:=X:=Y:= "" if RegExMatch(s, "O)<[^>\n]*>[^$\n]+\$[^" "\r\n]+" , r) v:= this .FindText(X, Y, 0,0,0,0, 0,0, r[0]) r:=StrSplit(Lang[ "s8" ] "||||" , "|" ) MsgBox, 4096, Tip, % r[1] ":`t" (IsObject(v)?v.Length():v) "`n`n" . r[2] ":`t" (A_TickCount-t) " " r[3] "`n`n" . r[4] ":`t" X ", " Y "`n`n" . r[5] ":`t<" (IsObject(v)?v[1].id: "" ) ">" , 3 Try For i,j in v if (i<=2) this .MouseTip(j.x, j.y) v:= "" , Clipboard:=X "," Y } ;---------------------- %Gui_Show%() return Case "GetOffset" , "GetClipOffset" : Gui, FindText_Main: Hide p:= this .GetRange() Gui, FindText_Main: Default if (cmd= "GetOffset" ) GuiControlGet, s,, scr else GuiControlGet, s,, ClipText if RegExMatch(s, "O)<[^>\n]*>[^$\n]+\$[^" "\r\n]+" , r) && this .FindText(X, Y, 0,0,0,0, 0,0, r[0]) { r:=StrReplace( "X+" ((p[1]+p[3]) //2-X) . ", Y+" ((p[2]+p[4]) //2-Y), "+-", "-") if (cmd= "GetOffset" ) { re:= "i)(\(\)\.\w*Click\w*\()[^,\n]*,[^,)\n]*" if SubStr(s,1,s~= "i)\n\s*FindText[^\n]+args\*" )~=re s:=RegExReplace(s, re, "$1" r,, 1) GuiControl,, scr, %s% } GuiControl,, Offset, %r% } s:= "" , %Gui_Show%() return Case "Paste" : s:=Clipboard if RegExMatch(s, "O)\|?<[^>\n]*>[^$\n]+\$[^" "\r\n]+" , r) { Gui, FindText_Main: Default GuiControl,, ClipText, % r[0] GuiControl,, MyPic, % Trim( this .ASCII(r[0]), "`n" ) } return Case "CopyOffset" : GuiControlGet, s, FindText_Main:, Offset Clipboard:=s return Case "Copy" : Gui, FindText_Main: Default ControlGet, s, Selected,,, ahk_id %hscr% if (s= "" ) { GuiControlGet, s,, scr GuiControlGet, r,, AddFunc if (r != 1) s:=RegExReplace(s, "i)\n\s*FindText[^\n]+args\*[\s\S]*" ) , s:=RegExReplace(s, "i)\n; ok:=FindText[\s\S]*" ) , s:=SubStr(s, (s~= "i)\n[ \t]*Text" )) } Clipboard:=RegExReplace(s, "\R" , "`r`n" ) GuiControl, Focus, scr return Case "Apply" : Gui, FindText_Main: Default GuiControlGet, NowHotkey GuiControlGet, SetHotkey1 GuiControlGet, SetHotkey2 if (NowHotkey!= "" ) Hotkey, *%NowHotkey%,, Off UseErrorLevel k:=SetHotkey1!= "" ? SetHotkey1 : SetHotkey2 if (k!= "" ) Hotkey, *%k%, %Gui_ScreenShot%, On UseErrorLevel GuiControl,, NowHotkey, %k% GuiControl,, SetHotkey1 GuiControl, Choose, SetHotkey2, 0 return Case "ScreenShot" : Critical if !FileExist(SavePicDir) FileCreateDir, % SavePicDir Loop f:=SavePicDir . Format( "{:03d}.bmp" ,A_Index) Until !FileExist(f) this .SavePic(f, StrSplit(arg1, "|" )*) CoordMode, ToolTip this .ToolTip(Lang[ "s9" ],, 0,, { bgcolor: "Yellow" , color: "Red" , size:48, bold: "bold" , trans:200, timeout:0.2 }) return Case "Bind0" , "Bind1" , "Bind2" , "Bind3" , "Bind4" : this .BindWindow(Bind_ID, bind_mode:=SubStr(cmd,5)) n:=150000, x:=y:=-n, w:=h:=2*n hBM:= this .BitmapFromScreen(x,y,w,h,1) %Gui_%( "PicUpdate" ) GuiControl, FindText_Capture: Choose, MyTab1, 2 this .BindWindow(0) return Case "MySlider1" , "MySlider2" : SetTimer, %Gui_Slider%, -10 return Case "Slider" : Critical dx:=nW>71 ? Round((nW-71)*MySlider1/100) : 0 dy:=nH>25 ? Round((nH-25)*MySlider2/100) : 0 if (oldx=dx && oldy=dy) return ListLines % (lls:=A_ListLines)?0:0 Loop % 25 + 0*(ty:=dy-1)*(k:=0) Loop % 71 + 0*(tx:=dx-1)*(ty++) { c:=((++tx)>=nW || ty>=nH || !show[i:=ty*nW+tx+1] ? WindowColor : bg= "" ? cors[i] : ascii[i] ? 0 : 0xFFFFFF) SendMessage,0x2001,0,(c&0xFF)<<16|c&0xFF00|(c>>16)&0xFF,,% "ahk_id " C_[++k] } Loop % 71*(oldx!=dx) + 0*(i:=nW*nH+dx)*(k:=71*25) SendMessage,0x2001,0,(show[++i]?0x0000FF:0xAAFFFF),,% "ahk_id " C_[++k] ListLines % lls oldx:=dx, oldy:=dy return Case "RepColor" : show[k]:=1, c:=(bg= "" ? cors[k] : ascii[k] ? 0 : 0xFFFFFF) if (tx:=Mod(k-1,nW)-dx)>=0 && tx<71 && (ty:=(k-1) //nW-dy)>=0 && ty<25 SendMessage,0x2001,0,(c&0xFF)<<16|c&0xFF00|(c>>16)&0xFF,,% "ahk_id " C_[ty*71+tx+1] return Case "CutColor" : show[k]:=0, c:=WindowColor if (tx:=Mod(k-1,nW)-dx)>=0 && tx<71 && (ty:=(k-1) //nW-dy)>=0 && ty<25 SendMessage,0x2001,0,(c&0xFF)<<16|c&0xFF00|(c>>16)&0xFF,,% "ahk_id " C_[ty*71+tx+1] return Case "RepL" : if (CutLeft<=0) || (bg!= "" && InStr(color, "**" ) && CutLeft=1) return k:=CutLeft-nW, CutLeft-- Loop %nH% k+=nW, (A_Index>CutUp && A_Index<nH+1-CutDown && %Gui_%( "RepColor" )) return Case "CutL" : if (CutLeft+CutRight>=nW) return CutLeft++, k:=CutLeft-nW Loop %nH% k+=nW, (A_Index>CutUp && A_Index<nH+1-CutDown && %Gui_%( "CutColor" )) return Case "CutL3" : Loop 3 %Gui_%( "CutL" ) return Case "RepR" : if (CutRight<=0) || (bg!= "" && InStr(color, "**" ) && CutRight=1) return k:=1-CutRight, CutRight-- Loop %nH% k+=nW, (A_Index>CutUp && A_Index<nH+1-CutDown && %Gui_%( "RepColor" )) return Case "CutR" : if (CutLeft+CutRight>=nW) return CutRight++, k:=1-CutRight Loop %nH% k+=nW, (A_Index>CutUp && A_Index<nH+1-CutDown && %Gui_%( "CutColor" )) return Case "CutR3" : Loop 3 %Gui_%( "CutR" ) return Case "RepU" : if (CutUp<=0) || (bg!= "" && InStr(color, "**" ) && CutUp=1) return k:=(CutUp-1)*nW, CutUp-- Loop %nW% k++, (A_Index>CutLeft && A_Index<nW+1-CutRight && %Gui_%( "RepColor" )) return Case "CutU" : if (CutUp+CutDown>=nH) return CutUp++, k:=(CutUp-1)*nW Loop %nW% k++, (A_Index>CutLeft && A_Index<nW+1-CutRight && %Gui_%( "CutColor" )) return Case "CutU3" : Loop 3 %Gui_%( "CutU" ) return Case "RepD" : if (CutDown<=0) || (bg!= "" && InStr(color, "**" ) && CutDown=1) return k:=(nH-CutDown)*nW, CutDown-- Loop %nW% k++, (A_Index>CutLeft && A_Index<nW+1-CutRight && %Gui_%( "RepColor" )) return Case "CutD" : if (CutUp+CutDown>=nH) return CutDown++, k:=(nH-CutDown)*nW Loop %nW% k++, (A_Index>CutLeft && A_Index<nW+1-CutRight && %Gui_%( "CutColor" )) return Case "CutD3" : Loop 3 %Gui_%( "CutD" ) return Case "Gray2Two" : ListLines % (lls:=A_ListLines)?0:0 gray:=[], k:=0 Loop % nW*nH gray[++k]:=((((c:=cors[k])>>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 Gui, FindText_Capture: Default GuiControl, Focus, Threshold GuiControlGet, Threshold if (Threshold= "" ) { pp:=[] Loop 256 pp[A_Index-1]:=0 Loop % nW*nH if (show[A_Index]) pp[gray[A_Index]]++ IP0:=IS0:=0 Loop 256 k:=A_Index-1, IP0+=k*pp[k], IS0+=pp[k] Threshold:=Floor(IP0/IS0) Loop 20 { LastThreshold:=Threshold IP1:=IS1:=0 Loop % LastThreshold+1 k:=A_Index-1, IP1+=k*pp[k], IS1+=pp[k] IP2:=IP0-IP1, IS2:=IS0-IS1 if (IS1!=0 && IS2!=0) Threshold:=Floor((IP1/IS1+IP2/IS2)/2) if (Threshold=LastThreshold) Break } GuiControl,, Threshold, %Threshold% } Threshold:=Round(Threshold) color:= "*" Threshold, k:=i:=0 Loop % nW*nH ascii[++k]:=v:=(gray[k]<=Threshold) , (show[k] && i:=(v?i+1:i-1)) bg:=(i>0 ? "1" : "0" ), %Gui_%( "BlackWhite" ) ListLines % lls return Case "GrayDiff2Two" : Gui, FindText_Capture: Default GuiControlGet, GrayDiff if (GrayDiff= "" ) { Gui, +OwnDialogs MsgBox, 4096, Tip, % Lang[ "s11" ] " !" , 1 return } ListLines % (lls:=A_ListLines)?0:0 gray:=[], k:=0 Loop % nW*nH gray[++k]:=((((c:=cors[k])>>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 if (CutLeft=0) %Gui_%( "CutL" ) if (CutRight=0) %Gui_%( "CutR" ) if (CutUp=0) %Gui_%( "CutU" ) if (CutDown=0) %Gui_%( "CutD" ) GrayDiff:=Round(GrayDiff) color:= "**" GrayDiff, k:=i:=0 Loop % nW*nH j:=gray[++k]+GrayDiff , ascii[k]:=v:=( gray[k-1]>j || gray[k+1]>j || gray[k-nW]>j || gray[k+nW]>j || gray[k-nW-1]>j || gray[k-nW+1]>j || gray[k+nW-1]>j || gray[k+nW+1]>j ) , (show[k] && i:=(v?i+1:i-1)) bg:=(i>0 ? "1" : "0" ), %Gui_%( "BlackWhite" ) ListLines % lls return Case "Color2Two" , "ColorPos2Two" : Gui, FindText_Capture: Default GuiControlGet, c,, SelColor if (c= "" ) { Gui, +OwnDialogs MsgBox, 4096, Tip, % Lang[ "s12" ] " !" , 1 return } UsePos:=(cmd= "ColorPos2Two" ) GuiControlGet, n,, % UsePos ? "Similar2" : "Similar1" n:=Round(n/100,2), color:=StrReplace(c, "0x" ) "@" n , n:=Floor(4606*255*255*(1-n)*(1-n)), k:=i:=0 , rr:=(c>>16)&0xFF, gg:=(c>>8)&0xFF, bb:=c&0xFF ListLines % (lls:=A_ListLines)?0:0 Loop % nW*nH c:=cors[++k], r:=((c>>16)&0xFF)-rr , g:=((c>>8)&0xFF)-gg, b:=(c&0xFF)-bb, j:=r+rr+rr , ascii[k]:=v:=((1024+j)*r*r+2048*g*g+(1534-j)*b*b<=n) , (show[k] && i:=(v?i+1:i-1)) bg:=(i>0 ? "1" : "0" ), %Gui_%( "BlackWhite" ) ListLines % lls return Case "ColorDiff2Two" : Gui, FindText_Capture: Default GuiControlGet, c,, SelColor if (c= "" ) { Gui, +OwnDialogs MsgBox, 4096, Tip, % Lang[ "s12" ] " !" , 1 return } GuiControlGet, dR GuiControlGet, dG GuiControlGet, dB rr:=(c>>16)&0xFF, gg:=(c>>8)&0xFF, bb:=c&0xFF , n:=Format( "{:06X}" ,(dR<<16)|(dG<<8)|dB) , color:=StrReplace(c "-" n, "0x" ), k:=i:=0 ListLines % (lls:=A_ListLines)?0:0 Loop % nW*nH c:=cors[++k], r:=(c>>16)&0xFF, g:=(c>>8)&0xFF, b:=c&0xFF , ascii[k]:=v:=(Abs(r-rr)<=dR && Abs(g-gg)<=dG && Abs(b-bb)<=dB) , (show[k] && i:=(v?i+1:i-1)) bg:=(i>0 ? "1" : "0" ), %Gui_%( "BlackWhite" ) ListLines % lls return Case "BlackWhite" : Loop % 25 + 0*(ty:=dy-1)*(k:=0) Loop % 71 + 0*(tx:=dx-1)*(ty++) if (k++)*0 + (++tx)<nW && ty<nH && show[i:=ty*nW+tx+1] SendMessage,0x2001,0,(ascii[i] ? 0 : 0xFFFFFF),,% "ahk_id " C_[k] return Case "Modify" : Gui, FindText_Capture: Default GuiControlGet, Modify return Case "MultiColor" : Gui, FindText_Capture: Default GuiControlGet, MultiColor Result:= "" ToolTip return Case "Undo" : Result:=RegExReplace(Result, ",[^/]+/[^/]+/[^/]+$" ) ToolTip % Trim(Result, "/," ) return Case "Similar1" : Gui, FindText_Capture: Default GuiControl,, Similar2, %Similar1% return Case "Similar2" : Gui, FindText_Capture: Default GuiControl,, Similar1, %Similar2% return Case "GetTxt" : txt:= "" if (bg= "" ) return k:=0 ListLines % (lls:=A_ListLines)?0:0 Loop %nH% { v:= "" Loop %nW% v.=!show[++k] ? "" : ascii[k] ? "1" : "0" txt.=v= "" ? "" : v "`n" } ListLines % lls return Case "Auto" : %Gui_%( "GetTxt" ) if (txt= "" ) { Gui, FindText_Capture: +OwnDialogs MsgBox, 4096, Tip, % Lang[ "s13" ] " !" , 1 return } While InStr(txt,bg) { if (txt~= "^" bg "+\n" ) txt:=RegExReplace(txt, "^" bg "+\n" ), %Gui_%( "CutU" ) else if !(txt~= "m`n)[^\n" bg "]$" ) txt:=RegExReplace(txt, "m`n)" bg "$" ), %Gui_%( "CutR" ) else if (txt~= "\n" bg "+\n$" ) txt:=RegExReplace(txt, "\n\K" bg "+\n$" ), %Gui_%( "CutD" ) else if !(txt~= "m`n)^[^\n" bg "]" ) txt:=RegExReplace(txt, "m`n)^" bg), %Gui_%( "CutL" ) else Break } txt:= "" return Case "OK" , "SplitAdd" , "AllAdd" : Gui, FindText_Capture: Default Gui, +OwnDialogs %Gui_%( "GetTxt" ) if (txt= "" ) && (!MultiColor) { MsgBox, 4096, Tip, % Lang[ "s13" ] " !" , 1 return } if InStr(color, "@" ) && (UsePos) && (!MultiColor) { r:=StrSplit(color, "@" ) k:=i:=j:=0 ListLines % (lls:=A_ListLines)?0:0 Loop % nW*nH { if (!show[++k]) Continue i++ if (k=SelPos) { j:=i Break } } ListLines % lls if (j=0) { MsgBox, 4096, Tip, % Lang[ "s12" ] " !" , 1 return } color:= "#" j "@" r[2] } GuiControlGet, Comment if (cmd= "SplitAdd" ) && (!MultiColor) { if InStr(color, "#" ) { MsgBox, 4096, Tip, % Lang[ "s14" ], 3 return } bg:=StrLen(StrReplace(txt, "0" )) > StrLen(StrReplace(txt, "1" )) ? "1" : "0" s:= "" , i:=0, k:=nW*nH+1+CutLeft Loop % w:=nW-CutLeft-CutRight { i++ if (!show[k++] && A_Index<w) Continue i:=Format( "{:d}" ,i) v:=RegExReplace(txt, "m`n)^(.{" i "}).*" , "$1" ) txt:=RegExReplace(txt, "m`n)^.{" i "}" ), i:=0 While InStr(v,bg) { if (v~= "^" bg "+\n" ) v:=RegExReplace(v, "^" bg "+\n" ) else if !(v~= "m`n)[^\n" bg "]$" ) v:=RegExReplace(v, "m`n)" bg "$" ) else if (v~= "\n" bg "+\n$" ) v:=RegExReplace(v, "\n\K" bg "+\n$" ) else if !(v~= "m`n)^[^\n" bg "]" ) v:=RegExReplace(v, "m`n)^" bg) else Break } if (v!= "" ) { v:=Format( "{:d}" ,InStr(v, "`n" )-1) "." this .bit2base64(v) s.= "`nText.=" "|<" SubStr(Comment,1,1) ">" color "$" v "" "`n" Comment:=SubStr(Comment, 2) } } Event:=cmd, Result:=s Gui, Hide return } if (!MultiColor) txt:=Format( "{:d}" ,InStr(txt, "`n" )-1) "." this .bit2base64(txt) else { GuiControlGet, n,, dRGB color:=Format( "##{:06X}" , n<<16|n<<8|n) r:=StrSplit(Trim(StrReplace(Result, "," , "/" ), "/" ), "/" ) , x:=r[1], y:=r[2], s:= "" , i:=1 SetFormat, IntegerFast, d Loop % r.Length() //3 s.= "," (r[i++]-x) "/" (r[i++]-y) "/" r[i++] txt:=SubStr(s,2) } s:= "`nText.=" "|<" Comment ">" color "$" txt "" "`n" if (cmd= "AllAdd" ) { Event:=cmd, Result:=s Gui, Hide return } x:=nX+CutLeft+(nW-CutLeft-CutRight) //2 y:=nY+CutUp+(nH-CutUp-CutDown) //2 s:=StrReplace(s, "Text.=" , "Text:=" ), r:=StrSplit(Lang[ "s8" ] "|||||||" , "|" ) s:= "`; #Include <FindText>`n" . "`nt1:=A_TickCount, Text:=X:=Y:=" "" "`n" s . "`nif (ok:=FindText(X, Y, " x "-150000, " . y "-150000, " x "+150000, " y "+150000, 0, 0, Text))" . "`n{" . "`n `; FindText()." . "Click(" . "X, Y, " "L" ")" . "`n}`n" . "`n`; ok:=FindText(X:=" "wait" ", Y:=3, 0,0,0,0,0,0,Text) `; " r[7] . "`n`; ok:=FindText(X:=" "wait0" ", Y:=-1, 0,0,0,0,0,0,Text) `; " r[8] . "`n`nMsgBox, 4096, Tip, `% " "" r[1] ":``t" " (IsObject(ok)?ok.Length():ok)" . "`n . " "``n``n" r[2] ":``t" " (A_TickCount-t1) " " " r[3] "" "" . "`n . " "``n``n" r[4] ":``t" " X " ", " " Y" . "`n . " "``n``n" r[5] ":``t<" " (IsObject(ok)?ok[1].id:" "" ") " ">" "`n" . "`nTry For i,v in ok `; ok " r[6] " ok:=FindText().ok" . "`n if (i<=2)" . "`n FindText().MouseTip(ok[i].x, ok[i].y)`n" Event:=cmd, Result:=s Gui, Hide return Case "SavePic2" : x:=nX+CutLeft, w:=nW-CutLeft-CutRight y:=nY+CutUp, h:=nH-CutUp-CutDown %Gui_%( "ScreenShot" , x "|" y "|" (x+w-1) "|" (y+h-1) "|0" ) return Case "ShowPic" : Gui, FindText_Main: Default ControlGet, i, CurrentLine,,, ahk_id %hscr% ControlGet, s, Line, %i%,, ahk_id %hscr% GuiControl,, MyPic, % Trim( this .ASCII(s), "`n" ) return Case "KeyDown" : Critical if (A_Gui!= "FindText_Main" ) return if (A_GuiControl= "scr" ) SetTimer, %Gui_ShowPic%, -150 else if (A_GuiControl= "ClipText" ) { GuiControlGet, s, FindText_Main:, ClipText GuiControl, FindText_Main:, MyPic, % Trim( this .ASCII(s), "`n" ) } return Case "LButtonDown" : Critical if (A_Gui= "FindText_SubPic" ) { ; Two windows trigger two messages if (A_TickCount-oldt)<100 || !GetKeyState( "LButton" , "P" ) return CoordMode, Mouse MouseGetPos, k1, k2 ListLines % (lls:=A_ListLines)?0:0 Loop { Sleep 50 MouseGetPos, k3, k4 this .RangeTip(Min(k1,k3), Min(k2,k4) , Abs(k1-k3), Abs(k2-k4), (A_MSec<500 ? "Red" : "Blue" )) } Until !GetKeyState( "LButton" , "P" ) ListLines % lls this .RangeTip() this .GetBitsFromScreen(,,,,0,zx,zy) this .ClientToScreen(sx, sy, 0, 0, sub_hpic) if Abs(k1-k3)+Abs(k2-k4)>4 sx:=zx+Min(k1,k3)-sx, sy:=zy+Min(k2,k4)-sy , sw:=Abs(k1-k3), sh:=Abs(k2-k4) else sx:=zx+k1-sx-71 //2, sy:=zy+k2-sy-25//2, sw:=71, sh:=25 %Gui_%( "CaptureUpdate" ) GuiControl, FindText_Capture: Choose, MyTab1, 1 oldt:=A_TickCount return } if (A_Gui!= "FindText_Capture" ) return %Gui_%( "KeyDown" ) MouseGetPos,,,, k2, 2 k1:=0 ListLines % (lls:=A_ListLines)?0:0 For k_,v_ in C_ if (v_=k2) && (k1:=k_) Break ListLines % lls if (k1<1) return else if (k1>71*25) { k3:=nW*nH+dx+(k1-71*25) SendMessage,0x2001,0,((show[k3]:=!show[k3])?0x0000FF:0xAAFFFF),,% "ahk_id " k2 return } k2:=Mod(k1-1,71)+dx, k3:=(k1-1) //71+dy if (k2<0 || k2>=nW || k3<0 || k3>=nH) return k1:=k, k:=k3*nW+k2+1, k4:=c if (MultiColor && show[k]) { c:= "," (nX+k2) "/" (nY+k3) "/" . Format( "{:06X}" ,cors[k]&0xFFFFFF) , Result.=InStr(Result,c) ? "" :c ToolTip % Trim(Result, "/," ) } if (Modify && bg!= "" && show[k]) { c:=((ascii[k]:=!ascii[k]) ? 0 : 0xFFFFFF) if (tx:=Mod(k-1,nW)-dx)>=0 && tx<71 && (ty:=(k-1) //nW-dy)>=0 && ty<25 SendMessage,0x2001,0,c,,% "ahk_id " C_[ty*71+tx+1] } else { c:=cors[k], SelPos:=k Gui, FindText_Capture: Default GuiControl,, SelGray, % (((c>>16)&0xFF)*38+((c>>8)&0xFF)*75+(c&0xFF)*15)>>7 GuiControl,, SelColor, % Format( "0x{:06X}" ,c&0xFFFFFF) GuiControl,, SelR, % (c>>16)&0xFF GuiControl,, SelG, % (c>>8)&0xFF GuiControl,, SelB, % c&0xFF } k:=k1, c:=k4 return Case "RButtonDown" : Critical if (A_Gui!= "FindText_SubPic" ) return ; Two windows trigger two messages if (A_TickCount-oldt)<100 || !GetKeyState( "RButton" , "P" ) return r:=[x, y, w, h, pX, pY, pW, pH] CoordMode, Mouse MouseGetPos, k1, k2 WinGetPos, x, y, w, h, ahk_id %parent_id% WinGetPos, pX, pY, pW, pH, ahk_id %sub_hpic% pX-=x, pY-=y, pW-=w, pH-=h ListLines % (lls:=A_ListLines)?0:0 Loop { Sleep 10 MouseGetPos, k3, k4 x:=Min(Max(pX+k3-k1,-pW),0), y:=Min(Max(pY+k4-k2,-pH),0) Gui, FindText_SubPic: Show, NA x%x% y%y% GuiControl, FindText_Capture:, MySlider3, % Round(-x/pW*100) GuiControl, FindText_Capture:, MySlider4, % Round(-y/pH*100) } Until !GetKeyState( "RButton" , "P" ) ListLines % lls x:=r[1], y:=r[2], w:=r[3], h:=r[4], pX:=r[5], pY:=r[6], pW:=r[7], pH:=r[8] oldt:=A_TickCount return Case "MouseMove" : if (PrevControl!=A_GuiControl) { ToolTip PrevControl:=A_GuiControl if (Gui_ToolTip) { SetTimer, %Gui_ToolTip%, % PrevControl ? -500 : "Off" SetTimer, %Gui_ToolTipOff%, % PrevControl ? -5500 : "Off" } } return Case "ToolTip" : MouseGetPos,,, _TT IfWinExist, ahk_id %_TT% ahk_class AutoHotkeyGUI ToolTip % Tip_Text[PrevControl] return Case "ToolTipOff" : ToolTip return Case "CutL2" , "CutR2" , "CutU2" , "CutD2" : Gui, FindText_Main: Default GuiControlGet, s,, MyPic s:=Trim(s, "`n" ) . "`n" , v:=SubStr(cmd,4,1) if (v= "U" ) s:=RegExReplace(s, "^[^\n]+\n" ) else if (v= "D" ) s:=RegExReplace(s, "[^\n]+\n$" ) else if (v= "L" ) s:=RegExReplace(s, "m`n)^[^\n]" ) else if (v= "R" ) s:=RegExReplace(s, "m`n)[^\n]$" ) GuiControl,, MyPic, % Trim(s, "`n" ) return Case "Update" : Gui, FindText_Main: Default GuiControl, Focus, scr ControlGet, i, CurrentLine,,, ahk_id %hscr% ControlGet, s, Line, %i%,, ahk_id %hscr% if !RegExMatch(s, "O)(<[^>\n]*>[^$\n]+\$)\d+\.[\w+/]+" , r) return GuiControlGet, v,, MyPic v:=Trim(v, "`n" ) . "`n" , w:=Format( "{:d}" ,InStr(v, "`n" )-1) v:=StrReplace(StrReplace(v, "0" , "1" ), "_" , "0" ) s:=StrReplace(s, r[0], r[1] . w "." this .bit2base64(v)) v:= "{End}{Shift Down}{Home}{Shift Up}{Del}" ControlSend,, %v%, ahk_id %hscr% Control, EditPaste, %s%,, ahk_id %hscr% ControlSend,, {Home}, ahk_id %hscr% return } } Lang(text:= "" , getLang:=0) { local static init, Lang1, Lang2 if (!VarSetCapacity(init) && init:= "1" ) { s:=" ( Myww = 宽度 = 调整抓图范围的宽度 Myhh = 高度 = 调整抓图范围的高度 AddFunc = 附加 = 复制时带 FindText() 函数 NowHotkey = 截屏热键 = 当前的截屏热键 SetHotkey1 = = 第一优先级的截屏热键 SetHotkey2 = = 第二优先级的截屏热键 Apply = 应用 = 应用新的截屏热键 CutU2 = 上删 = 裁剪下面编辑框中文字的上边缘 CutL2 = 左删 = 裁剪下面编辑框中文字的左边缘 CutR2 = 右删 = 裁剪下面编辑框中文字的右边缘 CutD2 = 下删 = 裁剪下面编辑框中文字的下边缘 Update = 更新 = 更新下面编辑框中文字到代码行中 GetRange = 获取屏幕范围 = 获取屏幕范围并替换代码中的范围参数 GetOffset = 获取相对坐标 = 获取相对图像位置的偏移坐标并替换代码中的坐标 GetClipOffset = 获取相对坐标2 = 获取相对左边编辑框的图像的偏移坐标 Capture = 抓图 = 开始屏幕抓图 CaptureS = 截屏抓图 = 先恢复某个截屏到屏幕上再开始抓图 Test = 测试 = 测试生成的代码是否可以查找成功 TestClip = 测试2 = 测试左边文本框中的文字,结果复制到剪贴板 Paste = 粘贴 = 粘贴剪贴板的文字数据 CopyOffset = 复制2 = 复制左边的偏移坐标到剪贴板 Copy = 复制 = 复制代码到剪贴板 Reset = 重读 = 重新读取原来的彩色图像 SplitAdd = 分割添加 = 使用黄色的标签来分割图像为单个的图像数据,添加到旧代码中 AllAdd = 整体添加 = 将文字数据整体添加到旧代码中 Gray2Two = 灰度阈值二值化 = 灰度小于阈值的为黑色其余白色 GrayDiff2Two = 灰度差值二值化 = 某点与周围灰度之差大于差值的为黑色其余白色 Color2Two = 颜色相似二值化 = 指定颜色及相似色为黑色其余白色 ColorPos2Two = 颜色位置二值化 = 指定颜色及相似色为黑色其余白色,但是记录该色的位置 ColorDiff2Two = 颜色分量二值化 = 指定颜色及颜色分量小于允许值的为黑色其余白色 SelGray = 灰度 = 选定颜色的灰度值 (0-255) SelColor = 颜色 = 选定颜色的RGB颜色值 SelR = 红 = 选定颜色的红色分量 SelG = 绿 = 选定颜色的绿色分量 SelB = 蓝 = 选定颜色的蓝色分量 RepU = -上 = 撤销裁剪上边缘1个像素 CutU = 上 = 裁剪上边缘1个像素 CutU3 = 上3 = 裁剪上边缘3个像素 RepL = -左 = 撤销裁剪左边缘1个像素 CutL = 左 = 裁剪左边缘1个像素 CutL3 = 左3 = 裁剪左边缘3个像素 Auto = 自动 = 二值化之后自动裁剪空白边缘 RepR = -右 = 撤销裁剪右边缘1个像素 CutR = 右 = 裁剪右边缘1个像素 CutR3 = 右3 = 裁剪右边缘3个像素 RepD = -下 = 撤销裁剪下边缘1个像素 CutD = 下 = 裁剪下边缘1个像素 CutD3 = 下3 = 裁剪下边缘3个像素 Modify = 修改 = 二值化后可以用鼠标在预览区点击手动修改黑白点 MultiColor = 多色查找 = 鼠标选择多种颜色,之后点击“确定”按钮 Undo = 撤销 = 撤销上一次选择的颜色 Comment = 识别文字 = 识别文本 (包含在<>中),分割添加时也会分解成单个文字 Threshold = 灰度阈值 = 灰度阈值 (0-255) GrayDiff = 灰度差值 = 灰度差值 (0-255) Similar1 = 相似度 = 与选定颜色的相似度 Similar2 = 相似度 = 与选定颜色的相似度 DiffR = 红 = 红色分量允许的偏差 (0-255) DiffG = 绿 = 绿色分量允许的偏差 (0-255) DiffB = 蓝 = 蓝色分量允许的偏差 (0-255) DiffRGB = 红/绿/蓝 = 多色查找时各分量允许的偏差 (0-255) Bind0 = 绑定窗口1 = 绑定窗口使用GetDCEx()获取后台窗口图像 Bind1 = 绑定窗口1+ = 绑定窗口使用GetDCEx()并修改窗口透明度 Bind2 = 绑定窗口2 = 绑定窗口使用PrintWindow()获取后台窗口图像 Bind3 = 绑定窗口2+ = 绑定窗口使用PrintWindow()并修改窗口透明度 Bind4 = 绑定窗口3 = 绑定窗口使用PrintWindow(,,3)获取后台窗口图像 OK = 确定 = 生成全新的代码替换旧代码 OK2 = 确定 = 恢复截屏到屏幕然后再抓图 Cancel = 取消 = 关闭窗口不做任何事 Cancel2 = 取消 = 关闭窗口不做任何事 ClearAll = 清空 = 清空所有保存的截图 OpenDir = 打开目录 = 打开保存屏幕截图的目录 SavePic = 保存图片 = 选择一个范围保存为图片 SavePic2 = 保存图片 = 将修剪后的原始图像保存为图片 LoadPic = 载入图片 = 载入一张图片作为抓取的图像 ClipText = = 显示粘贴的文字数据 Offset = = 显示“获取相对坐标2”或者“获取屏幕范围”的结果 SelectBox = = 选择截图显示到屏幕左上角 s1 = FindText s2 = 灰度阈值|灰度差值|颜色相似|颜色位置|颜色分量|多色查找 s3 = 图像二值化及分割 s4 = 抓图生成字库及找字代码 s5 = 方向键微调选框\n先点击右键一次\n把鼠标移开\n再点击右键一次 s6 = 解绑窗口使用 s7 = 请用左键拖动范围\n坐标复制到剪贴板 s8 = 找到|时间|毫秒|位置|结果|值可以这样获取|等待3秒等图像出现|无限等待等图像消失 s9 = 截屏成功 s10 = 鼠标位置|穿透显示绑定窗口\n点击右键完成抓图 s11 = 请先设定灰度差值 s12 = 请先选择核心颜色 s13 = 请先将图像二值化 s14 = 不能用于颜色位置二值化模式, 因为分割后会导致位置错误 s15 = 重选|到文件|仅范围|到剪贴板 s16 = 左键拖动选择范围,方向键微调\n右键或ESC仅范围,双击到剪贴板 s17 = 请先保存图片 s18 = 捕获|截图 )" Lang1:=[], Lang2:=[] loop Parse, s, `n, `r if InStr(v:=A_LoopField, "=" ) r:=StrSplit(StrReplace(v "==" , "\n" , "`n" ), "=" , "`t " ) , Lang1[r[1]]:=r[2], Lang2[r[1]]:=r[3] } return getLang=1 ? Lang1 : getLang=2 ? Lang2 : Lang1[text] } } ; // Class End Script_End() { } ; ---------------------------------------------------------------------------------------------------------------------- ; Name ..........: TrayIcon library ; Description ...: Provide some useful functions to deal with Tray icons. ; AHK Version ...: AHK_L 1.1.22.02 x32/64 Unicode ; Code from .....: Sean (http: //www.autohotkey.com/forum/viewtopic.php?t=17314) ; Author ........: Cyruz (http: //ciroprincipe.info) (http://ahkscript.org/boards/viewtopic.php?f=6&t=1229) ; Mod from ......: Fanatic Guru - Cyruz ; License .......: WTFPL - http: //www.wtfpl.net/txt/copying/ ; Version Date ..: 2019.03.12 ; Upd.20160120 ..: Fanatic Guru - Went through all the data types in the DLL and NumGet and matched them up to MSDN ; ...............: which fixed idCmd. ; Upd.20160308 ..: Fanatic Guru - Fix for Windows 10 NotifyIconOverflowWindow. ; Upd.20180313 ..: Fanatic Guru - Fix problem with "VirtualFreeEx" pointed out by nnnik. ; Upd.20180313 ..: Fanatic Guru - Additional fix for previous Windows 10 NotifyIconOverflowWindow fix breaking non ; ...............: hidden icons. ; Upd.20190312 ..: Cyruz - Added TrayIcon_Set, code merged and refactored. ; ---------------------------------------------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------------------------------------------- ; Function ......: TrayIcon_GetInfo ; Description ...: Get a series of useful information about tray icons. ; Parameters ....: sExeName - The exe for which we are searching the tray icon data. Leave it empty to receive data for ; ...............: all tray icons. ; Return ........: oTrayInfo - An array of objects containing tray icons data. Any entry is structured like this : ; ...............: oTrayInfo[A_Index].idx - 0 based tray icon index. ; ...............: oTrayInfo[A_Index].idcmd - Command identifier associated with the button. ; ...............: oTrayInfo[A_Index].pid - Process ID. ; ...............: oTrayInfo[A_Index].uid - Application defined identifier for the icon. ; ...............: oTrayInfo[A_Index].msgid - Application defined callback message. ; ...............: oTrayInfo[A_Index].hicon - Handle to the tray icon. ; ...............: oTrayInfo[A_Index].hwnd - Window handle. ; ...............: oTrayInfo[A_Index]. class - Window class . ; ...............: oTrayInfo[A_Index].process - Process executable. ; ...............: oTrayInfo[A_Index].tray - Tray Type (Shell_TrayWnd or NotifyIconOverflowWindow). ; ...............: oTrayInfo[A_Index].tooltip - Tray icon tooltip. ; Info ..........: TB_BUTTONCOUNT message - http: //goo.gl/DVxpsg ; ...............: TB_GETBUTTON message - http: //goo.gl/2oiOsl ; ...............: TBBUTTON structure - http: //goo.gl/EIE21Z ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_GetInfo(sExeName := "" ) { d := A_DetectHiddenWindows DetectHiddenWindows, On oTrayInfo := [] For key,sTray in [ "Shell_TrayWnd" , "NotifyIconOverflowWindow" ] { idxTB := TrayIcon_GetTrayBar(sTray) WinGet, pidTaskbar, PID, ahk_class %sTray% hProc := DllCall( "OpenProcess" , UInt,0x38, Int,0, UInt,pidTaskbar) pRB := DllCall( "VirtualAllocEx" , Ptr,hProc, Ptr,0, UPtr,20, UInt,0x1000, UInt,0x04) szBtn := VarSetCapacity(btn, (A_Is64bitOS ? 32 : 20), 0) szNfo := VarSetCapacity(nfo, (A_Is64bitOS ? 32 : 24), 0) szTip := VarSetCapacity(tip, 128 * 2, 0) ; TB_BUTTONCOUNT = 0x0418 SendMessage, 0x0418, 0, 0, ToolbarWindow32%idxTB%, ahk_class %sTray% loop, %ErrorLevel% { ; TB_GETBUTTON 0x0417 SendMessage, 0x0417, A_Index-1, pRB, ToolbarWindow32%idxTB%, ahk_class %sTray% DllCall( "ReadProcessMemory" , Ptr,hProc, Ptr,pRB, Ptr,&btn, UPtr,szBtn, UPtr,0) iBitmap := NumGet(btn, 0, "Int" ) idCmd := NumGet(btn, 4, "Int" ) fsState := NumGet(btn, 8, "UChar" ) fsStyle := NumGet(btn, 9, "UChar" ) dwData := NumGet(btn, (A_Is64bitOS ? 16 : 12), "UPtr" ) iString := NumGet(btn, (A_Is64bitOS ? 24 : 16), "Ptr" ) DllCall( "ReadProcessMemory" , Ptr,hProc, Ptr,dwData, Ptr,&nfo, UPtr,szNfo, UPtr,0) hWnd := NumGet(nfo, 0, "Ptr" ) uId := NumGet(nfo, (A_Is64bitOS ? 8 : 4), "UInt" ) msgId := NumGet(nfo, (A_Is64bitOS ? 12 : 8), "UPtr" ) hIcon := NumGet(nfo, (A_Is64bitOS ? 24 : 20), "Ptr" ) WinGet, nPid, PID, ahk_id %hWnd% WinGet, sProcess, ProcessName, ahk_id %hWnd% WinGetClass, sClass, ahk_id %hWnd% if ( (sExeName = "-" && !sProcess) || (sExeName == "--" && !nPid) || (!sExeName) || (sExeName = sProcess) || (sExeName == nPid)) { DllCall( "ReadProcessMemory" , Ptr,hProc, Ptr,iString, Ptr,&tip, UPtr,szTip, UPtr,0) oTrayInfo.Push({ "idx" : A_Index-1 , "idcmd" : idCmd , "pid" : nPid , "uid" : uId , "msgid" : msgId , "hicon" : hIcon , "hwnd" : hWnd , "class" : sClass , "process" : sProcess , "tooltip" : StrGet(&tip, "UTF-16" ) , "tray" : sTray }) } } DllCall( "VirtualFreeEx" , Ptr,hProc, Ptr,pRB, UPtr,0, UInt,0x8000) DllCall( "CloseHandle" , Ptr,hProc) } DetectHiddenWindows, %d% return oTrayInfo } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Hide ; Description ..: Hide or unhide a tray icon. ; Parameters ...: idCmd - Command identifier associated with the button. ; ..............: sTray - Place where to find the icon ( "Shell_TrayWnd" or "NotifyIconOverflowWindow" ). ; ..............: bHide - True for hide, False for unhide. ; Info .........: TB_HIDEBUTTON message - http: //goo.gl/oelsAa ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_Hide(idCmd, sTray:= "Shell_TrayWnd" , bHide:=True) { d := A_DetectHiddenWindows DetectHiddenWindows, On idxTB := TrayIcon_GetTrayBar() SendMessage, 0x0404, idCmd, bHide, ToolbarWindow32%idxTB%, ahk_class %sTray% ; TB_HIDEBUTTON SendMessage, 0x001A, 0, 0, , ahk_class %sTray% DetectHiddenWindows, %d% } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Delete ; Description ..: Delete a tray icon. ; Parameters ...: idx - 0 based tray icon index. ; ..............: sTray - Place where to find the icon ( "Shell_TrayWnd" or "NotifyIconOverflowWindow" ). ; Info .........: TB_DELETEBUTTON message - http: //goo.gl/L0pY4R ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_Delete(idx, sTray:= "Shell_TrayWnd" ) { d := A_DetectHiddenWindows DetectHiddenWindows, On idxTB := TrayIcon_GetTrayBar() SendMessage, 0x0416, idx, 0, ToolbarWindow32%idxTB%, ahk_class %sTrayPlace% ; TB_DELETEBUTTON = 0x0416 SendMessage, 0x001A, 0, 0, , ahk_class %sTrayPlace% DetectHiddenWindows, %d% } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Remove ; Description ..: Remove a Tray icon. It should be more reliable than TrayIcon_Delete. ; Parameters ...: hWnd - Window handle. ; ..............: uId - Application defined identifier for the icon. ; Info .........: NOTIFYICONDATA structure - https: //goo.gl/1Xuw5r ; ..............: Shell_NotifyIcon function - https: //goo.gl/tTSSBM ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_Remove(hWnd, uId) { VarSetCapacity(NID, szNID := ((A_IsUnicode ? 2 : 1) * 384 + A_PtrSize*5 + 40),0) NumPut( szNID, NID, 0 ) NumPut( hWnd, NID, A_PtrSize ) NumPut( uId, NID, A_PtrSize*2 ) return DllCall( "Shell32.dll\Shell_NotifyIcon" , UInt,0x2, UInt,&NID) } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Move ; Description ..: Move a tray icon. ; Parameters ...: idxOld - 0 based index of the tray icon to move. ; ..............: idxNew - 0 based index where to move the tray icon. ; ..............: sTray - Place where to find the icon ( "Shell_TrayWnd" or "NotifyIconOverflowWindow" ). ; Info .........: TB_MOVEBUTTON message - http: //goo.gl/1F6wPw ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_Move(idxOld, idxNew, sTray := "Shell_TrayWnd" ) { d := A_DetectHiddenWindows DetectHiddenWindows, On idxTB := TrayIcon_GetTrayBar() SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class %sTrayPlace% ; TB_MOVEBUTTON = 0x452 DetectHiddenWindows, %d% } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Set ; Description ..: Modify icon with the given index for the given window. ; Parameters ...: hWnd - Window handle. ; ..............: uId - Application defined identifier for the icon. ; ..............: hIcon - Handle to the tray icon. ; ..............: hIconSmall - Handle to the small icon, for window menubar. Optional. ; ..............: hIconBig - Handle to the big icon, for taskbar. Optional. ; Return .......: True on success, false on failure. ; Info .........: NOTIFYICONDATA structure - https: //goo.gl/1Xuw5r ; ..............: Shell_NotifyIcon function - https: //goo.gl/tTSSBM ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_Set(hWnd, uId, hIcon, hIconSmall:=0, hIconBig:=0) { d := A_DetectHiddenWindows DetectHiddenWindows, On ; WM_SETICON = 0x0080 if ( hIconSmall ) SendMessage, 0x0080, 0, hIconSmall,, ahk_id %hWnd% if ( hIconBig ) SendMessage, 0x0080, 1, hIconBig,, ahk_id %hWnd% DetectHiddenWindows, %d% VarSetCapacity(NID, szNID := ((A_IsUnicode ? 2 : 1) * 384 + A_PtrSize*5 + 40),0) NumPut( szNID, NID, 0 ) NumPut( hWnd, NID, (A_PtrSize == 4) ? 4 : 8 ) NumPut( uId, NID, (A_PtrSize == 4) ? 8 : 16 ) NumPut( 2, NID, (A_PtrSize == 4) ? 12 : 20 ) NumPut( hIcon, NID, (A_PtrSize == 4) ? 20 : 32 ) ; NIM_MODIFY := 0x1 return DllCall( "Shell32.dll\Shell_NotifyIcon" , UInt,0x1, Ptr,&NID) } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_GetTrayBar ; Description ..: Get the tray icon handle. ; Parameters ...: sTray - Traybar to retrieve. ; Return .......: Tray icon handle. ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_GetTrayBar(sTray:= "Shell_TrayWnd" ) { d := A_DetectHiddenWindows DetectHiddenWindows, On WinGet, ControlList, ControlList, ahk_class %sTray% RegExMatch(ControlList, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)" , nTB) loop, %nTB% { ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class %sTray% hParent := DllCall( "GetParent" , Ptr, hWnd ) WinGetClass, sClass, ahk_id %hParent% if !(sClass == "SysPager" || sClass == "NotifyIconOverflowWindow" ) continue idxTB := A_Index break } DetectHiddenWindows, %d% return idxTB } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_GetHotItem ; Description ..: Get the index of tray's hot item. ; Return .......: Index of tray's hot item. ; Info .........: TB_GETHOTITEM message - http: //goo.gl/g70qO2 ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_GetHotItem() { idxTB := TrayIcon_GetTrayBar() SendMessage, 0x0447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETHOTITEM = 0x0447 return ErrorLevel << 32 >> 32 } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Button ; Description ..: Simulate mouse button click on a tray icon. ; Parameters ...: sExeName - Executable Process Name of tray icon. ; ..............: sButton - Mouse button to simulate (L, M, R). ; ..............: bDouble - True to double click, false to single click. ; ..............: nIdx - Index of tray icon to click if more than one match. ; ---------------------------------------------------------------------------------------------------------------------- TrayIcon_Button(sExeName, sButton:= "L" , bDouble:=False, nIdx:=1) { d := A_DetectHiddenWindows DetectHiddenWindows, On WM_MOUSEMOVE = 0x0200 WM_LBUTTONDOWN = 0x0201 WM_LBUTTONUP = 0x0202 WM_LBUTTONDBLCLK = 0x0203 WM_RBUTTONDOWN = 0x0204 WM_RBUTTONUP = 0x0205 WM_RBUTTONDBLCLK = 0x0206 WM_MBUTTONDOWN = 0x0207 WM_MBUTTONUP = 0x0208 WM_MBUTTONDBLCLK = 0x0209 sButton := "WM_" sButton "BUTTON" oIcons := TrayIcon_GetInfo(sExeName) if ( bDouble ) PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%DBLCLK,, % "ahk_id " oIcons[nIdx].hwnd else { PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%DOWN,, % "ahk_id " oIcons[nIdx].hwnd PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%UP,, % "ahk_id " oIcons[nIdx].hwnd } DetectHiddenWindows, %d% return } ; ---------------------------------------------------------------------------------------------------------------------- ; Function .....: TrayIcon_Clean 清理托盘图标 ; Description ..: Removes stale icons (no matching processid). ; 删除过时的图标(没有匹配处理)。 ; Parameters ...: bVerbose - True to display output, false ( default for no output). ; bVerbose -显示输出为True, false (默认为无输出)。 ; Notes ........: Uses modified TrayIcon_GetInfo that accepts sExeName - for no process, and -- for no processid ; 使用修改后的TrayIcon_GetInfo,接受sExeName -(无进程)和——(无进程)---------------------------------------------------------------------------------------------------------------------- TrayIcon_Clean(bVerbose := false ) { for i, oIcon in TrayIcon_GetInfo( "--" ) { if (not oIcon.pid) { TrayIcon_Remove( oIcon.hwnd, oIcon.uid) if (bVerbose) { str .= "Idx: " oIcon.idx "`nhWnd: " oIcon.hwnd "`nUid: " oIcon.uid "`nIdCmd: " oIcon.idcmd "`n`n" } } } if (bVerbose) { if (str) { str := "Leftover icons removed`n`n" str } else { str := "No leftover icons to remove" } MsgBox str } } |
www.cnblogs.com/delphixx
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2022-05-29 好物推荐 第4版 2022.05.29