Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get code in the LA code editing area
#2
If the script has role editorExtension:
Code:
Copy      Help
/*/ role editorExtension; testInternal Au.Editor; r Au.Editor.dll; r Au.Controls.dll; /*/
var doc = Panels.Editor.ActiveDoc;
if (doc == null) return; //all closed
var text = doc.aaaText;
print.it(text);

Else:
Code:
Copy      Help
print.it(C.LaGetCodeEditorText());


class C {
    public static unsafe string LaGetCodeEditorText() {
        var w = wnd.find(0, "LibreAutomate", "HwndWrapper[Au.Editor;*");
        var c = w.Child("document", "Scintilla");
        if (c.Is0) return null; //all closed
        
        const int SCI_GETLENGTH = 2006;
        const int SCI_GETTEXT = 2182;
        
        int n = _Sci(SCI_GETLENGTH);
        if (n < 1) return "";
        
        using var pm = new ProcessMemory(c, n + 1000, noException: true);
        if (pm.Mem == 0) return null;
        n = _Sci(SCI_GETTEXT, n + 1, pm.Mem);
        return pm.ReadByteString(n);
        
        int _Sci(int message, nint wparam = 0, nint lparam = 0)
            => (int)c.Send(message, wparam, lparam);
    }
}


Messages In This Thread
Get code in the LA code editing area - by Davider - 03-11-2024, 12:47 PM
RE: Get code in the LA code editing area - by Gintaras - 03-12-2024, 06:26 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)