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

45
LINES

< > BotCompany Repo | #1006424 // XP_FindWindows + FoundWindow

JavaX fragment (include)

sclass FoundWindow {
  Rect r;
  bool active;
}

sclass XP_FindWindows extends ShootLoop {
  volatile new L<FoundWindow> foundWindows;
  
  void recognize {
    L<Rect> topRight =
      //findImageAll(#1005903, #1005902);
      findImageAll(#1006414, #1006416);
    selections.clear();
    new L<FoundWindow> found;
    for (Rect right : topRight) {
      int y1 = right.y;
      L<Rect> leftActive = findImageAllOnRow(#1006419, y1+1);
      L<Rect> leftInactive = findImageAllOnRow(#1006420, y1+1);
      if (l(leftActive) + l(leftInactive) != 1) {
        print("  Confused! No or multiple left corners for " + right);
        continue;
      }
      bool active = nempty(leftActive);
      int x1 = first(concatLists(leftActive, leftInactive)).x-3;
      //print("  Window title found, probably");
      int y2 = right.y2(); // title only
      
      L<Rect> bottom = concatLists(
        findImageAllOnColumn(#1006421, x1),
        findImageAllOnColumn(#1006422, x1));
      
      if (l(bottom) == 1)
        y2 = first(bottom).y2();
        
      Rect r = pointsRect(x1, y1, right.x2()+4, y2);
      found.add(nu(FoundWindow, +r, +active));
      selections.add(r);
    }
    foundWindows = found;
  }
  
  void printState(long time) {
    done_always(time, n(l(foundWindows), "XP windows") + " found");
  }
}

Author comment

Began life as a copy of #1005906

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006424
Snippet name: XP_FindWindows + FoundWindow
Eternal ID of this version: #1006424/1
Text MD5: d35f0a682e1d47501c7b2336d34af3bd
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-01-01 20:35:55
Source code size: 1361 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 479 / 1172
Referenced in: [show references]