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

58
LINES

< > BotCompany Repo | #1005906 // Windows XP: Find regular windows, show in thumbnail of screen

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

Libraryless. Click here for Pure Java version (6220L/44K/146K).

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

Author comment

Began life as a copy of #1005891

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005906
Snippet name: Windows XP: Find regular windows, show in thumbnail of screen
Eternal ID of this version: #1005906/1
Text MD5: 21e121ee2164fe60678cd38eca20773b
Transpilation MD5: 8de693ea666aa3eb1b2caa2928f2ff81
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-01-01 20:07:33
Source code size: 1668 bytes / 58 lines
Pitched / IR pitched: No / No
Views / Downloads: 552 / 655
Referenced in: [show references]