Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

70
LINES

< > BotCompany Repo | #462 // Scrollbar finder 1

Lua code - Image recognition

get("#356") -- num2hex

w, h = img.width, img.height
barw = 15 -- scrollbar width

mx = math.floor(barw/2) -- in the middle
stepx, stepy = mx, 4

function topOK(x, y1, enabled)
  for y=y1-1, math.max(y1-stepy-16, 0), -1 do
    for xx = math.max(0, x-mx), math.min(w-1, x+mx) do
      local p = img.getInt(xx, y)
      if p == (enabled and 0x000000 or 0x777777) then return true end
    end
  end
  return false
end

for x = w-mx, mx, -stepx do
  last, slider, background1, background2, top = nil
  for y = 0, h-1, stepy do
    pix = img.getInt(x, y)
    if last ~= pix then
      if slider == nil and (last == 0xEAEAEA and y > starty+stepy) then
        print("possible slider: "..starty.."-"..(y-stepy))
        if top ~= nil or topOK(x, starty, false) then
          print("slider")
          if top == nil then top = starty end
          slider = x..", "..starty..", "..(x+1)..", "..(y-stepy)
          bottom = y
        end
      elseif last == 0xD3D3D3 and y > starty+stepy then
        print("possible background found: "..starty.."-"..(y-stepy))
        if top ~= nil or topOK(x, starty, true) then
          print("background")
          if top == nil then top = starty end
          bg = x..", "..starty..", "..(x+1)..", "..(y-stepy)
          if slider then
            background2 = bg
          else
            background1 = bg
          end
          bottom = y
        end
      end
      last, starty = pix, y
    end
    --print("y", y, num2hex(pix))
    if background2 then goto raus end
  end
  ::raus::
  
  if slider then
    upArrow = x..", "..(top-stepy-2)..", "..(x+1)..", "..(top-stepy-1)
    downArrow = x..", "..bottom..", "..(x+1)..", "..(bottom+1)
  
    parts = {}
    table.insert(parts, "Up arrow="..upArrow)
    if background1 then
      table.insert(parts, "Background1="..background1)
    end
    table.insert(parts, "Slider="..slider)
    if background2 then
      table.insert(parts, "Background2="..background2)
    end
    table.insert(parts, "Down arrow="..downArrow)
    
    return "Vertical scrollbar found: "..table.concat(parts, "|")
  end
end

download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
41 stefan See #1000159 2015-02-13 20:32:38

add comment

Image recognition results

show nils
Image Result Result calculated
#1004090 java.lang.OutOfMemoryError: Java heap space 2016-08-07 13:34:11

[raw result]
[visualize]
#1000121 Vertical scrollbar found: Up arrow=107, 334, 108, 335|Slider=107, 340, 108, 344|Down arrow=107, 348,... 2016-08-05 10:15:48
Lua instructions: 188k (110 ms)

[raw result]
[visualize]
#1000113 Vertical scrollbar found: Up arrow=666, 110, 667, 111|Background1=666, 116, 667, 476|Slider=666, 484... 2016-08-04 04:14:25
Lua instructions: 13k (28 ms)

[raw result]
[visualize]
#1000336 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 17:48:38

[raw result]
[visualize]
#1000330 java.lang.OutOfMemoryError: Java heap space 2016-08-01 17:35:31

[raw result]
[visualize]
#1000327 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 16:53:54

[raw result]
[visualize]
#1000326 java.lang.OutOfMemoryError: Java heap space 2016-08-01 16:53:38

[raw result]
[visualize]
#1000320 java.lang.OutOfMemoryError: Java heap space 2016-08-01 15:25:45

[raw result]
[visualize]
#1000316 Vertical scrollbar found: Up arrow=10, 466, 11, 467|Slider=10, 472, 11, 476|Down arrow=10, 480, 11, ... 2016-08-01 15:00:31
Lua instructions: 235k (39 ms)

[raw result]
[visualize]
#1000314 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:55:24

[raw result]
[visualize]
#1000310 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:21:22

[raw result]
[visualize]
#1000309 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:20:53

[raw result]
[visualize]
#1000301 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:20:50

[raw result]
[visualize]
#1000259 Vertical scrollbar found: Up arrow=655, 98, 656, 99|Background1=655, 104, 656, 464|Slider=655, 472, ... 2016-08-01 12:14:50
Lua instructions: 21k (52 ms)

[raw result]
[visualize]
#1000250 Vertical scrollbar found: Up arrow=659, 66, 660, 67|Background1=659, 72, 660, 172|Slider=659, 176, 6... 2016-08-01 11:28:41
Lua instructions: 7k (3 ms)

[raw result]
[visualize]
#1000248 Vertical scrollbar found: Up arrow=1359, 106, 1360, 107|Background1=1359, 112, 1360, 240|Slider=1359... 2016-08-01 11:14:34
Lua instructions: 9k (19 ms)

[raw result]
[visualize]
#1000241 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 09:35:20

[raw result]
[visualize]
#1000238 Vertical scrollbar found: Up arrow=1359, 106, 1360, 107|Slider=1359, 112, 1360, 724|Down arrow=1359,... 2016-08-01 09:21:17
Lua instructions: 9k (4 ms)

[raw result]
[visualize]
#1000233 Vertical scrollbar found: Up arrow=1359, 94, 1360, 95|Background1=1359, 100, 1360, 676|Slider=1359, ... 2016-08-01 09:04:46
Lua instructions: 9k (3 ms)

[raw result]
[visualize]
#1000235 Vertical scrollbar found: Up arrow=1359, 94, 1360, 95|Background1=1359, 100, 1360, 676|Slider=1359, ... 2016-08-01 09:04:45
Lua instructions: 9k (26 ms)

[raw result]
[visualize]
#499 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:34:29

[raw result]
[visualize]
#500 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:34:29

[raw result]
[visualize]
#488 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 07:29:04

[raw result]
[visualize]
#1000218 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 05:08:25

[raw result]
[visualize]
#1000216 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 05:08:25

[raw result]
[visualize]
#1000212 java.lang.OutOfMemoryError: Java heap space 2016-08-01 05:08:25

[raw result]
[visualize]
#1000196 java.lang.OutOfMemoryError: Java heap space 2016-08-01 04:39:11

[raw result]
[visualize]
#1000187 Vertical scrollbar found: Up arrow=1212, 734, 1213, 735|Slider=1212, 740, 1213, 744|Down arrow=1212,... 2016-08-01 03:22:02
Lua instructions: 175k (96 ms)

[raw result]
[visualize]
#1000178 Vertical scrollbar found: Up arrow=1002, 62, 1003, 63|Slider=1002, 68, 1003, 340|Background2=1002, 3... 2016-08-01 02:32:33
Lua instructions: 166k (77 ms)

[raw result]
[visualize]
#1000176 Vertical scrollbar found: Up arrow=1212, 734, 1213, 735|Slider=1212, 740, 1213, 744|Down arrow=1212,... 2016-08-01 02:12:33
Lua instructions: 175k (111 ms)

[raw result]
[visualize]
#113 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:55:16

[raw result]
[visualize]
#112 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:55:16

[raw result]
[visualize]
#182 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:50:13

[raw result]
[visualize]
#100 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:26:57

[raw result]
[visualize]
#1000162 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:21:03

[raw result]
[visualize]
#145 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:21:02

[raw result]
[visualize]
#1000013 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:21:00

[raw result]
[visualize]
#92 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:20:14

[raw result]
[visualize]
#1000017 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:20:13

[raw result]
[visualize]
#178 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:19:35

[raw result]
[visualize]
#1000161 Vertical scrollbar found: Up arrow=74, 106, 75, 107|Background1=74, 112, 75, 356|Slider=74, 360, 75,... 2016-07-31 23:17:35
Lua instructions: 9k (4 ms)

[raw result]
[visualize]
#1000160 Vertical scrollbar found: Up arrow=74, 106, 75, 107|Background1=74, 112, 75, 376|Slider=74, 380, 75,... 2016-07-31 23:13:53
Lua instructions: 9k (24 ms)

[raw result]
[visualize]
#1000045 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:13:13

[raw result]
[visualize]
#1000044 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:13:13

[raw result]
[visualize]
#1000047 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:13:12

[raw result]
[visualize]
#1000042 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:13:10

[raw result]
[visualize]
#141 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:40

[raw result]
[visualize]
#1000033 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:37

[raw result]
[visualize]
#93 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:34

[raw result]
[visualize]
#98 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:34

[raw result]
[visualize]
#1000003 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:34

[raw result]
[visualize]
#1000108 Vertical scrollbar found: Up arrow=17, 230, 18, 231|Slider=17, 236, 18, 248|Down arrow=17, 252, 18, ... 2016-07-31 23:12:32
Lua instructions: 784k (99 ms)

[raw result]
[visualize]
#1000116 Vertical scrollbar found: Up arrow=675, 110, 676, 111|Background1=675, 116, 676, 480|Slider=675, 484... 2016-07-31 23:12:31
Lua instructions: 23k (31 ms)

[raw result]
[visualize]
#1000114 Vertical scrollbar found: Up arrow=666, 110, 667, 111|Background1=666, 116, 667, 476|Slider=666, 484... 2016-07-31 23:12:31
Lua instructions: 13k (22 ms)

[raw result]
[visualize]
#1000112 Vertical scrollbar found: Up arrow=331, 114, 332, 115|Slider=331, 120, 332, 148|Down arrow=331, 152,... 2016-07-31 23:12:31
Lua instructions: 101k (76 ms)

[raw result]
[visualize]
#1000123 Vertical scrollbar found: Up arrow=28, 230, 29, 231|Slider=28, 236, 29, 252|Down arrow=28, 256, 29, ... 2016-07-31 23:12:30
Lua instructions: 1336k (227 ms)

[raw result]
[visualize]
#1000118 Vertical scrollbar found: Up arrow=233, 110, 234, 111|Slider=233, 116, 234, 124|Down arrow=233, 128,... 2016-07-31 23:12:30
Lua instructions: 14k (24 ms)

[raw result]
[visualize]
#1000130 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:29

[raw result]
[visualize]
#1000131 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:28

[raw result]
[visualize]
#1000138 Vertical scrollbar found: Up arrow=541, 58, 542, 59|Background1=541, 64, 542, 68|Slider=541, 72, 542... 2016-07-31 23:12:27
Lua instructions: 537k (64 ms)

[raw result]
[visualize]
#1000142 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:26

[raw result]
[visualize]
#1000140 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:26

[raw result]
[visualize]
#1000139 Vertical scrollbar found: Up arrow=541, 58, 542, 59|Background1=541, 64, 542, 68|Slider=541, 72, 542... 2016-07-31 23:12:26
Lua instructions: 514k (172 ms)

[raw result]
[visualize]
#1000145 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:25

[raw result]
[visualize]
#1000144 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:25

[raw result]
[visualize]
#1000143 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:25

[raw result]
[visualize]
#1000127 Vertical scrollbar found: Up arrow=670, 74, 671, 75|Background1=670, 80, 671, 224|Slider=670, 228, 6... 2016-07-31 23:12:24
Lua instructions: 10k (4 ms)

[raw result]
[visualize]
#1000157 java.lang.OutOfMemoryError: Java heap space 2016-07-31 23:12:22

[raw result]
[visualize]
#1000156 Vertical scrollbar found: Up arrow=78, 62, 79, 63|Slider=78, 68, 79, 268|Background2=78, 272, 79, 68... 2016-07-31 23:12:22
Lua instructions: 6k (40 ms)

[raw result]
[visualize]
#1000137 Vertical scrollbar found: Up arrow=604, 58, 605, 59|Background1=604, 64, 605, 68|Slider=604, 72, 605... 2016-07-31 23:12:22
Lua instructions: 575k (65 ms)

[raw result]
[visualize]
#87 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:22

[raw result]
[visualize]
#85 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:22

[raw result]
[visualize]
#48 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:12:22

[raw result]
[visualize]
#1000159 Vertical scrollbar found: Up arrow=8, 10, 9, 11|Slider=8, 16, 9, 216|Background2=8, 224, 9, 632|Down... 2016-07-31 23:12:21
Lua instructions: 5k (18 ms)

[raw result]
[visualize]
#1000219 java.lang.OutOfMemoryError: Java heap space 2016-07-31 18:51:33

[raw result]
[visualize]
#1003745 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 18:51:22

[raw result]
[visualize]
#489 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 18:51:22

[raw result]
[visualize]
#1000141 Vertical scrollbar found: Up arrow=1359, 146, 1360, 147|Slider=1359, 152, 1360, 392|Background2=1359... 2016-07-31 18:45:20
Lua instructions: 13k (23 ms)

[raw result]
[visualize]

Snippet ID: #462
Snippet name: Scrollbar finder 1
Eternal ID of this version: #462/1
Text MD5: 97dfc1066cee70784f6dac2c94107bc9
Author: stefan
Category: image recognition
Type: Lua code - Image recognition
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-02-14 19:42:30
Source code size: 2158 bytes / 70 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1896 / 178
Referenced in: [show references]