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)

1  
sclass FoundWindow {
2  
  Rect r;
3  
  bool active;
4  
}
5  
6  
sclass XP_FindWindows extends ShootLoop {
7  
  volatile new L<FoundWindow> foundWindows;
8  
  
9  
  void recognize {
10  
    L<Rect> topRight =
11  
      //findImageAll(#1005903, #1005902);
12  
      findImageAll(#1006414, #1006416);
13  
    selections.clear();
14  
    new L<FoundWindow> found;
15  
    for (Rect right : topRight) {
16  
      int y1 = right.y;
17  
      L<Rect> leftActive = findImageAllOnRow(#1006419, y1+1);
18  
      L<Rect> leftInactive = findImageAllOnRow(#1006420, y1+1);
19  
      if (l(leftActive) + l(leftInactive) != 1) {
20  
        print("  Confused! No or multiple left corners for " + right);
21  
        continue;
22  
      }
23  
      bool active = nempty(leftActive);
24  
      int x1 = first(concatLists(leftActive, leftInactive)).x-3;
25  
      //print("  Window title found, probably");
26  
      int y2 = right.y2(); // title only
27  
      
28  
      L<Rect> bottom = concatLists(
29  
        findImageAllOnColumn(#1006421, x1),
30  
        findImageAllOnColumn(#1006422, x1));
31  
      
32  
      if (l(bottom) == 1)
33  
        y2 = first(bottom).y2();
34  
        
35  
      Rect r = pointsRect(x1, y1, right.x2()+4, y2);
36  
      found.add(nu(FoundWindow, +r, +active));
37  
      selections.add(r);
38  
    }
39  
    foundWindows = found;
40  
  }
41  
  
42  
  void printState(long time) {
43  
    done_always(time, n(l(foundWindows), "XP windows") + " found");
44  
  }
45  
}

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: 490 / 1185
Referenced in: [show references]