Libraryless. Click here for Pure Java version (9072L/63K/212K).
!7 static int sleepTimeWhenNotFound = 5000; static JFrame frame; static ImageSurface imageSurface; static FindURLBox1 finder; static BoxShot shot; static TimeRange timeRange; concept BoxShot { S imageMD5; byte[] png; new RefL<TimeRange> timeRanges; } concept TimeRange { long from, to; *() {} *(long *from) { to = from; } void addNow() { cset(this, to := max(to, now())); } } p { conceptsAndBot(60*1000); awt { finder = new FindURLBox1; frame = showFrame("Find URL Box", jcenteredLabel("-")); frameInnerSize(frame, 500, 70); moveToBottomRightCorner(frame); frame.setAlwaysOnTop(true); awtCalcRegularly(frame, 200, 0, r { final bool b = finder.go(); awt { if (b) { RGBImage img = finder.bestImage(); S since = ""; if (shot != null && timeRange != null) since = ", since " + (now()-timeRange.from)/1000 + "s, " + nth(l(shot.timeRanges)) + " appearance)"; S text = "URL box found in " + finder.recogTime + " ms (" + img.w() + "*" + img.h() + " px" + since + ")"; if (imageSurface == null) { imageSurface = new ImageSurface(img); setFrameContents(frame, jSection(text, new JScrollPane(imageSurface))); } else { imageSurface.setImage(img); setSectionTitle(imageSurface, text); } S imageMD5 = md5OfRGBImage(img); shot = uniq(BoxShot, +imageMD5); if (shot.png == null) shot.png = rgbImageToPNG(img); if (shot.timeRanges.contains(timeRange)) timeRange.addNow(); else shot.timeRanges.add(timeRange = new TimeRange(now())); shot.change(); } else { timeRange = null; if (imageSurface != null) { imageSurface = null; setFrameContents(frame, jcenteredLabel("URL box not found (" + finder.recogTime + " ms)")); } } } if (!b) sleep(sleepTimeWhenNotFound); }); } }
Began life as a copy of #1006217
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006232 |
Snippet name: | Record browser's URL box |
Eternal ID of this version: | #1006232/1 |
Text MD5: | f3bc68d421ba4d09b569e4faa13daa04 |
Transpilation MD5: | b65aa2f0dbeb55eb063eddbae0759e90 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-25 20:26:33 |
Source code size: | 2123 bytes / 75 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 643 / 773 |
Referenced in: | [show references] |