Code:
;chunk pixel search;
global hdc
setbatchlines,-1
setwindelay,-1
chunk_width := 100
chunk_height := 100
;chunk_colors is whole bunch of reds and different shades of it, for your own list just use the "GetPixel" function to get the colors
chunk_colors := ".1708241.2037205.2958561.3813869.4076783.6445554.10130935.10328312.7630573.3287769.1971155.3024098.3945197.4076776.8485872.9801974.2563284.1774033.2563804.3550183.4274160.7761908.3748075.4866288.9538807.4669150.2300377.3155683.9209591.9473269.3814107.3550697.4932575.2431962.5590513.9933560.2892512.3353062.6840563.6512104.9604599.5261281.2168791.2629341.3616233.8156917.4997872.9670391.6248434.5129706.1971411.3418855.3024093.5985258.10065143.5195745.6051044.6380009.7169522.7235315.7630068.9801975.5524717.2826463.3813852.7103978.10196728.2826970.4011242.5919466.9143796.10196471.7367152.4471784.7959541.9341174.5063921.8156660.5195504.4668912.8617205.7037939.5195761.9604344.4471792.7564789.7367156.5853425.5393137.8749046.6774771.6117106.8880374.9275383.8814838.8288245.9341175.6248178.5458929.6643187.4339951.5985266.8091126.5919217.6643186.9406965.5787633.7038446.8946420.4800496.3221476.1839827.3550681.4932080.9011958.7630323.2234836.5787619.6248166.7169523.3682283.6314225.5853682.6380018.2102741.8420086.8551670.2366169.4142576.6051058.9078007.4010991.5261553.10065144.6906355.7498996.7103987.9209590.6116850.8354294.5721842.6051057.4603376.8814582.5787890.4208368.9407221.5656306.5985265.3353314.6182635.7498480.9736183.4932333.8091125.4471535.5129712.9275126.2760926.5327341.8617462.8156661.6972659.4406000.7695860.8946423.7498227.4208367.5656305.6445810.5327345.5524721.6511859.5261297.6182641.7235571.4537584.8025333.4537326.8485877.2234327.7301364.5195505.6709235.6577650.4932593.7630581.7103730.4340201.2497755.6313959.3419101.4537576.4011233.3747807.5063664.3221475.4734958.6643180.4735210.3747809.4734960.5458673.5919473.5063920.4274415.6709234.7696372.6906610.7432948.6906611.7235572.8156404.7367412.6841075.6313970.8880886.6972403.7762420.7959796.7894004.6511858.9801720.8354549.8749045.7301619.7630324.5524462.7827956.8946678.6314482.7038451.8420341.8157173.6577394.7169780.7630836.4669415.6775025.9867767.4537574.7103986.9341431.4077283.8288501.7038452.4866544.7038450.8946421.9012214.7367155.6314226.4537328.7104242.8486133.7564788.3550430.4208112.7367411.7170035.8025332.6182894.4603369.5590508.7235828.10131192.3220955.9209847.4932837.5393128.7170289.1905362.4340198.4998126.7038196.6446066.6577645.5853930.8682997.3616475.2300373.4142819.4998382.7104244.5326832.5327344.5787889.5853679.7103731.9999352.8354293.10262264.8683253.7959540.8617461.4734949.6116844.6775023.5195750.7433204.8420085.3024088.5064165.6906864.3945694.2168532.6380528.6775027.2629334.4537569.5985770.7499251.2695128.5788138.4867044.7103988.7104497.6445811.5919474.6840818.4142562.6511855"
hwnd := winexist("ahk_class MSPaintApp")
hdc := DllCall("user32.dllGetDCEx", "UInt", hwnd, "UInt", 0, "UInt", 1|2)
wingetpos,wx,wy,ww,wh,ahk_id %hwnd%
searchArea_x := 0
searchArea_y := 0
searchArea_width := ww
searchArea_height := wh
search_x := floor(searchArea_width/chunk_width)
search_y := floor(searchArea_height/chunk_height)
winactivate,ahk_id %hwnd%
loop {
match := fail := false
loop % search_y {
y_index := a_index
loop % search_x {
loc_x := (a_index-1)*chunk_width
loc_y := (y_index-1)*chunk_width
found_color := GetPixel(loc_x,loc_y,hwnd)
if (instr(chunk_colors,found_color)) {
found_x := loc_x-1
found_y := loc_y
loop % chunk_width {
found_color := GetPixel(found_x,found_y,hwnd)
if (instr(chunk_colors,found_color)) {
found_x--
}
else {
found_x++
loop % chunk_height {
found_color := GetPixel(found_x,found_y,hwnd)
if (instr(chunk_colors,found_color)) {
found_y--
}
else {
found_y++
c++
if (instr(chunk_colors,GetPixel(found_x+chunk_width-1,found_y,hwnd))) {
if (instr(chunk_colors,GetPixel(found_x,found_y+chunk_height-1,hwnd))) {
if (instr(chunk_colors,GetPixel(found_x+chunk_width-1,found_y+chunk_height-1,hwnd))) {
MsgBox % "MATCH at, x: " found_x ", y:" found_y
match := true
}
else
fail := true
}
else
fail := true
}
else
fail := true
}
} until match || fail
}
} until match || fail
}
} until match
} until match
}
return
GetPixel(x, y, hwnd) {
return "." DllCall("gdi32.dllGetPixel", "UInt", hDC, "Int", x, "Int", y, "UInt")
}
rshift::
DllCall("user32.dllReleaseDC", "UInt", hwnd, "UInt", hdc)
exitapp