Close parameters window with API

Close parameters window with API

CAD_CAM_MAN
Advocate Advocate
1,211 Views
10 Replies
Message 1 of 11

Close parameters window with API

CAD_CAM_MAN
Advocate
Advocate
I am building an application (for Inventor 2015) that will crash Inventor if the user runs it with the parameters window open. I would like to close the parameters window programmatically before the function causing the crash is executed. Is it possible to close the parameters window through the API if it is open for the active part document? I cannot figure out how to get access to the parameters window object. Does anybody have the syntax to do what I am asking?
0 Likes
Accepted solutions (2)
1,212 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

I am not sure this is going to be usefull, but you could try this, witch is done in C#:

 

In the class declaration insert

[DllImport("User32.Dll", EntryPoint = "PostMessageA")] static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);

const uint WM_KEYDOWN = 0x100;

 

Where you want to close the window, insert 

PostMessage(InventorApp.MainFrameHWND, WM_KEYDOWN, Keys.Escape, 0);

 

InventorApp is the Inventor application object

 

That code should send a escape key stroke that would close any open dialog in Inventor.

 

That's the closest I could get to what you want to do...

 

Hope that will help

 

 

0 Likes
Message 3 of 11

CAD_CAM_MAN
Advocate
Advocate
Thank you Pierre, I should have mentioned I am working in VB.net on this project. Will see if I can work with your suggestion though as I had not thought to try an "ESC" key. Sure would prefer to get ahold of the window object though.
0 Likes
Message 4 of 11

ekinsb
Alumni
Alumni
Accepted solution

Here's some simpler code that results in the same thing.  Essentially, when you press the escape key, the Select command is invoked, which has the side-effect of terminating the currently active command.  The code below will run the Select command.

 

    Dim selectCmd As ControlDefinition
    selectCmd = invApp.CommandManager.ControlDefinitions.Item("AppSelectNorthwestArrowCmd")
    selectCmd.Execute

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 11

CAD_CAM_MAN
Advocate
Advocate
Accepted solution
Thank you Brian for pointing me in this direction. I could not get your code to work as posted but by simply changing "App​SelectNorthwestArrowCmd" to "AppContextual_CancelCmd" the code seems to work as desired.
0 Likes
Message 6 of 11

CAD_CAM_MAN
Advocate
Advocate
Thank you Brian for pointing me in this direction. I could not get your code to work as posted but by simply changing the command to the cancel command it now seems to work as desired. I tried posting my code but the forum keeps rejecting. How do I post code on these posts (sorry new to forums)?
0 Likes
Message 7 of 11

rossano_praderi
Collaborator
Collaborator

When you post a new message...

 

Cattura.JPG

 

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 8 of 11

CAD_CAM_MAN
Advocate
Advocate
This is all I see (attached) when I try to post. Is there a setting for the other buttons? Also what is the quote button for? It does not seem to do anything.
0 Likes
Message 9 of 11

CAD_CAM_MAN
Advocate
Advocate
The attachment does not seem to work either. Regarding the last post I have no buttons below the Rich Text HTML and Preview tabs. I have to be missing something really obvious?
0 Likes
Message 10 of 11

rossano_praderi
Collaborator
Collaborator

Which browser are you using?

 

Do you have any add-in/plugin?

 

Are you receiving any kind of error messages from your browser?

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 11 of 11

CAD_CAM_MAN
Advocate
Advocate
Have tried Microsoft internet explorer, and Firefox. I am going to put this in another post since this is not related to the original question
0 Likes