We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Calling Win32 ShowWindow from Java/JACOB

mdsrobbins
mdsrobbins asked
on
Medium Priority
1,427 Views
Last Modified: 2013-12-22
I'm seeking to call the Windows ShowWindow service from Java via JACOB to restore/minimise a Window of a given title but can't find any examples of doign this.  Can someone provide an example or an alternative means to achieve the same end.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2004
Commented:
Not sure why this is tagged as Groovy, but here goes...

I couldn't find a JACOB example (as they seem to have decided to move their wiki to SF, and not put any documentation up), but I found this library here:

http://jnative.free.fr/

Now, I've never used JNative, but the how-to (showing how to set it up) seems to be here:

http://jnative.free.fr/SPIP-v1-8-3/article.php3?id_article=4

And it looks like you should be able to do the following...

(maybe -- I haven't tried, and I'm not on Windows)



HWND hwnd = org.xvolks.jnative.util.User32.findWindow( null, "Window Title" ) ;
org.xvolks.jnative.util.User32.showWindow( hwnd, org.xvolks.jnative.misc.MSG.WindowsConstants.SW_MINIMIZE ) ;

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks - the code works though as you say it is not JACOB based.  

I have also located serveral other libraries that provdie similar "native" access.  Anyone interested in alternatives should look at the following website:

JavaByExample

I would, however, prefer a JACOB based solution if one exists.  The problem is that JACOB appears to need you to supply a CLSID or PROGID for the library for which it looks up the Registry etc to locate the DLL etc and there does not *appear* to be one for User32.dll.

regards

Author

Commented:
I have had confirmed elsewhere that in fact user32 and other low-level calls in kernel32 etc are NOT COM based services and therefore JACOB cannot be used so JNative or other direct call libraries is the only approach I'm aware of.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.