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

67
LINES

< > BotCompany Repo | #1006398 // Find Scroll Bar 4

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (6372L/42K/141K).

!7

sclass PossibleHScrollbar {
  Rect slider;
  int hIdx;
}

p {
  // Find candidates
  
  RGBImage rgb = shootScreen(); //loadImage(#1006358;
  ocr_explodedView1_init();
  L<Rect> vClips = ocr_wideBlack_vsplit(rgb);
  int iLine = 0;
  new L<PossibleHScrollbar> hCandidates;
  int y = 0;
  for i over vClips: {
    RGBImage line = rgb.clip(vClips.get(i));
    L<Rect> lineClips = ocr_highBlack_hsplit(line);
    //print("Line " + (++iLine) + " (" + r + "): " + struct(lineClips));
    int x = 0;
    for j over lineClips: {
      Rect clip = lineClips.get(j);
      if (clip.w == 1)
        hCandidates.add(nu(PossibleHScrollbar,
          slider := new Rect(x, y, clip.w, clip.h), hIdx := j));
      x += clip.w;
    }
    y += line.h();
  }
  printStruct(+hCandidates);
  
  // Keep shooting, check candidates for movement
  
  while licensed {
    sleepSeconds(2);
    print("Shooting & checking for scrollbar movement");  
    rgb = shootScreen(); //loadImage(#1006358;
    vClips = ocr_wideBlack_vsplit(rgb);
    y = 0;
    int iHC = 0;
    for i over vClips: {
      // find candidates for this line
      while (iHC < l(hCandidates) && hCandidates.get(iHC).slider.y < y) ++iHC;
      if (iHC >= l(hCandidates)) break;
      
      int jHC = iHC;
      while (jHC < l(hCandidates) && hCandidates.get(jHC).slider.y == y) ++jHC;
      if (jHC > iHC) { // any candidates for this line
        L<PossibleHScrollbar> lineCandidates = subList(hCandidates, iHC, jHC);
        RGBImage line = rgb.clip(vClips.get(i));
        L<Rect> lineClips = ocr_highBlack_hsplit(line);
        int x = 0;
        for j over lineClips: {
          Rect clip = lineClips.get(j);
          if (clip.w == 1) {
            PossibleHScrollbar sb = findWhere(lineCandidates, xIdx := x);
            if (sb != null)
              print("Horizontal slider move: " + sb.slider.x + " => " + x);
          }
          x += clip.w;
        }
      }
      y += vClips.get(i).h;
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006398
Snippet name: Find Scroll Bar 4
Eternal ID of this version: #1006398/1
Text MD5: 4876b16c6b633276291966286dcabde6
Transpilation MD5: 37ee4fbf651a9d1265fda8864322932b
Author: stefan
Category: javax / ocr
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-16 11:32:48
Source code size: 2029 bytes / 67 lines
Pitched / IR pitched: No / No
Views / Downloads: 561 / 655
Referenced in: [show references]