Emulate shortcut press (iLogic)

Emulate shortcut press (iLogic)

Maxim-CADman77
Advisor Advisor
935 Views
4 Replies
Message 1 of 5

Emulate shortcut press (iLogic)

Maxim-CADman77
Advisor
Advisor

I'd like to know how can I programmatically emulate pressing keyboard shortcut.

 

I'm aware that emulating key press is a lame practice but I don't see any alternative way to force Inventor behave in the way I prefer.

I want to have Projection type "Perspective with ortho faces" be active "by default" in 3D-modelling environments but corresponding idea published in 2013 seems to have no chances to be implemented (under-voted).

 

I see there is a possibility to set up keyboard shortcut with the mode I'm interested in (and manuall pressingdoes the trick). The problem - its effect is limited to the active 3Dmodel only. I need to remember pressing the shortcut for each newely opened 3Dmodel which is quite tedious.

 

I also see threads that desribes key-press emulating within Inventor's child windows but I fail to emulate key-press without those windows.

 

Let say I want to emulate pressing Help-button with iLogic,

 

I believe it should look like

 

System.Windows.Forms.SendKeys.SendWait("{F1}")

 

But it does nothing.

 

What I'm missing?

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
936 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

I think maybe this is what you are looking for.  This is what makes it work for me.

AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("{F1}")

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Maxim-CADman77
Advisor
Advisor

I confirm your solution works for Help-Call-shortcut but for some reason it doesn't work for Clear-Screen-shortcut ("Ctrl+0") which i try to call in this way:

AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("^0")

Don't you have any guess why?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

I'm not sure why some things work with SendKeys while other do not, but perhaps you can achieve your goal of setting the "Perspective with Ortho Faces" setting in another, more stable way.  For instance, by executing its command.

Here are a few commands you can play around with:

To enable the view cube use this one:  "AppViewCubeCmd"

Then you can use one of these

"AppViewCubePerspectiveOrthoCmd"

"AppPerspectiveOrthoCameraCmd"

'or to switch back

"AppViewCubeHomeCmd"

"AppViewCubeOrthographicCmd"

"AppViewCubePerspectiveCmd"

"AppOrthographicCameraCmd"

"AppPerspectiveCameraCmd"

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

Maxim-CADman77
Advisor
Advisor

My first guessing regarding instability of SendKeys command was that it works only for OS shortcuts and so-called Reserved* Inventor shortcuts.

But testing revealed that even out of the Reserved shortcuts very few can be really emulated with the command. Thus it seems you are right and it is impossible to produce the desired workaround using SendKeys command as a core ...and I have no any further ideas for now.

 

* I've counted 13 non-customizable Inventor shortcuts :

Alt+F1

Alt+F8

Alt+F11

Ctrl+C

Ctrl+Enter

Ctrl+V

Ctrl+X

F5

F6

F7

F10

Shift+F3

Shift+F5

...which of course is not a complete list of shortcuts that user can't set as a custom command (other are: F1, Tab, Space, BackSpace, CapsLock, Shift+Ins ... etc...)

Please vote for Inventor-Idea Text Search within Option Names

0 Likes