cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Java J-Link Creo Parametric 9.0.7.0 Convert/Get windows of Creo to move them in the screen with JNA

Noah_c
4-Participant

Java J-Link Creo Parametric 9.0.7.0 Convert/Get windows of Creo to move them in the screen with JNA

Good morning everyone, i'm using the java j-link kit asynchronously to automate some task of Creo Parametric 9.0.7.0 (Java11).

Is it possible get the window of Creo Parametric and convert to an HWND in JNA? My purpose is to move the windows of Creo Parametric in the screen and later resize them, i haven't finded a way to get the pointer to inizialize the HWND. Here is a part of my code ("mainCreoApplication" is a class that contain asyncConn Obj, the session obj and the windows management):

 

private static final User32 user32 = User32.INSTANCE;
private void getHWND(){
MainCreoApplication
mainCreoApplication = null;
try {
mainCreoApplication = new MainCreoApplication();
} catch (jxthrowable e) {
throw new RuntimeException(e);
}

Pointer ptr = null;
try {
ptr = new Pointer(mainCreoApplication.getMyAsyncConn().GetSession().GetCurrentWindow().getptr());

} catch (jxthrowable e) {
throw new RuntimeException(e);
}
HWND hwnd = new HWND(ptr);

if (hwnd != null) {
user32.MoveWindow(hwnd, 500, 500,1000,600, true);
}
}
public interface User32 extends com.sun.jna.platform.win32.User32 {
User32 INSTANCE = Native.load("user32", User32.class);

HWND SetParent(HWND hWndChild, HWND hWndNewParent);

boolean MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, boolean bRepaint);
}

Am i in the right direction? Is there a better way to do it?

 

Regards

Noah

2 REPLIES 2
RPN
17-Peridot
17-Peridot
(To:Noah_c)

You don’t get a handle, you get an id. And I don’t think that you will have success with this method. The window title is unique, just visit them and get the handle from here. Pure MS code. 

Hello @nc_10923715

 

It looks like you have a response from a community member. If it helped you solve your question please mark the reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Community Moderation Team.

Announcements


Top Tags