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

55
LINES

< > BotCompany Repo | #1005915 // Find Opera window, show in thumbnail of screen [WORKS]

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

Libraryless. Click here for Pure Java version (4622L/31K/105K).

!752

p {
  new ShootLoop {
    void recognize {
      selections.clear();
      
      // check for full screen window
      //print(topRightCornerSimilarity("#1005918"));
      
      if (topRightCornerIs("#1005921") || topRightCornerIs("#1005918"))
        selections.add(new Rect(maxWindowBounds()));
        
      // check for regular windows
      L<Rect> topRight = concatLists(
        findImageAll("#1005911"), findImageAll("#1005912"));
      for (Rect right : topRight) {
        int y1 = right.y;
        L<Rect> left = concatLists(
          findImageAllOnRow("#1005909", y1),
          findImageAllOnRow("#1005910", y1));
        if (l(left) != 1) {
          print("  Confused! No left corner for " + right);
          continue;
        }
        Rect lft = first(left);
        int x1 = lft.x-4;
        //print("  Window title found, probably");
        int y2 = right.y2(); // title only
        
        L<Rect> bottom = concatLists(
          findImageAllOnColumn("#1005913", x1),
          findImageAllOnColumn("#1005914", x1));
        
        if (l(bottom) == 1)
          y2 = first(bottom).y2();
        else
          print("Confused - no bottom left corner for " + lft);
          
        selections.add(pointsRect(x1, y1, right.x2(), y2));
      }
    }
    
    void printState(long time) {
      done_always(time, n(l(selections), "Opera windows") + " found");
      int nWindows = l(selections);
      setConsoleIcon(
        nWindows == 0 ? "#1005834" :
        nWindows == 1 ? "#1005888" :
        nWindows == 2 ? "#1005889" :
          "#1005890");
      showThumbnail();
    }
  }.run();
}

Author comment

Began life as a copy of #1005906

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: #1005915
Snippet name: Find Opera window, show in thumbnail of screen [WORKS]
Eternal ID of this version: #1005915/1
Text MD5: 9adef1c5c13b9f9ac2c99a11e670255a
Transpilation MD5: 1c8f6a94d89ade85bea2498d8f170aa1
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-12 20:27:18
Source code size: 1681 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 519 / 664
Referenced in: