def getScriptEditorSelection(): ''' this is a hack to bypass an issue with getting the data back from the ScriptEditorHistory scroll. We need to copy the selected text to the clipboard then pull it back afterwards. ''' import Red9.packages.pyperclip as pyperclip control = mel.eval("$v=$gLastFocusedCommandControl") executer = mel.eval("$v=$gLastFocusedCommandExecuter") reporter = mel.eval("$v=$gLastFocusedCommandReporter") func = "" if control == executer: func = cmds.cmdScrollFieldExecuter(control, q=True, selectedText=True) elif control == reporter: cmds.cmdScrollFieldReporter(reporter, e=True, copySelection=True) #func=Clipboard.getText() #pyperclip.py : IN TESTING : Platform independant clipboard support func = pyperclip.paste() log.info('command caught: %s ' % func) return func
def getScriptEditorSelection(): ''' this is a hack to bypass an issue with getting the data back from the ScriptEditorHistory scroll. We need to copy the selected text to the clipboard then pull it back afterwards. ''' import Red9.packages.pyperclip as pyperclip control=mel.eval("$v=$gLastFocusedCommandControl") executer=mel.eval("$v=$gLastFocusedCommandExecuter") reporter=mel.eval("$v=$gLastFocusedCommandReporter") func="" if control==executer: func=cmds.cmdScrollFieldExecuter(control, q=True, selectedText=True) elif control == reporter: cmds.cmdScrollFieldReporter(reporter, e=True, copySelection=True) #func=Clipboard.getText() #pyperclip.py : IN TESTING : Platform independant clipboard support func=pyperclip.paste() log.info('command caught: %s ' % func) return func