java - Selecting a window behind a JFrame -


alright, give bit of background, have jframe i've manipulated full screen transparent overlay when user types keystroke on keyboard.

the goal want user select opened window (so web browser you're using now) further manipulate program. have overlay working global keystroke managed jintellitype , swing's nifty extended state method full screen...ness.

the problem have nice-looking overlay appears way want, cannot select of windows because jframe on them. need screencloud has screenshot selection (look @ 0:19 on video), user needs click on window when overlay/message appears.

i'm looking jna getting window sizes , other info later use in application. i'm open ideas on how go this. worst case scenario see on ctrl-alt-tab window switcher selecting window.

note: if helps @ all, i'm using trayicon application centered around, calls , creates jframes , such.

for future, if (which doubt anyone) runs problem, have jna grab rectangle each window , in order in they're layered (e.g. "file manager" - (0,0)(250,250) , "eclipse" - (0,0)(1920,1080) -- saying window "file manager" on top). have jframe listen mouse click event on frame; use coordinates find collisions rectangles generated jna. code example (the jna side of it):

public static list<windowinfo> getwindows() {     final list<windowinfo> infllist = new arraylist<windowinfo>();     final list<integer> order = new arraylist<integer>();     int top = user32.instance.gettopwindow(0);     while (top!=0) {         order.add(top);         top = user32.instance.getwindow(top, user32.gw_hwndnext);     }     user32.instance.enumwindows(new wndenumproc()     {         @override         public boolean callback(int hwnd, int lparam)         {             if (user32.instance.iswindowvisible(hwnd)) {                 rect r = new rect();                 user32.instance.getwindowrect(hwnd, r);                 if (r.left>-32000) {     // minimized                     byte[] buffer = new byte[1024];                     user32.instance.getwindowtexta(hwnd, buffer, buffer.length);                     string title = native.tostring(buffer);                     infllist.add(new windowinfo(hwnd, r, title));                 }             }             return true;         }     }, 0);     collections.sort(infllist, new comparator<windowinfo>()             {         @override         public int compare(windowinfo o1, windowinfo o2) {             return order.indexof(o1.hwnd)-order.indexof(o2.hwnd);         }             });     return infllist; } public static interface wndenumproc extends stdcalllibrary.stdcallcallback {     boolean callback (int hwnd, int lparam); }  public static interface user32 extends stdcalllibrary {     final user32 instance = (user32) native.loadlibrary ("user32", user32.class);     user32 instance = (user32) native.loadlibrary("user32", user32.class,                w32apioptions.default_options);     boolean enumwindows (wndenumproc wndenumproc, int lparam);     boolean iswindowvisible(int hwnd);     int getwindowrect(int hwnd, rect r);     void getwindowtexta(int hwnd, byte[] buffer, int buflen);     int gettopwindow(int hwnd);     int getwindow(int hwnd, int flag);      hwnd findwindow(string lpclassname, string lpwindowname);      final int gw_hwndnext = 2; } 

note windows (as seen user32 class). class windowinfo holds rectangle, title, , handle each window. thrown mouselistener.

edit: found here https://stackoverflow.com/a/3238193/3502776


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -