Spyder Python "SendKeys"

Spyder Python "SendKeys"

isocam
Collaborator Collaborator
1,108 Views
2 Replies
Message 1 of 3

Spyder Python "SendKeys"

isocam
Collaborator
Collaborator

Can anybody help?

 

Does anybody know if it is possible, using Spyder Python, to use "SendKeys"???

 

I want to send the keys "Ctrl+Alt+N" to fusion 360

 

Many thanks in advance!!!!

 

Darren

0 Likes
1,109 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Hello,

 

I am unclear what you were going to do by sending keyboard keys. We have KeyBoardEvent  API which you can probably refer to. By hooking Command.KeyDown event, you can do something in Fusion 360 according to which keys are pressed in keyboard.

 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-492810d8-b2d6-4c8a-ab92-d283724d70ba

 

Thanks,

Marshal

Message 3 of 3

JeromeBriot
Mentor
Mentor

Hello Darren,

 

here is a solution using the keyboard module (https://pypi.org/project/keyboard/) :

 

#Author-Jerome Briot
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback

from .Modules import keyboard


def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        # Open/close the data panel
        keyboard.press_and_release('ctrl+alt+p')
        adsk.doEvents()

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Hope this helps