Notifications
Clear all

[Closed] Can you copy something into the maxscript editor via code??

Curious to know if you could click a button and have it
paste a string into the current script you have open.

5 Replies

I didn’t notice any maxscript access to the editor, but things you can easily do are:
A. open a legacy editor with your text:

format "print \"hello world\"
" to:(newscript())

B. copy some text into clipboard so you can paste it yourself:

setclipboardText "print \"hello world\"
"

It may be possible to combine B with a simple commandline application that only sends a Ctrl+V keystroke to get what you want. But keeping the focus on the editor window while you click a button may be tricky.

This may work:

fn SetMXSEditorFocus =
 (
 	local WM_ACTIVATE = 0x0006
 	local GetWindowClassName = UIAccessor.GetWindowClassName
 
 	for hwnd in (UIAccessor.GetChildWindows 0) where (GetWindowClassName hwnd) == "MXS_SciTEWindow" do
 	(
 		windows.sendmessage hwnd WM_ACTIVATE 1 0
 	)
 )

A couple of years ago i developed a plugin which exposes the complete Scintilla component of Maxscript edtor to Maxscript ( plus additional goodies like MXS editor as extended viewport ). This means most Scintilla commands, internal properties etc. can be called and queried using the plugin:
eg Inserting text at the current cursor position would be this maxscript line

MXSEFuncs.call "InsertText" ( MXSEProps.get "CurrentPos" ) "This is the inserted Text"

The embedded command MXSEProps.get “CurrentPos” simply returns the current cursor position ( MXSEProps is a struct and part of the pugin as is MXSEditor, MXSEFuncs, MXSEProps and MXSECallback )

Is there a way of getting current mxseditor line without getting whole document first?


int SCI_GETCURLINE = 2027;
int SCI_GETLINE = 2153;

I tried SendMessage with the above but without any result