anyway to add a keyboard shortcut to a script?

functionfunction Posts: 283

[anyway to add a keyboard shortcut to a script?] for example, add Ctrl+D to the script to implement the move to floor function, instead of writing many sentences?

Post edited by Richard Haseltine on

Comments

  • MartirillaMartirilla Posts: 181

    Sounds like you might be wanting to invoke the shortcut of one script from inside another script? But you would first need to assign a shortcut to the first script, thus:

    1. The target scripts' folder. Right-click on the target script. "Create Custom Action". Accept default settings.

    2. If you have the correct UI layout active, up top there's now a Scripts section on the top menu bar. Your script is now pinned there.

    3. Press F3 to open the Customize panel. There select and open the "Custom" section. Your script should be listed there.

    4. Right-click it, "Change Keyboard Shortcut".

    5. Now you have made a shortcut, mouse-action freeware such as StrokesPlus can work with it. For instance, quickly draw a letter with the mouse, and the official Dock Area Toggle script is invoked. No need to squint to find the tiny grey Dock Toggle double-arrows every time.

    (In Poser you just rename your target PoserPython script filename. For instance my_super_script###Alt+R.py and that gives it a shortcut).

  • functionfunction Posts: 283

    Martirilla said:

    Sounds like you might be wanting to invoke the shortcut of one script from inside another script? But you would first need to assign a shortcut to the first script, thus:

    1. The target scripts' folder. Right-click on the target script. "Create Custom Action". Accept default settings.

    2. If you have the correct UI layout active, up top there's now a Scripts section on the top menu bar. Your script is now pinned there.

    3. Press F3 to open the Customize panel. There select and open the "Custom" section. Your script should be listed there.

    4. Right-click it, "Change Keyboard Shortcut".

    5. Now you have made a shortcut, mouse-action freeware such as StrokesPlus can work with it. For instance, quickly draw a letter with the mouse, and the official Dock Area Toggle script is invoked. No need to squint to find the tiny grey Dock Toggle double-arrows every time.

    (In Poser you just rename your target PoserPython script filename. For instance my_super_script###Alt+R.py and that gives it a shortcut).

    no, sorry, not that create shortcut on menu,  I just want to write a script which include the 'move to floor' function, it is somekind complex which I discussed 2 days before, so I thought put the Ctrl+D into the script is an idea.

  • Richard HaseltineRichard Haseltine Posts: 100,707
    edited April 2023
    Post edited by Richard Haseltine on
  • functionfunction Posts: 283
    edited April 2023

    Richard Haseltine said:

    You can use DzActionMgr to launch existing actions. See these samples http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/start#actions

    Thank you very much Richard.  Following your instruction, life becomes easier, now the move to floor script works.

    Here is the link I used:

    1. find the Action name for a shortcut by this example:

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/actionmgr_dz#a_1a0954d953e54681325ef4a1b5666dea6b

    2. trigger the Action example: 

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/actions/action_trigger/start

    Attached is the 'Move to floor' script I made by above examples, it can paste into other scripts.

    -------

    Edited: add CC3 liciense in the beginning of the script.

    dsa
    dsa
    move to floor.dsa
    2K
    Post edited by function on
  • Richard HaseltineRichard Haseltine Posts: 100,707

    Please remember to  obey the rquirements of the CC3 By Attribution license.

Sign In or Register to comment.