Calling Win32 ShowWindow from Java/JACOB

Posted on 2009-02-18
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.
Question by:mdsrobbins
    LVL 35

    Accepted Solution

    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:

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

    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


    Author Comment

    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:


    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.


    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    sumHeights2  challenge 7 50
    how to use external config file with Spring MVC 4 36
    Fibonacci challenge 11 61
    countHi challenge 25 59
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    This video teaches viewers about errors in exception handling.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now