Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get code in the LA code editing area
#1
I remember in previous versions of LA, I could use Ctrl+Shift+E to capture the code editing control, and in the name attribute of that control, retrieve the code.
However, now I cannot retrieve the code from the name attribute. What could be the reason for this? As shown in the screenshot below.
https://i.ibb.co/3WvxPxF/A.gif
#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);
    }
}
#3
thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)