Posts: 1,049
Threads: 249
Joined: Jul 2022
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
Posts: 12,095
Threads: 142
Joined: Dec 2002
03-12-2024, 06:26 AM
(This post was last modified: 03-12-2024, 06:44 AM by Gintaras.)
If the script has role editorExtension:
/*/ 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:
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);
}
}
Posts: 1,049
Threads: 249
Joined: Jul 2022