def _createHotkey(self): if cmds.runTimeCommand('%s_press' % self.ui_txt_name.text(), exists=True): if cmds.confirmDialog(m='name is not unique! replace?', b=['yes', 'no']) == 'no': return else: cmds.runTimeCommand('%s_press' % self.ui_txt_name.text(), delete=True, e=True) cmds.runTimeCommand('%s_release' % self.ui_txt_name.text(), delete=True, e=True) name = self.ui_txt_name.text() menu = self.ui_txt_menu.text() command = self.ui_txt_command.text() hotkey = self.ui_txt_hotkey.text().lower() if not hotkey: return ctrl = self.ui_chb_ctrl.isChecked() alt = self.ui_chb_alt.isChecked() shift = self.ui_chb_shift.isChecked() if self.SELECT == 1: # select based press = "MMtoKey.press_selected(menu='%s', ctl=%s, alt=%s, sh=%s)" % (menu, ctrl, alt, shift) release = "MMtoKey.release_selected('%s', %i)" % (command, self.ui_cmb_language.currentIndex()) else: # preset based press = "MMtoKey.press_preset(ctl=%s, alt=%s, sh=%s)" % (ctrl, alt, shift) release = "MMtoKey.release_preset()" cmds.runTimeCommand('%s_press' % name, c=press, category='MMtoKey', cl='python') cmds.runTimeCommand('%s_release' % name, c=release, category='MMtoKey', cl='python') cmds.nameCommand('%s_PressNameCommand' % name, annotation='%s_press' % name, command='%s_press' % name) cmds.nameCommand('%s_ReleaseNameCommand' % name, annotation='%s_release' % name, command='%s_release' % name) try: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt, sht=shift) except TypeError: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt) cmds.warning('hotkey created')
def __init__ (self, graph, parent=None): '''constructor @param graph the model @param parent a parent QObject, or None for root window. ''' super (MainMayaWindow, self).__init__(parent) QObject.__init__(self) # initiation indispensable for sending and receiving signals! # define scene and constrain its workspace self.scene = QGraphicsScene () self.scene.setSceneRect (QRectF (-1000, -1000, 2000, 2000)) self.graph_model = graph self.helper = utility.Helper (self, self.scene, self.graph_model) self.graph_view = grv.GraphView (self.graph_model, self.helper) self.helper.setGraphView (self.graph_view) # wirings self.comm = self.graph_model.getComm () self.connect (self.comm, SIGNAL ('deleteNode_MSignal(int)'), self.graph_view.removeTag) self.connect (self.comm, SIGNAL ('addLink_MSignal(int,int)'), self.graph_view.addWire) self.connect (self.comm, SIGNAL ('deleteLink_MSignal(int,int)'), self.graph_view.checkIfEmpty) self.connect (self.comm, SIGNAL ('addNode_MSignal(int, float, float)'), self.graph_view.addTag) self.scene.addItem (self.helper.getHarpoon ()) self.hovered_tag_id = None # register a new command that takes care of deleting selected items and bind it to the key 'd'. cmds.nameCommand ('delSelection', ann='deleteSelectedItems', c='python (\"ClientMaya.ui.graph_view.removeSelectedItems ()\");') cmds.hotkey (k='d', name='delSelection')
def keys() : ''' creates some useful keyboard shortcuts (removing existing ones if they exist) ''' kt = "import mocapCleanup.keyTools as kt;kt." la = "import mocapCleanup.labeler as la;la." cmds = [ [ "Home", "alt", "SetCurrent1", "Set Current 1", "p", kt + "setCurrent('1')" ] , [ "Home", "" , "MoveToCurrent1", "Move to current 1", "p", kt + "moveToCurrent('1')" ] , [ "End", "alt", "SetCurrent2", "Set Current 2", "p", kt + "setCurrent('2')" ] , [ "End", "" , "MoveToCurrent2", "Move to current 2", "p", kt + "moveToCurrent('2')" ] , [ "Page_Up", "alt", "SetCurrent3", "Set Current 3", "p", kt + "setCurrent('3')" ] , [ "Page_Up", "" , "MoveToCurrent3", "Move to current 3", "p", kt + "moveToCurrent('3')" ] , [ "Page_Down", "alt", "SetCurrent4", "Set Current 4", "p", kt + "setCurrent('4')" ] , [ "Page_Down", "" , "MoveToCurrent4", "Move to current 4", "p", kt + "moveToCurrent('4')" ] , [ "8", "" , "ExtractSelected", "Extract Selected", "p", kt + "extractSelected()" ] , [ "9", "" , "OneTwoTwo", "One To Two", "p", la + "onetwo()" ] ] for keycode, modifier, name, title, lang, cmd in cmds: if lang == "p" : cmd="python(\"" + cmd + "\")" name = "peel" + name + "NameCommand" print("Setting " + keycode + " " + title + " to " + cmd) m.nameCommand( name, ann=title, c=cmd) if modifier == "alt" : m.hotkey(keyShortcut=keycode, altModifier=True, name=name) else : m.hotkey(keyShortcut=keycode, name=name)
def launchHotkeys(self): if( len(self.hotkeysInfo) == 0 ): mc.error( 'first add some hotkeys with: addHotkey( letter , specialButton , cmd )' ) for keyInfo in self.hotkeysInfo: runTimeCmdName = keyInfo[0] + '_' + self.customCmdBaseName self.runTimeCmdNames.append(runTimeCmdName) nameCmdName = runTimeCmdName + 'NameCommand' specialKeys = [0,0,0] if( keyInfo[2] == 'ctrl' ): specialKeys = [1,0,0] elif( keyInfo[2] == 'alt' ): specialKeys = [0,1,0] elif( keyInfo[2] == 'shift' ): specialKeys = [0,0,1] melToEval = 'runTimeCommand -annotation "" -category "Custom Scripts" -hotkeyCtx "" -default false -commandLanguage "python" -command ( "{0}" ) {1} ; '.format( keyInfo[3] , runTimeCmdName ) mel.eval(melToEval) mc.nameCommand( nameCmdName , sourceType = 'mel' , annotation = nameCmdName , command = runTimeCmdName , default = False ) mc.hotkey( k= keyInfo[1] , ctl= specialKeys[0] , alt = specialKeys[1] , sht = specialKeys[2] , ctxClient = '' , name = nameCmdName )
def setHotkey(hotkey): """Creates a hotkey from a given hotkey dict""" # get hotkey dict data name = hotkey['name'] key = hotkey['key'] alt = hotkey['alt'] ctl = hotkey['ctrl'] release = hotkey['release'] command = hotkey['command'] if release: releaseName = name+"Release" releaseCommand = hotkey['releaseCommand'] # check if this is not a separator if not 'separator' in command: #create hotkey command cmds.nameCommand(name, sourceType="mel", annotation=name, command=command) if release: cmds.nameCommand(releaseName, sourceType="mel", annotation=releaseName, command=releaseCommand) # set hotkey cmds.hotkey(k=key, alt=alt, ctl=ctl, name=name) if release: cmds.hotkey(k=key, alt=alt, ctl=ctl, releaseName=releaseName)
def setUnsetContextHotkeys(): """ Sets / unsets context hotkeys. """ sequence = TRANSFERT_SELECTION_HOTKEY command = "python(\"import snippets.libraries.others as others; reload(others); others.transfertSelectionToUserTarget()\")" name = "transfertSelectionNamedCommand" if cmds.hotkey(sequence, query=True, name=True) != name: print("%s | Assigning '%s' hotkey to '%s' command!" % (__name__, sequence, name)) DEFAULTS_HOTKEYS[sequence] = { "name": cmds.hotkey(sequence, query=True, name=True), "releaseName": cmds.hotkey(sequence, query=True, releaseName=True) } cmds.nameCommand(name, annotation="Transfert Selection", command=command) cmds.hotkey(k=sequence, rcr=True, name=name) else: hotkey = DEFAULTS_HOTKEYS.get(sequence) if hotkey: print("%s | Unassigning '%s' hotkey from '%s' command!" % (__name__, sequence, name)) cmds.hotkey(k=sequence, name=hotkey.get("name"), releaseName=hotkey.get("releaseName")) return True
def setupHotkey(self, name, sourceType='mel'): """Sets up the hotkey and nameCommand only. This is useful when linking to a maya runtimeCommand.""" self.name = name # Make names consistant with Maya's convention self.commandName = name + 'NameCommand' self.sourceType = sourceType if self.release: cmds.hotkey(k=self.key, alt=self.alt, ctl=self.ctl, cmd=self.cmd, rn=self.commandName) else: cmds.hotkey(k=self.key, alt=self.alt, ctl=self.ctl, cmd=self.cmd, n=self.commandName) cmds.nameCommand(self.commandName, ann=self.commandName, c=self.name, stp=self.sourceType)
def setquick(arg): keyadj = cmds.hotkey( '1', query=True, ctl=True ) if keyadj ==False: cmds.nameCommand( 'filebridgemanager', annotation='filebridgemanager',command='source"O:/mocap/SJ_ToolBox/mel_source/filebridge.mel"') cmds.hotkey(k='1',ctl=1,name='filebridgemanager') else: print "已经设置好快捷键!!\n",
def _createHotkey(self): if cmds.runTimeCommand('%s_press' % self.ui_txt_name.text(), exists=True): if cmds.confirmDialog(m='name is not unique! replace?', b=['yes', 'no']) == 'no': return else: cmds.runTimeCommand('%s_press' % self.ui_txt_name.text(), delete=True, e=True) cmds.runTimeCommand('%s_release' % self.ui_txt_name.text(), delete=True, e=True) name = self.ui_txt_name.text() menu = self.ui_txt_menu.text() command = self.ui_txt_command.text() hotkey = self.ui_txt_hotkey.text().lower() if not hotkey: return ctrl = self.ui_chb_ctrl.isChecked() alt = self.ui_chb_alt.isChecked() shift = self.ui_chb_shift.isChecked() if self.SELECT == 1: # select based press = "MMtoKey.press_selected(menu='%s', ctl=%s, alt=%s, sh=%s)" % ( menu, ctrl, alt, shift) release = "MMtoKey.release_selected('%s', %i)" % ( command, self.ui_cmb_language.currentIndex()) else: # preset based press = "MMtoKey.press_preset(ctl=%s, alt=%s, sh=%s)" % (ctrl, alt, shift) release = "MMtoKey.release_preset()" cmds.runTimeCommand('%s_press' % name, c=press, category='MMtoKey', cl='python') cmds.runTimeCommand('%s_release' % name, c=release, category='MMtoKey', cl='python') cmds.nameCommand('%s_PressNameCommand' % name, annotation='%s_press' % name, command='%s_press' % name) cmds.nameCommand('%s_ReleaseNameCommand' % name, annotation='%s_release' % name, command='%s_release' % name) try: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt, sht=shift) except TypeError: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt) cmds.warning('hotkey created')
def initMVGCommand(name, script, source_type, key_sequence, alt=False, ctl=False, command=False, release=False): # Runtime command exists = mel.eval("runTimeCommand -exists {name}".format(name=name)) nameCommand = name + "NameCommand" if exists: cmd = "runTimeCommand -e -c \"{script}\" -cl {sourceType} {cmdName}".format( script=script, sourceType=source_type, cmdName=name) mel.eval(cmd) else: cmd = "runTimeCommand -c \"{script}\" -cl {sourceType} -cat \"MayaMVG\" {cmdName}".format( script=script, sourceType=source_type, cmdName=name) mel.eval(cmd) #Create nameCommand annotation = name cmds.nameCommand(nameCommand, command=name, annotation=name, stp=source_type) #Check for hotkey in optionVar varString = "{0}_hotkey".format(name) cmd = "optionVar -exists {varString}".format(varString=varString) if mel.eval(cmd): cmd = "optionVar -q {varString}".format(varString=varString) keyArray = mel.eval(cmd) key_sequence = keyArray[0] alt = True if keyArray[1] == "1" else False ctl = True if keyArray[2] == "1" else False release = True if keyArray[3] == "1" else False command = True if keyArray[4] == "1" else False # Check hotkey validity commandName = cmds.hotkey(key_sequence, q=True, name=True, ctl=ctl, alt=alt, cmd=command) if commandName != None and commandName != "": #TODO : proper warning print "WARNING : hotkey {hotkey} already assigned to \"{name}\". Please set your own sequence".format( hotkey=key_sequence, name=commandName) return # Bind nameCommands to hotkeys # TODO : use constructHotkeyCommand ? cmds.hotkey(keyShortcut=key_sequence, name=nameCommand, alt=alt, ctl=ctl, cmd=command)
def hotkeySetup(): ''' ''' # ==================== # - Runtime Commands - # ==================== # Copy Weights if mm.eval('runTimeCommand -q -ex rt_copyWeights'): mm.eval('runTimeCommand -e -del rt_copyWeights') mm.eval('runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.copyWeights()" rt_copyWeights') # Paste Weights if mm.eval('runTimeCommand -q -ex rt_pasteWeights'): mm.eval('runTimeCommand -e -del rt_pasteWeights') mm.eval('runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.pasteWeights()" rt_pasteWeights') # Average Weights if mm.eval('runTimeCommand -q -ex rt_averageWeights'): mm.eval('runTimeCommand -e -del rt_averageWeights') mm.eval('runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.averageWeights()" rt_averageWeights') # Auto Average Weights if mm.eval('runTimeCommand -q -ex rt_autoAverageWeights'): mm.eval('runTimeCommand -e -del rt_autoAverageWeights') mm.eval('runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.autoAverageWeights()" rt_autoAverageWeights') # ======================== # - Create Name Commands - # ======================== copyWtCmd = mc.nameCommand( 'copyWeightsNameCommand', ann='copyWeightsNameCommand', sourceType='mel', c='rt_copyWeights' ) pasteWtCmd = mc.nameCommand( 'pasteWeightsNameCommand', ann='pasteWeightsNameCommand', sourceType='mel', c='rt_pasteWeights' ) averageWtCmd = mc.nameCommand( 'averageWeightsNameCommand', ann='averageWeightsNameCommand', sourceType='mel', c='rt_averageWeights' ) autoAverageWtCmd = mc.nameCommand( 'autoAverageWeightsNameCommand', ann='autoAverageWeightsNameCommand', sourceType='mel', c='rt_autoAverageWeights' ) # ============================= # - Create Hotkey Assignments - # ============================= mc.hotkey(keyShortcut='c',alt=True,name=copyWtCmd) mc.hotkey(keyShortcut='v',alt=True,name=pasteWtCmd) mc.hotkey(keyShortcut='x',alt=True,name=averageWtCmd) mc.hotkey(keyShortcut='a',alt=True,name=autoAverageWtCmd)
def create_name_cmd(self, key): cmds.nameCommand( key.name, ann=key.name, c=key.name, # default=True, sourceType=self.script_type, )
def set_hotkey(key, name=None, command='', release_name=None, release_command='', ctrl=False, alt=False): if cmds.runTimeCommand("{0}_runtime_cmd".format(name), query=True, exists=True): cmds.runTimeCommand("{0}_runtime_cmd".format(name), edit=True, delete=True) if cmds.runTimeCommand("{0}_runtime_cmd".format(release_name), query=True, exists=True): cmds.runTimeCommand("{0}_runtime_cmd".format(release_name), edit=True, delete=True) if name: press_runtime_cmd = cmds.runTimeCommand( "{0}_runtime_cmd".format(name), annotation="{0}_runtime_cmd".format(name), command=command, commandLanguage="python") name_cmd = cmds.nameCommand("{0}_name_cmd".format(name), annotation="{0}_name_cmd".format(name), command=press_runtime_cmd) cmds.hotkey(keyShortcut=key, ctrlModifier=ctrl, altModifier=alt, name=name_cmd) if release_name: release_runtime_cmd = cmds.runTimeCommand( "{0}_runtime_cmd".format(release_name), annotation="{0}_runtime_cmd".format(release_name), command=release_command, commandLanguage="python") release_name_cmd = cmds.nameCommand( "{0}_name_cmd".format(release_name), annotation="{0}_name_cmd".format(release_name), command=release_runtime_cmd) cmds.hotkey(keyShortcut=key, ctrlModifier=ctrl, altModifier=alt, releaseName=release_name_cmd) cmds.hotkey(autoSave=True)
def bt_checkCtrFHotkey(): hotkeyExists = cmds.hotkey('f',query=1,ctl=1) if hotkeyExists == 1: print 'CTRL f hotkey already exists. If you\'d like CTRL f to be associated with this tool simply delete the existing hotkey and rerun the tool to auto create.' else: print 'Automatically setting CTRL f as hotkey for this tool' cmds.nameCommand('bt_moveObjToCameraNameCommand',annotation='bt_moveObjToCameraNameCommand', command='bt_moveObjToCamera') runtimeCommandExists = cmds.runTimeCommand('bt_moveObjToCamera', exists=1) if runtimeCommandExists == 0: cmds.runTimeCommand('bt_moveObjToCamera', category='User', command='from bt_moveObjToCamera import *; bt_moveObjToCamera()') cmds.hotkey(keyShortcut='f',ctl=1,name='bt_moveObjToCameraNameCommand')
def categoryHotkeys(self): # X cmds.nameCommand(Cache.currentCategory + '_alt_x', ann= Cache.currentCategory + '_alt_x', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_x()\")") # C cmds.nameCommand(Cache.currentCategory + '_C', ann= Cache.currentCategory + '_C', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.C()\")") cmds.nameCommand(Cache.currentCategory + '_C_release', ann= Cache.currentCategory + '_C_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.C_release()\")") # E cmds.nameCommand(Cache.currentCategory + '_alt_e', ann= Cache.currentCategory + '_alt_e', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_e()\")")
def createTomaytoKeymap(callbackName="tomaytoCB", nameCommandPrefix="tomayto", **kwargs): """ Creates Maya nameCommands and hotkeys for the cartesian product of all keys, modifiers, and press and release states, pointing them all toward a default, global handler. This pointing is done to a default name in the global space, as nameCommands are MEL-only, and, as such, are difficult (but not impossible) to point to existing Python identifiers. This means that a callable of that name must be created in the global space to handle the information from the nameCommands. """ for key in allKeys: for a in [False, True]: for c in [False, True]: modTag = ("_alt" if a else "") + ("_ctrl" if c else "") nameCommandName = nameCommandPrefix + (modTag if modTag else "") + "_" + keyName(key) # Over-escaping required when callback commands are created by mel python calls if key == '"': key = '\\\\\\\"' if key == '\\': key = '\\\\\\\\' # press nameCommand callback = "python(\"" + callbackName + "(\\\"" + key + "\\\", " + str( a) + ", " + str(c) + ", True)\")" cmds.nameCommand(nameCommandName + "_press", annotation=nameCommandName + "_press", command=callback) print "created", nameCommandName + "_press nameCommand" # release nameCommand callback = "python(\"" + callbackName + "(\\\"" + key + "\\\", " + str( a) + ", " + str(c) + ", False)\")" cmds.nameCommand(nameCommandName + "_release", annotation=nameCommandName + "_release", command=callback) print "created", nameCommandName + "_release nameCommand" # hotkey for both press and release nameCommands for current key + mods cmds.hotkey(keyShortcut=key, name=nameCommandName + "_press", releaseName=nameCommandName + "_release", altModifier=a, ctrlModifier=c) print "created", nameCommandName, " press/release hotkey"
def hotkeySetup(): ''' ''' # ==================== # - Runtime Commands - # ==================== # Smooth Weights if mm.eval('runTimeCommand -q -ex rt_smoothWeights'): mm.eval('runTimeCommand -e -del rt_smoothWeights') mm.eval('runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.smoothWeights;reload(glTools.tools.smoothWeights);glTools.tools.smoothWeights.smoothWeights(mc.ls(sl=1),True,True)" rt_smoothWeights') # ======================== # - Create Name Commands - # ======================== smoothWtCmd = mc.nameCommand( 'smoothWeightsNameCommand', ann='smoothWeightsNameCommand', sourceType='mel', c='rt_smoothWeights' ) # ============================= # - Create Hotkey Assignments - # ============================= mc.hotkey(keyShortcut='s',alt=True,name=smoothWtCmd)
def setHotkey(name, config, *args): log.info('setHotkey: name: %s' % name) if 'code' not in config: raise Exception('I need some code to setup a hotkey!') return if 'key' not in config: raise Exception('I need a KEY to setup a hotkey!') return nameCmd = config.get('nameCommand', name + '_NameCommand') # if there is no special category set make it 'User' cat = config.get('cat', 'User') # if there is no doc text/annotation just give it the name for now text = config.get('text', name) lang = config.get('lang', 'python') # create runtimeCommand, which is wisible in Hotkey Editor and contains actual code! runTimeCmd = createRunTimeCommand(name, config['code'], text, cat, lang) # create a nameCommand which is triggered by the hotkey nameCmd = cmds.nameCommand(nameCmd, ann=text, c=runTimeCmd, sourceType=lang) # now the actual hotkey with the keys and modifiers cmds.hotkey(k=config['key'], name=nameCmd, alt=config.get('alt', False), ctl=config.get('ctl', False))
def setup_runTime(self, command = None, commandLanguage = 'mel', annotation = None, suffix = '_prs'): _str_runTime_cmd = self._d_kws['name'] + suffix#...build name string #If our command name exists, we're gonna modify it if mel.eval('runTimeCommand -ex {0};'.format(_str_runTime_cmd)): log.info("{0} command exists, editing...".format(_str_runTime_cmd)) _l_buildArg = ['runTimeCommand -edit'] else: _l_buildArg = ['runTimeCommand'] if annotation is not None: _l_buildArg.append('-ann "{0}"'.format(annotation)) _l_buildArg.extend(['-cat User','-commandLanguage {0}'.format(commandLanguage), '-c "{0}"'.format(command), _str_runTime_cmd,';']) _str_runTimeArg = ' '.join(_l_buildArg) log.debug("arg: " + _str_runTimeArg) try: mel.eval(_str_runTimeArg)#...evaluate the runTime call cause maya sucks and doesn't have a python command for this return mc.nameCommand( _str_runTime_cmd + 'COMMAND', annotation=_str_runTime_cmd, command=_str_runTime_cmd) except Exception,error: log.error("runTime arg failure..." + cgmGeneral._str_hardBreak) print _str_runTimeArg log.error(error) log.error(cgmGeneral._str_hardBreak) return False
def hotkeySetup(): """ """ # ==================== # - Runtime Commands - # ==================== # Smooth Weights if mel.eval('runTimeCommand -q -ex rt_smoothWeights'): mel.eval('runTimeCommand -e -del rt_smoothWeights') mel.eval( 'runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.smoothWeights;reload(glTools.tools.smoothWeights);glTools.tools.smoothWeights.smoothWeights(cmds.ls(sl=1),True,True)" rt_smoothWeights') # ======================== # - Create Name Commands - # ======================== smoothWtCmd = cmds.nameCommand('smoothWeightsNameCommand', ann='smoothWeightsNameCommand', sourceType='mel', c='rt_smoothWeights') # ============================= # - Create Hotkey Assignments - # ============================= cmds.hotkey(keyShortcut='s', alt=True, name=smoothWtCmd)
def create(self, verbose=False): if not self.keys: return for i,k in enumerate(self.keys): name = self.name+'.'+self.functions[i] if verbose: hotkeyPrint = '\t' if self.altModifier[i]: hotkeyPrint+='[Alt]+' if self.ctrlModifier[i]: hotkeyPrint+='[Ctrl]+' hotkeyPrint = hotkeyPrint+'['+k+'] :\t'+name print hotkeyPrint rtc = 'ml_hk_'+self.name+'_'+self.functions[i] nc = rtc+'_NC' if not mc.runTimeCommand(rtc, exists=True): rtc = mc.runTimeCommand(rtc, default=True, annotation=name+' Hotkey generated by ml_toolbox', category='User', command=self.commands[i]) nc = mc.nameCommand(nc, default=True, annotation=name+' nameCommand generated by ml_toolbox', command=rtc) mc.hotkey(keyShortcut=k, alt=self.altModifier[i], ctl=self.ctrlModifier[i], name=nc, releaseName='')
def setup_runTime(self, command = None, commandLanguage = 'mel', annotation = None, suffix = '_prs'): _str_runTime_cmd = self._d_kws['name'] + suffix#...build name string #If our command name exists, we're gonna modify it if mel.eval('runTimeCommand -ex {0};'.format(_str_runTime_cmd)): log.info("{0} command exists, editing...".format(_str_runTime_cmd)) _l_buildArg = ['runTimeCommand -edit'] else: _l_buildArg = ['runTimeCommand'] if annotation is not None: _l_buildArg.append('-ann "{0}"'.format(annotation)) _l_buildArg.extend(['-cat User','-commandLanguage {0}'.format(commandLanguage), '-c "{0}"'.format(command), _str_runTime_cmd,';']) _str_runTimeArg = ' '.join(_l_buildArg) try: mel.eval(_str_runTimeArg)#...evaluate the runTime call cause maya sucks and doesn't have a python command for this return mc.nameCommand( _str_runTime_cmd + 'COMMAND', annotation=_str_runTime_cmd, command=_str_runTime_cmd) except Exception,error: log.error("runTime arg failure..." + cgmGeneral._str_hardBreak) print _str_runTimeArg log.error(error) log.error(cgmGeneral._str_hardBreak) return False
def hotkey(name, key_sequence, script, source_type="python", release_name="", release_script=None, annotation=None): '''A more convenient function for defining maya hotkeys.''' #Create nameCommands if not annotation: annotation = name runtime_cmd(name, script, source_type) cmds.nameCommand( name, command=name, annotation=annotation, stp=source_type) if release_script and release_name: runtime_cmd(release_name, release_script, source_type) cmds.nameCommand( release_name, command=release_name, annotation=annotation, stp=source_type) #Bind nameCommands to hotkeys ctrl = False alt = False ctrl_match = re.search(r"[Cc]trl\+", key_sequence) alt_match = re.search(r"[Aa]lt\+", key_sequence) if ctrl_match: ctrl = True key_sequence = key_sequence.replace(ctrl_match.group(), "") if alt_match: alt = True key_sequence = key_sequence.replace(ctrl_match.group(), "") if not release_name: cmds.hotkey( keyShortcut=key_sequence, name=name, alt=alt, ctl=ctrl) else: cmds.hotkey( keyShortcut=key_sequence, name=name, alt=alt, ctl=ctrl, releaseName=release_name)
def _hotkey(self): """create hotkey""" name = self.ui.line_name.text() if cmds.runTimeCommand('%s_press' % name, exists=True): if cmds.confirmDialog(m='name is not unique! replace?', b=['yes', 'no']) == 'no': return else: cmds.runTimeCommand('%s_press' % name, delete=True, e=True) cmds.runTimeCommand('%s_release' % name, delete=True, e=True) hotkey = self.ui.line_hotkey.text().lower() if not hotkey: return # build menu ctrl = self.ui.chb_ctrl.isChecked() alt = self.ui.chb_alt.isChecked() shift = self.ui.chb_shift.isChecked() if self.COMMANDS[self.ui.cmb_method.currentIndex()][0] == "custom": press = "MMtoKey.pressCustom(ctl=%s, alt=%s, sh=%s, menu_type=%i, menu_name='%s')" press %= ctrl, alt, shift, self.ui.cmb_menu.currentIndex(), self.ui.line_menu.text() elif self.COMMANDS[self.ui.cmb_method.currentIndex()][0] == "selected": press = "MMtoKey.pressSelected(ctl=%s, alt=%s, sh=%s)" % (ctrl, alt, shift) else: press = "MMtoKey.pressPreset(ctl=%s, alt=%s, sh=%s)" % (ctrl, alt, shift) # release command if self.COMMANDS[self.ui.cmb_method.currentIndex()][1] == "custom": release = "MMtoKey.releaseCustom(command_always=%s, command='%s', language=%i)" release %= (self.ui.cmb_menu.currentIndex(), self.ui.line_command.text().replace("'", "\\'"), self.ui.cmb_command.currentIndex()) elif self.COMMANDS[self.ui.cmb_method.currentIndex()][1] == "selected": release = "MMtoKey.releaseSelected()" else: release = "MMtoKey.releasePreset()" # create runtime and name commands cmds.runTimeCommand('%s_press' % name, c=press, category='MMtoKey', cl='python') cmds.runTimeCommand('%s_release' % name, c=release, category='MMtoKey', cl='python') cmds.nameCommand('%s_PressNameCommand' % name, annotation='%s_press' % name, command='%s_press' % name) cmds.nameCommand('%s_ReleaseNameCommand' % name, annotation='%s_release' % name, command='%s_release' % name) try: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt, sht=shift) except TypeError: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt) cmds.warning('hotkey created')
def initMVGCommand(name, script, source_type, key_sequence, alt=False, ctl=False, command=False, release=False): # Runtime command exists = mel.eval("runTimeCommand -exists {name}".format(name=name)) nameCommand = name + "NameCommand" if exists: cmd = "runTimeCommand -e -c \"{script}\" -cl {sourceType} {cmdName}".format(script=script, sourceType=source_type, cmdName=name) mel.eval(cmd) else: cmd = "runTimeCommand -c \"{script}\" -cl {sourceType} -cat \"MayaMVG\" {cmdName}".format(script=script, sourceType=source_type, cmdName=name) mel.eval(cmd) #Create nameCommand annotation = name cmds.nameCommand( nameCommand, command=name, annotation=name, stp=source_type) #Check for hotkey in optionVar varString = "{0}_hotkey".format(name) cmd = "optionVar -exists {varString}".format(varString=varString); if mel.eval(cmd): cmd = "optionVar -q {varString}".format(varString=varString) keyArray = mel.eval(cmd) key_sequence = keyArray[0] alt = True if keyArray[1] == "1" else False ctl = True if keyArray[2] == "1" else False release = True if keyArray[3] == "1" else False command = True if keyArray[4] == "1" else False # Check hotkey validity commandName = cmds.hotkey(key_sequence, q=True, name=True, ctl=ctl, alt=alt, cmd=command) if commandName != None and commandName != "": #TODO : proper warning print "WARNING : hotkey {hotkey} already assigned to \"{name}\". Please set your own sequence".format(hotkey=key_sequence, name=commandName); return # Bind nameCommands to hotkeys # TODO : use constructHotkeyCommand ? cmds.hotkey( keyShortcut=key_sequence, name=nameCommand, alt=alt, ctl=ctl, cmd=command)
def setupHotkey(self, name, sourceType='mel'): """Sets up the hotkey and nameCommand only. This is useful when linking to a maya runtimeCommand.""" self.name = name # Make names consistant with Maya's convention self.commandName = name + 'NameCommand' self.sourceType = sourceType if self.release: cmds.hotkey(k=self.key, alt=self.alt, ctl=self.ctl, cmd=self.cmd, rn=self.commandName) else: cmds.hotkey(k=self.key, alt=self.alt, ctl=self.ctl, cmd=self.cmd, n=self.commandName) cmds.nameCommand( self.commandName, ann=self.commandName, c=self.name, stp=self.sourceType)
def setHotkey(self, hotkeyDict): message = "Are you sure?\n\n" #format message for loopIndex, loopCommand in enumerate(hotkeyDict): command = loopCommand["command"] name = loopCommand["name"] key = loopCommand["hotkey"] alt = loopCommand["alt"] ctl = loopCommand["ctl"] q = cmds.text("query%s" % name, query=True, label=True) commandKeys = "" if ctl: commandKeys += "Ctl + " if alt: commandKeys += "Alt + " message += "%s (%s%s)" % (name, commandKeys, key) if q != "": message += " is assigned to: %s" % q message += "\n" confirm = cmds.confirmDialog(title='Confirm', message=message, button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if confirm == 'Yes': for loopIndex, loopCommand in enumerate(hotkeyDict): command = loopCommand["command"] name = loopCommand["name"] key = loopCommand["hotkey"] alt = loopCommand["alt"] ctl = loopCommand["ctl"] cmds.nameCommand(name, command='python("%s");' % command, annotation=name) cmds.hotkey(k=key, alt=alt, ctl=ctl, name=name) aToolsMod.saveInfoWithUser("hotkeys", name, [key, alt, ctl]) self.updateHotkeyCheck(name) cmds.savePrefs(hotkeys=True)
def createUpdateRunTimeCommand(): runTimeCommandNamePathLangs = getNamePathLang(getRunTimeCommandDir()) runTimeCommandNamePathLangs.sort() updatedMsg = "\nUpdated...\n\n" createdMsg = "\nCreated...\n\n" for runTimeCommandNamePathLang in runTimeCommandNamePathLangs: name, path, commandLanguage = runTimeCommandNamePathLang if cmds.runTimeCommand(name, q=True, exists=True): cmds.runTimeCommand(name, e=True, delete=True) cmds.runTimeCommand(name, category="Custom Scripts", commandLanguage=commandLanguage, command=getCommand(path)) updatedMsg += "'{}' runtime command\n".format(name) else: cmds.runTimeCommand(name, category="Custom Scripts", commandLanguage=commandLanguage, command=getCommand(path)) cmds.nameCommand(name+"NameCommand", annotation=name+"NameCommand", sourceType="mel", command=name) createdMsg += "'{}' runtime command.\n".format(name) cmds.confirmDialog(title="Run Time Command Results",message="{0}\n-----------------------\n{1}".format(updatedMsg, createdMsg))
def SundayHotkeyWrapper(sourceType, name, key, down, release, alt, ctrl, cmd): if sourceType == 'python': print 'Setkey : ' + key + ' - Script : ' + down cmds.nameCommand(name + '_down', annotation = 'annotation_' + name, command = 'python( "' + down + '" )') cmds.nameCommand(name + '_release', annotation = 'annotation_' + release, command = 'python( "' + release + '" )') cmds.hotkey(k = key, name = name + '_down', releaseName = name + '_release', alt = alt, ctl = ctrl, cmd = cmd) else: print 'Setkey : ' + key + ' - Script : ' + down cmds.nameCommand(name + '_down', annotation = 'annotation_' + name, command = down) cmds.nameCommand(name + '_release', annotation = 'annotation_' + release, command = release) cmds.hotkey(k = key, name = name + '_down', releaseName = name + '_release', alt = alt, ctl = ctrl, cmd = cmd)
def runtimeCommand(): if not cmds.runTimeCommand('switchRTC', exists = True): cmds.runTimeCommand('switchRTC', default = True, category = 'User', ann = "switches wieght unlocked influences", c = 'switchInfluence()') cmds.nameCommand('switchNC', ann = "Create a Sphere", default = True, command = 'switchRTC') if version >= 2016: clHotkeySet = "slHotKeySet" if not cmds.hotkeySet (clHotkeySet, exists = True): cmds.hotkeySet(clHotkeySet, source = 'Maya_Default', current = True) else: cmds.hotkeySet (clHotkeySet, e = True, current = True) cmds.hotkey(k = ';', n = 'switchNC')
def registerHotkey(): """ Register hotkey to set focus to the search field, the hotkey combination registered is Ctrl + Alt + Space. If a hotkey is already registered to that combination a failed message will be printed. """ hk = "rjCMDSearchHK" cmd = 'python("import {0}; {0}.focus()")'.format(__name__) registered = cmds.hotkey("Space", alt=1, ctl=1, query=1, name=1) # check if a hotkey is already registered to the key combination if registered and registered != hk: print "Search Commands: installation failed ( Hotkey )" return # register hotkey cmds.nameCommand(hk, annotation="Ctrl + Alt + Space", command=cmd) cmds.hotkey(k="Space", alt=1, ctl=1, name=hk) print "Search Commands: installation succeeded ( Hotkey )"
def setUnsetContextHotkeys(): """ This definition sets / unsets context hotkeys. """ sequence = TRANSFERT_SELECTION_HOTKEY command = "python(\"import snippets.libraries.others as others; reload(others); others.transfertSelectionToUserTarget()\")" name = "transfertSelectionNamedCommand" if cmds.hotkey(sequence, query=True, name=True) != name: print("%s | Assigning '%s' hotkey to '%s' command!" % (__name__, sequence, name)) DEFAULTS_HOTKEYS[sequence] = {"name" : cmds.hotkey(sequence, query=True, name=True), "releaseName" : cmds.hotkey(sequence, query=True, releaseName=True)} cmds.nameCommand(name, annotation="Transfert Selection", command=command) cmds.hotkey(k=sequence, rcr=True, name=name) else: hotkey = DEFAULTS_HOTKEYS.get(sequence) if hotkey: print("%s | Unassigning '%s' hotkey from '%s' command!" % (__name__, sequence, name)) cmds.hotkey(k=sequence, name=hotkey.get("name"), releaseName=hotkey.get("releaseName")) return True
def reassignCommandsAtStartup(self): allHotkeys = hotkeys.getHotkeys() hotkeysDict = [] for n, loopHotkey in enumerate(allHotkeys): for loopItem in loopHotkey: hotkeysDict.append(loopItem) for loopCommand in hotkeysDict: command = loopCommand["command"] name = loopCommand["name"] key = loopCommand["hotkey"] alt = loopCommand["alt"] ctl = loopCommand["ctl"] #toolTip = loopCommand["toolTip"] label = self.hotkeyCheck(key, ctl, alt) if label == name: cmds.nameCommand(name, command='python("%s");'%command, annotation=name)
def setHotkey(self, hotkeyDict): message = "Are you sure?\n\n" #format message for loopIndex, loopCommand in enumerate(hotkeyDict): command = loopCommand["command"] name = loopCommand["name"] key = loopCommand["hotkey"] alt = loopCommand["alt"] ctl = loopCommand["ctl"] q = cmds.text("query%s"%name, query=True, label=True) commandKeys = "" if ctl: commandKeys += "Ctl + " if alt: commandKeys += "Alt + " message += "%s (%s%s)"%(name, commandKeys, key) if q != "": message += " is assigned to: %s"%q message += "\n" confirm = cmds.confirmDialog( title='Confirm', message=message, button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' ) if confirm == 'Yes': for loopIndex, loopCommand in enumerate(hotkeyDict): command = loopCommand["command"] name = loopCommand["name"] key = loopCommand["hotkey"] alt = loopCommand["alt"] ctl = loopCommand["ctl"] cmds.nameCommand(name, command='python("%s");'%command, annotation=name) cmds.hotkey(k=key, alt=alt, ctl=ctl, name=name) aToolsMod.saveInfoWithUser("hotkeys", name, [key, alt, ctl]) self.updateHotkeyCheck(name) cmds.savePrefs( hotkeys=True )
def bt_checkCtrFHotkey(): hotkeyExists = cmds.hotkey('f', query=1, ctl=1) if hotkeyExists == 1: print 'CTRL f hotkey already exists. If you\'d like CTRL f to be associated with this tool simply delete the existing hotkey and rerun the tool to auto create.' else: print 'Automatically setting CTRL f as hotkey for this tool' cmds.nameCommand('bt_moveObjToCameraNameCommand', annotation='bt_moveObjToCameraNameCommand', command='bt_moveObjToCamera') runtimeCommandExists = cmds.runTimeCommand('bt_moveObjToCamera', exists=1) if runtimeCommandExists == 0: cmds.runTimeCommand( 'bt_moveObjToCamera', category='User', command='from bt_moveObjToCamera import *; bt_moveObjToCamera()' ) cmds.hotkey(keyShortcut='f', ctl=1, name='bt_moveObjToCameraNameCommand')
def setHotkey(hotkey): # get hotkey dict data name = hotkey['name'] key = hotkey['key'] alt = hotkey['alt'] ctl = hotkey['ctrl'] release = hotkey['release'] command = hotkey['command'] if release: releaseName = name+"Release" releaseCommand = hotkey['releaseCommand'] #create hotkey command cmds.nameCommand(name, sourceType="mel", annotation=name, command=command) if release: cmds.nameCommand(releaseName, sourceType="mel", annotation=releaseName, command=releaseCommand) # set hotkey cmds.hotkey(k=key, alt=alt, ctl=ctl, name=name) #print 'set hotkey:', name, key, alt, ctrl, command if release: cmds.hotkey(k=key, alt=alt, ctl=ctl, releaseName=releaseName)
def _register_hotkey(): script_path = os.path.dirname(__file__) + "/scripts" command = """ # ------------------------- # MayaWindowSwitcher # Author: @tm8r # https://github.com/tm8r/MayaWindowSwitcher # ------------------------- import os import sys from maya import cmds def switch_window(): script_path = "{0}" if not os.path.exists(script_path): cmds.error("WindowSwitcher install directory is not found. path={0}") return if script_path not in sys.path: sys.path.insert(0, script_path) import window_switcher.view window_switcher.view.WindowSwitcher.switch() switch_window()""".format(script_path) command_name = "WindowSwitcher" if cmds.runTimeCommand(command_name, ex=True): cmds.runTimeCommand(command_name, e=True, delete=True) cmds.runTimeCommand(command_name, ann="Open WindowSwitcher", category="User", command=command, commandLanguage="python") named_command = command_name + "Command" named_command = cmds.nameCommand( named_command, annotation="Open WindowSwitcher", command=command_name, ) if int(cmds.about(v=True)) <= 2015: cmds.hotkey(k="T", ctl=True, n=named_command) return cmds.hotkey(k="t", ctl=True, sht=True, n=named_command)
def create(self, verbose=False): if not self.keys: return for i, k in enumerate(self.keys): name = self.name + '.' + self.functions[i] if verbose: hotkeyPrint = '\t' if self.altModifier[i]: hotkeyPrint += '[Alt]+' if self.ctrlModifier[i]: hotkeyPrint += '[Ctrl]+' hotkeyPrint = hotkeyPrint + '[' + k + '] :\t' + name print hotkeyPrint rtc = 'ml_hk_' + self.name + '_' + self.functions[i] nc = rtc + '_NC' if not mc.runTimeCommand(rtc, exists=True): rtc = mc.runTimeCommand(rtc, default=True, annotation=name + ' Hotkey generated by ml_toolbox', category='User', command=self.commands[i]) nc = mc.nameCommand(nc, default=True, annotation=name + ' nameCommand generated by ml_toolbox', command=rtc) mc.hotkey(keyShortcut=k, alt=self.altModifier[i], ctl=self.ctrlModifier[i], name=nc, releaseName='')
def assignDefaultHotkey(cmd_name, cmd_string, cmd_annotation, cmd_hotkey): exists = cmds.runTimeCommand(cmd_name, exists=True) if exists: cmds.runTimeCommand(cmd_name, edit=True, delete=True) runtime = cmds.runTimeCommand(cmd_name, command=cmd_string, category='User', annotation=cmd_annotation) if not exists: command = cmds.nameCommand(command=runtime, sourceType='python', annotation=cmd_annotation) cmds.hotkey(altModifier=True, keyShortcut=cmd_hotkey, releaseName=command, releaseCommandRepeat=True) cmds.evalDeferred( Callback(log, 'Assigned default hotkey (ALT+%s) for command: %s.', cmd_hotkey, cmd_name)) return
def set_hotkey(self, name, mode, sequence, open_cmd, close_cmd, switch_cmd): from maya import cmds, mel current_hotkey_set = cmds.hotkeySet(current=True, query=True) if current_hotkey_set == 'Maya_Default': msg = 'The current hotkey set is locked, change in the hotkey editor' warning('Hotbox designer', msg) return mel.eval('hotkeyEditorWindow;') use_alt = 'Alt' in sequence use_ctrl = 'Ctrl' in sequence use_shift = 'Shift' in sequence touch = sequence.split('+')[-1] show_name = 'showHotbox_{n}'.format(n=name) hide_name = 'hideHotbox_{n}'.format(n=name) switch_name = 'switchHotbox_{n}'.format(n=name) if mode == SETMODE_PRESS_RELEASE: cmds.nameCommand(show_name, annotation='show {n} hotbox'.format(n=name), command=format_command_for_mel(open_cmd), sourceType='python') cmds.nameCommand(hide_name, annotation='hide {n} hotbox'.format(n=name), command=format_command_for_mel(close_cmd), sourceType='python') cmds.hotkey(keyShortcut=touch, altModifier=use_alt, ctrlModifier=use_ctrl, shiftModifier=use_shift, name=show_name, releaseName=hide_name) else: cmds.nameCommand(switch_name, annotation='switch {n} hotbox'.format(n=name), command=format_command_for_mel(switch_cmd), sourceType='python') cmds.hotkey(keyShortcut=touch, altModifier=use_alt, ctrlModifier=use_ctrl, shiftModifier=use_shift, name=switch_name)
def create(self, verbose=False): if not self.keys: return for i, k in enumerate(self.keys): name = self.name + "." + self.functions[i] if verbose: hotkeyPrint = "\t" if self.altModifier[i]: hotkeyPrint += "[Alt]+" if self.ctrlModifier[i]: hotkeyPrint += "[Ctrl]+" hotkeyPrint = hotkeyPrint + "[" + k + "] :\t" + name print hotkeyPrint rtc = "ml_hk_" + self.name + "_" + self.functions[i] nc = rtc + "_NC" if not mc.runTimeCommand(rtc, exists=True): rtc = mc.runTimeCommand( rtc, default=True, annotation=name + " Hotkey generated by ml_toolbox", category="User", command=self.commands[i], ) nc = mc.nameCommand( nc, default=True, annotation=name + " nameCommand generated by ml_toolbox", command=rtc ) mc.hotkey(keyShortcut=k, alt=self.altModifier[i], ctl=self.ctrlModifier[i], name=nc, releaseName="")
def hotkeySetup(): """ """ # ==================== # - Runtime Commands - # ==================== # Copy Weights if mel.eval('runTimeCommand -q -ex rt_copyWeights'): mel.eval('runTimeCommand -e -del rt_copyWeights') mel.eval( 'runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.copyWeights()" rt_copyWeights' ) # Paste Weights if mel.eval('runTimeCommand -q -ex rt_pasteWeights'): mel.eval('runTimeCommand -e -del rt_pasteWeights') mel.eval( 'runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.pasteWeights()" rt_pasteWeights' ) # Average Weights if mel.eval('runTimeCommand -q -ex rt_averageWeights'): mel.eval('runTimeCommand -e -del rt_averageWeights') mel.eval( 'runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.averageWeights()" rt_averageWeights' ) # Auto Average Weights if mel.eval('runTimeCommand -q -ex rt_autoAverageWeights'): mel.eval('runTimeCommand -e -del rt_autoAverageWeights') mel.eval( 'runTimeCommand -annotation "" -category "User" -commandLanguage "python" -command "import glTools.tools.copyPasteWeights;reload(glTools.tools.copyPasteWeights);glTools.tools.copyPasteWeights.autoAverageWeights()" rt_autoAverageWeights' ) # ======================== # - Create Name Commands - # ======================== copyWtCmd = cmds.nameCommand('copyWeightsNameCommand', ann='copyWeightsNameCommand', sourceType='mel', c='rt_copyWeights') pasteWtCmd = cmds.nameCommand('pasteWeightsNameCommand', ann='pasteWeightsNameCommand', sourceType='mel', c='rt_pasteWeights') averageWtCmd = cmds.nameCommand('averageWeightsNameCommand', ann='averageWeightsNameCommand', sourceType='mel', c='rt_averageWeights') autoAverageWtCmd = cmds.nameCommand('autoAverageWeightsNameCommand', ann='autoAverageWeightsNameCommand', sourceType='mel', c='rt_autoAverageWeights') # ============================= # - Create Hotkey Assignments - # ============================= cmds.hotkey(keyShortcut='c', alt=True, name=copyWtCmd) cmds.hotkey(keyShortcut='v', alt=True, name=pasteWtCmd) cmds.hotkey(keyShortcut='x', alt=True, name=averageWtCmd) cmds.hotkey(keyShortcut='a', alt=True, name=autoAverageWtCmd)
def registerHotkeys( ): cmds.nameCommand( 'renameSelectedNode', annotation='Rename Selected Node', command='python "dox.hotkeys.renameSelectedNode()"' ) cmds.hotkey( k='f2', name='renameSelectedNode' ) cmds.nameCommand( 'copySelectedNodeName', annotation='Copy Selected Node Name', command='python "dox.hotkeys.copySelectedNodeName()"' ) cmds.hotkey( k='f3', name='copySelectedNodeName' )
try: if welcomescreeninitialized: print("Already Registered") pass except: if cmds.runTimeCommand(name, q=True, exists=True): cmds.runTimeCommand(name, e=True, delete=True) if not cmds.runTimeCommand(name, q=True, exists=True): cmds.runTimeCommand(name, annotation=annotation, command=command, commandLanguage="python", category="Custom Scripts") cmds.nameCommand("{0}NameCommand".format(name), annotation=annotation, command=name) if cmds.hotkeySet(q=True, current=True) == "Maya_Default": if not cmds.hotkeySet("Custom", q=True, exists=True): cmds.hotkeySet("Custom", current=True) else: cmds.hotkeySet("Custom", edit=True, current=True) cmds.hotkey(keyShortcut="w", ctl=True, sht=True, name="{0}NameCommand".format(name)) ### Register Menu ### MainMayaWindow = mel.eval('$tmpVar=$gMainWindow')
def createHotkeyAndRequiredFromEntry(self, entry ): hotkeySetAtFunctionStart = pm.hotkeySet( current=True, query=True ) i = entry pm.hotkeySet( i['set'], current=True, edit=True ) ## Determine which modifiers are being used. (Because Maya is already naturally ## sensitive to shift, by using capitals or symbols, we don't test for shift. try: try: isCtl=i['ctl'] except: isCtl=False try: isAlt=i['alt'] except: isAlt=False except: pass ## Based on the above logic, generate strings to be used while creating the hotkeys. if isAlt == True: AltString = " Alt + " else: AltString = " " if isCtl == True: CtlString = " Ctrl + " else: CtlString = " " if not i.get('doRelease',False): ## Create a printout of the command being made and the hotkey that will use it. print( "About to add runTimeCommand and nameCommand named "\ + i['name'] + " Pushing: " + CtlString + AltString + i['key'] ) try: if cmds.runTimeCommand( i['name'], q=True, exists=True ): cmds.runTimeCommand( i['name'], e=True, delete=True ) cmds.runTimeCommand( i['name'], annotation=i['annotation'], category="Custom Scripts", commandLanguage="mel", hotkeyCtx="", command=i['mel'] ) except: print( "Error Creating Runtime Command" ) print( traceback.format_exc() ) try: cmds.nameCommand( i['name']+"NameCommand", annotation=i['annotation'], sourceType='mel', command=i['name'] ) except: print( "Error Creating Named Command" ) ## Add the actual hotkey to Maya. try: cmds.hotkey( k=i['key'], name=i['name']+"NameCommand", ctl=isCtl, alt=isAlt) except: print( "Error Binding Hotkey" ) print( traceback.format_exc() ) if i.get('doRelease',False): ## Create a printout of the command being made and the hotkey that will use it. print( "About to add nameCommandRelease named " + i['name'] + " Releasing: " + CtlString + AltString + i['key'] ) try: if cmds.runTimeCommand( i['name']+"Release", q=True, exists=True ): cmds.runTimeCommand( i['name']+"Release", e=True, delete=True ) cmds.runTimeCommand( i['name']+"Release", annotation=i['annotation'], category="Custom Scripts", commandLanguage="mel", hotkeyCtx="", command=i['mel'] ) except: print( "Error Creating Runtime Command" ) print( traceback.format_exc() ) try: cmds.nameCommand( i['name']+"Release", annotation=i['annotation']+"Release", command=i['mel']+"Release" ) except: print( "Error Creating Named Command" ) ## Add the actual hotkey to Maya. try: ##Its very important that Release is added to name string below. cmds.hotkey( k=i['key'], ctl=isCtl, alt=isAlt ,releaseName=i['name']+"Release" ) except: print( "Error Binding Hotkey" ) pm.hotkeySet( hotkeySetAtFunctionStart, current=True, edit=True )
def main(): print '# Custom Hotkey Set Creation Tool' # HotKey Set Creation. Omitting now. Currently ''' ### Delete Current Custom Hotkey Sets. sSet = 'CustomHotkeySet' sSetBU = '%sBU'%sSet# This one is the BU set to be duplicated from. aSet = [str(s) for s in cmds.hotkeySet(q = True, hotkeySetArray = True)] # Delete previously created Custom Hotkey Sets. if sSet in aSet: cmds.hotkeySet(sSet, edit = True, delete = True) print '%s found. Deleted.'% sSet if sSetBU in aSet: cmds.hotkeySet(sSetBU, edit = True, delete = True) print '%s found. Deleted.'% sSetBU # Create a fresh custom Set. (Create BU first for Toggle tool. WIll create sSet at the end of the run.) cmds.hotkeySet(sSetBU, current = True) print '%s Created.'% sSetBU ''' ### Create Scripts in the Editor. ## # Get List of Hotkeys from HotKeys.py sScriptName = 'HotKeys' # remove '.py' sScriptPath = '/vol/transfer/dyabu/Scripts/mayaScripts' oHotKeys = imp.load_source(sScriptName, '%s/%s.py' % (sScriptPath, sScriptName)) # Getting List of keys from HotKeys.py (List of all Custom Hotkeys.) aKeyList = oHotKeys.KeyList().keys() #print aKeyList #aKeyList = ['9_N_P','N_ALT_R',] # temp. for testing aKeyList = ['L_ALT_P', 'L_ALT_R'] # temp. for testing for k in aKeyList: if not cmds.runTimeCommand(k, ex=True): #mel.eval('runTimeCommand -delete %s '%k) # Not working.... #cmds.runTimeCommand(k, delete = True) aKey = k.split('_') # Custom Shortcut command. sCommand = '''# Custom Hotkey - Consolidated - v0.0.2 # CUSTOMIZE HERE: p = '%s/' # Path to HotKeys.py sChar = '%s' # Key on Keyboard. not case sensitive. sPress = '%s' # 'P' or 'R' Pressed or Release # -- Start -- import maya.cmds as cmds import sys if p not in sys.path: sys.path.append(p) import Hotkeys # Hotkeys.py reload(HotKeys) #Use reload when testing. Comment out when in actual use. iModifier = cmds.getModifiers() HotKeys.Execute(sChar, iModifier, sPress) ''' % (sScriptPath, aKey[0], aKey[2]) aMod = [False, False, False, False] if 'SFT' in aKey: aMod[0] = True if 'CTL' in aKey: aMod[1] = True if 'ALT' in aKey: aMod[2] = True if 'CMD' in aKey: aMod[3] = True sNameCommand = k + aKey[ 2] # Specific name of the command to assign to a key. if 'P' in aKey[2]: aRelease = [sNameCommand, False] else: aRelease = [False, sNameCommand] # Key Exceptions dExceptions = { 'SPACE': 'Space', 'COMMA': ',', } if aKey[0] in dExceptions.keys(): sKey = dExceptions[aKey[0]] else: sKey = aKey[0] # Continue here : Shift turns on for some reason cmds.runTimeCommand(k, annotation=k.replace('_', ' '), category="Custom Scripts", command=(sCommand), showInHotkeyEditor=1) cmds.hotkey(keyShortcut=aKey[0].lower(), sht=aMod[0], ctl=aMod[1], alt=aMod[2], cmd=aMod[3], name=None, rn=None) cmds.nameCommand(sNameCommand, ann=k.replace('_', ' '), c=k, stp='python') cmds.hotkey(keyShortcut=aKey[0].lower(), sht=aMod[0], ctl=aMod[1], alt=aMod[2], cmd=aMod[3], name=aRelease[0], rn=aRelease[1]) print '%s : CREATED!' % k
def setHotkeys(pref): '''set hotkeys according to pref dictionary''' #first reset resetHotkeys() hotkeys = hotkeyDict[pref] #outliner cmds.nameCommand( 'OutlinerWindowNameCommand', ann='OutlinerWindowNameCommand', c='OutlinerWindow') cmds.hotkey( k=hotkeys[1], alt=hotkeys[0], name='OutlinerWindowNameCommand', releaseName='') #attribute editor cmds.nameCommand( 'AttributeEditorNameCommand', ann='AttributeEditorNameCommand', c='AttributeEditor') cmds.hotkey( k=hotkeys[2], alt=hotkeys[0], name='AttributeEditorNameCommand', rn='') #graph editor cmds.nameCommand( 'GraphEditorNameCommand', ann='GraphEditorNameCommand', c='GraphEditor') cmds.hotkey( k=hotkeys[3], alt=hotkeys[0], name='GraphEditorNameCommand' ) #tool settings cmds.nameCommand( 'ToolSettingsWindowNameCommand', ann='ToolSettingsWindowNameCommand', c='ToolSettingsWindow') cmds.hotkey( k=hotkeys[4], alt=hotkeys[0], name='ToolSettingsWindowNameCommand' ) #trax editor cmds.nameCommand( 'CharacterAnimationEditorNameCommand', ann='CharacterAnimationEditorNameCommand', c='CharacterAnimationEditor') cmds.hotkey( k=hotkeys[5], ctl=True, name='CharacterAnimationEditorNameCommand' ) if lib.checkAboveVersion(2015): #versions below 2016 don't have shift modifier in hotkey command #special key cmds.nameCommand( 'SpecialKeyNameCommand', ann='Set a Special Keyframe', c='python("import coopAnimUtils;coopAnimUtils.keySpecial()")') cmds.hotkey( k=hotkeys[6], alt=True, name='SpecialKeyNameCommand' ) #breakdown key cmds.nameCommand( 'BreakdownKeyNameCommand', ann='Key only keyed attributes', c='python("import coopAnimUtils;coopAnimUtils.keyInbetween()")') cmds.hotkey( k=hotkeys[6], sht=True, name='BreakdownKeyNameCommand' ) #curvesel key TODO #cmds.nameCommand( 'ScriptEditorNameCommand', ann='ScriptEditorNameCommand', c='ScriptEditor') #cmds.hotkey( k=hotkeys[6], sht=True, name='ScriptEditorNameCommand' ) #script editor cmds.nameCommand( 'ScriptEditorNameCommand', ann='ScriptEditorNameCommand', c='ScriptEditor') cmds.hotkey( k='i', alt=True, name='ScriptEditorNameCommand' ) print pref + " hotkeys set (to change or reset hotkeys, right mouse click on the same shelf button\n",
def _hotkey(self): """create hotkey""" name = self.ui.line_name.text() if cmds.runTimeCommand('%s_press' % name, exists=True): if cmds.confirmDialog(m='name is not unique! replace?', b=['yes', 'no']) == 'no': return else: cmds.runTimeCommand('%s_press' % name, delete=True, e=True) cmds.runTimeCommand('%s_release' % name, delete=True, e=True) hotkey = self.ui.line_hotkey.text().lower() if not hotkey: return # build menu ctrl = self.ui.chb_ctrl.isChecked() alt = self.ui.chb_alt.isChecked() shift = self.ui.chb_alt.isChecked() if self.COMMANDS[self.ui.cmb_method.currentIndex()][0] == "custom": press = "MMtoKey.pressCustom(ctl=%s, alt=%s, sh=%s, menu_type=%i, menu_name='%s')" press %= ctrl, alt, shift, self.ui.cmb_menu.currentIndex( ), self.ui.line_menu.text() elif self.COMMANDS[self.ui.cmb_method.currentIndex()][0] == "selected": press = "MMtoKey.pressSelected(ctl=%s, alt=%s, sh=%s)" % ( ctrl, alt, shift) else: press = "MMtoKey.pressPreset(ctl=%s, alt=%s, sh=%s)" % (ctrl, alt, shift) # release command if self.COMMANDS[self.ui.cmb_method.currentIndex()][1] == "custom": release = "MMtoKey.releaseCustom(command_always=%s, command='%s', language=%i)" release %= (self.ui.cmb_menu.currentIndex(), self.ui.line_command.text().replace("'", "\\'"), self.ui.cmb_command.currentIndex()) elif self.COMMANDS[self.ui.cmb_method.currentIndex()][1] == "selected": release = "MMtoKey.releaseSelected()" else: release = "MMtoKey.releasePreset()" # create runtime and name commands cmds.runTimeCommand('%s_press' % name, c=press, category='MMtoKey', cl='python') cmds.runTimeCommand('%s_release' % name, c=release, category='MMtoKey', cl='python') cmds.nameCommand('%s_PressNameCommand' % name, annotation='%s_press' % name, command='%s_press' % name) cmds.nameCommand('%s_ReleaseNameCommand' % name, annotation='%s_release' % name, command='%s_release' % name) try: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt, sht=shift) except TypeError: cmds.hotkey(k=hotkey, name='%s_PressNameCommand' % name, releaseName='%s_ReleaseNameCommand' % name, ctl=ctrl, alt=alt) cmds.warning('hotkey created')
def SetHotKeys(): if 'MayaGame' in cmds.hotkeySet(q=True, hotkeySetArray=True): cmds.hotkeySet('MayaGame', edit=True, delete=True) cmds.hotkeySet('MayaGame', current=True) cmds.nameCommand('pushKeyUp', ann='Push Up Key', c='python("MayaGame.PushKeyUp(True)")') cmds.nameCommand('pushKeyDown', ann='Push Down Key', c='python("MayaGame.PushKeyDown(True)")') cmds.nameCommand('pushKeyLeft', ann='Push Left Key', c='python("MayaGame.PushKeyLeft(True)")') cmds.nameCommand('pushKeyRight', ann='Push Right Key', c='python("MayaGame.PushKeyRight(True)")') cmds.nameCommand('releaseKeyUp', ann='Release Up Key', c='python("MayaGame.PushKeyUp(False)")') cmds.nameCommand('releaseKeyDown', ann='Release Down Key', c='python("MayaGame.PushKeyDown(False)")') cmds.nameCommand('releaseKeyLeft', ann='Release Left Key', c='python("MayaGame.PushKeyLeft(False)")') cmds.nameCommand('releaseKeyRight', ann='Release Right Key', c='python("MayaGame.PushKeyRight(False)")') cmds.hotkey(keyShortcut='Up', name='pushKeyUp', releaseName='releaseKeyUp') cmds.hotkey(keyShortcut='Down', name='pushKeyDown', releaseName='releaseKeyDown') cmds.hotkey(keyShortcut='Left', name='pushKeyLeft', releaseName='releaseKeyLeft') cmds.hotkey(keyShortcut='Right', name='pushKeyRight', releaseName='releaseKeyRight')
def globalHotkeys(self): # ~ cmds.nameCommand('tilde', ann= 'tilde', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.tilde()\")") cmds.nameCommand('alt_tilde', ann= 'alt_tilde', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_tilde()\")") cmds.nameCommand('ctrl_tilde', ann= 'ctrl_tilde', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_tilde()\")") # 1 cmds.nameCommand('one', ann= 'one', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.one()\")") cmds.nameCommand('alt_one', ann= 'alt_one', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_one()\")") cmds.nameCommand('shift_one', ann= 'shift_one', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.shift_one()\")") # 2 cmds.nameCommand('two', ann= 'two', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.two()\")") cmds.nameCommand('alt_two', ann= 'alt_two', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_two()\")") cmds.nameCommand('shift_two', ann= 'shift_two', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.shift_two()\")") # 3 cmds.nameCommand('three', ann= 'three', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.three()\")") cmds.nameCommand('alt_three', ann= 'alt_three', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_three()\")") cmds.nameCommand('shift_three', ann= 'shift_three', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.shift_three()\")") # 4 cmds.nameCommand('alt_four', ann= 'alt_four', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_four()\")") # 5 cmds.nameCommand('alt_five', ann= 'alt_five', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_five()\")") # Q cmds.nameCommand('q', ann= 'q', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.q()\")") cmds.nameCommand('alt_q', ann= 'alt_q', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_q()\")") cmds.nameCommand('q_release', ann= 'q_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.q_release()\")") # W cmds.nameCommand('w', ann= 'w', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.w()\")") cmds.nameCommand('w_release', ann= 'w_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.w_release()\")") # E cmds.nameCommand('e', ann= 'e', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.e()\")") cmds.nameCommand('e_release', ann= 'e_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.e_release()\")") cmds.nameCommand('ctrl_e', ann= 'ctrl_e', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_e()\")") # R cmds.nameCommand('r', ann= 'r', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.r()\")") cmds.nameCommand('R', ann= 'R', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.R()\")") cmds.nameCommand('ctrl_r', ann= 'ctrl_r', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_r()\")") cmds.nameCommand('r_release', ann= 'r_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.r_release()\")") cmds.nameCommand('alt_r', ann= 'alt_r', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_r()\")") # H cmds.nameCommand('h', ann= 'h', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.h()\")") # L cmds.nameCommand('ctrl_l', ann= 'ctrl_l', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_l()\")") # P cmds.nameCommand('alt_p', ann= 'alt_p', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_p()\")") cmds.nameCommand('ctrl_p', ann= 'ctrl_p', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_p()\")") cmds.nameCommand('alt_p_release', ann= 'alt_p_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_p()\")") # F cmds.nameCommand('F', ann= 'F', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.F()\")") # B cmds.nameCommand('alt_b', ann= 'alt_b', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_b()\")") # M cmds.nameCommand('ctrl_m', ann= 'ctrl_m', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_m()\")") cmds.nameCommand('ctrl_M', ann= 'ctrl_M', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_M()\")") cmds.nameCommand('M', ann= 'M', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.M()\")") cmds.nameCommand('m', ann= 'm', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.m()\")") # D cmds.nameCommand('d', ann= 'd', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.d()\")") cmds.nameCommand('alt_d', ann= 'alt_d', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_d()\")") # I cmds.nameCommand('i', ann= 'i', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.i()\")") cmds.nameCommand('alt_i', ann= 'alt_i', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_i()\")") cmds.nameCommand('ctrl_i', ann= 'ctrl_i', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_i()\")") # O cmds.nameCommand('o', ann= 'o', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.o()\")") # G cmds.nameCommand('alt_g', ann= 'alt_g', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_g()\")") # C cmds.nameCommand('c', ann= 'c', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.c()\")") cmds.nameCommand('c_release', ann= 'c_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.c_release()\")") cmds.nameCommand('alt_c', ann= 'alt_c', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_c()\")") cmds.nameCommand('alt_shift_c', ann= 'alt_shift_c', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_shift_c()\")") # V cmds.nameCommand('v', ann= 'v', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.v()\")") cmds.nameCommand('v_release', ann= 'v_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.v_release()\")") # X cmds.nameCommand('x', ann= 'x', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.x()\")") cmds.nameCommand('x_release', ann= 'x_release', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.x_release()\")") # S cmds.nameCommand('S', ann= 'S', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.S()\")") cmds.nameCommand('alt_s', ann= 'alt_s', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_s()\")") cmds.nameCommand('alt_S', ann= 'alt_S', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.alt_S()\")") cmds.nameCommand('ctrl_S', ann= 'ctrl_S', stp='python', c="python(\"from JR_hk_cmds import *;i=Hotkeys();i.ctrl_S()\")")