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).

!752

static int nWindows;

sclass FoundWindow {
  Rect r;
  bool active;
}

static volatile new L<FoundWindow> foundWindows;

p {
  new ShootLoop {
    void recognize {
      L<Rect> topRight =
        //findImageAll(#1005903, #1005902);
        findImageAll(#1006414, #1006416);
      nWindows = l(topRight);
      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(), y2);
        found.add(nu(FoundWindow, +r, +active));
        selections.add(r);
      }
      foundWindows = found;
    }
    
    void printState(long time) {
      done_always(time, n(nWindows, "XP windows") + " found");
      setConsoleIcon(
        nWindows == 0 ? "#1005834" :
        nWindows == 1 ? "#1005888" :
        nWindows == 2 ? "#1005889" :
          "#1005890");
      showThumbnail();
    }
  }.run();
}

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: 613 / 750
Referenced in: #1005915 - Find Opera window, show in thumbnail of screen [WORKS]
#1006424 - XP_FindWindows + FoundWindow