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

40
LINES

< > BotCompany Repo | #1007001 // Monitor clipboard for runnable snippets [WORKS]

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

Uses 3874K of libraries. Click here for Pure Java version (8084L/57K/197K).

1  
!7
2  
3  
static int secondsToDisplay = 10;
4  
5  
p-substance-thread {
6  
  S lastText = null;
7  
  repeat with sleep 1 {
8  
    S s = getTextFromClipboard();
9  
    if (neq(s, lastText)) {
10  
      lastText = s;
11  
      final long id = parseSnippetURLOpt(s);
12  
      if (id != 0) {
13  
        fS _id = fsI(id);
14  
        //infoBox("Snippet: " + _id, 2);
15  
        
16  
        awt {
17  
          final JLabel lbl = jlabel("Testing snippet");
18  
          final JFrame f = showPackedFrameInTopRightCorner("Run " + _id + "?",
19  
            withMargin(vstackWithSpacing(lbl, jbutton("Run", r {
20  
              nohupJavax(_id);
21  
            }))));
22  
          thread "Fetch Stuff" {
23  
            print("Testing snippet " + id);
24  
            if (getSnippetType(id) != 34)
25  
              disposeWindow(f);
26  
            else {
27  
              print("Runnable");
28  
              setText(lbl, "Fetching title...");
29  
              packFrameInTopRightCorner(f);
30  
              setText(lbl, or2(getSnippetTitle(id), "Unnamed snippet"));
31  
              makeLabelBold(lbl);
32  
              packFrameInTopRightCorner(f);
33  
              disposeWindowIfMouseNotInIt(iround(secondsToDisplay*1000), f);
34  
            }
35  
          }
36  
        }
37  
      }
38  
    }
39  
  }
40  
}

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: #1007001
Snippet name: Monitor clipboard for runnable snippets [WORKS]
Eternal ID of this version: #1007001/15
Text MD5: 4cd4b2ddb1c0e40e362e21599bf1d9eb
Transpilation MD5: 3114b496afa499ec179c3c690c94d970
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-25 16:28:17
Source code size: 1211 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 483 / 604
Version history: 14 change(s)
Referenced in: [show references]