How to close a window set with same name

21 views
Skip to first unread message

giuseppe...@gmail.com

unread,
Jan 31, 2013, 5:03:18 AM1/31/13
to jniwrapp...@teamdev.com
Hello,
i do have a web application that generates every second a child window named es. "Pippo".
I wish, after i have read the child window content, close this/these windows.
I, to close a single window do use the command:
 
        int WM_SYSCOMMAND = 0x0112;
        int SC_CLOSE = 0xF060;
        Wnd wnd = Wnd.findWindowByName("Pippo");
        wnd.show(Wnd.ShowWindowCommand.SHOWMAXIMIZED);
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            System.out.println("error");
        }
        wnd.sendMessageEx(WM_SYSCOMMAND, SC_CLOSE, 0);
To close, at determinate interval, n windows named "Pippo" how I do?
 
Thanks for reply.
SaSa
 

Sergei Piletsky

unread,
Jan 31, 2013, 8:09:09 AM1/31/13
to giuseppe...@gmail.com, jniwrapp...@teamdev.com
Hi,

I think that there could be several possible solutions. One of then is:

1) get the collection of all those "Pippo" windows at once. You can do this using Wnd.getAllWindows() and then filter out the required Wnd instances by the required window class (Wnd.getWindowClassName()) name or window title Wnd.getWindowText());

2) iterate though that collection and call the wnd.destroy() method for each window.

Sincerely,
Serge

 

--
You received this message because you are subscribed to the Google Groups "JNIWrapper Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jniwrapper-for...@teamdev.com.
To post to this group, send email to jniwrapp...@teamdev.com.
Visit this group at http://groups.google.com/a/teamdev.com/group/jniwrapper-forum/?hl=en.
For more options, visit https://groups.google.com/a/teamdev.com/groups/opt_out.
 
 

giuseppe...@gmail.com

unread,
Feb 1, 2013, 10:48:51 AM2/1/13
to jniwrapp...@teamdev.com, giuseppe...@gmail.com
Thanks,
but it don't runs...
This Exception of Access denied rise-up :
 
Exception in thread "Thread-5" com.jniwrapper.win32.LastErrorException: Error destroying window. Accesso negato.
 at com.jniwrapper.win32.ui.Wnd.destroy(Wnd.java:540)
 at controllo.funzioni.Automazione.chiudiFinestraBrowserFiglio(Automazione.java:159)
How can do I destroy the windows in another way?
Sincerely SaSa

Sergei Piletsky

unread,
Feb 1, 2013, 11:04:11 AM2/1/13
to giuseppe...@gmail.com, jniwrapp...@teamdev.com
Oh, that's right, you cannot destroy a window in such way if it was created by another process, I almost forgot about this restriction. That's actually why you got that exception.

Anyway, having a collection of windows which you need to close you can try sending them the WM_CLOSE message instead of WM_SYSCOMMAND.

Hope this helps.

-
Serge

Reply all
Reply to author
Forward
0 new messages