08-07-2024, 04:45 AM
Instead of getting text from the Mouse panel, copy function _MouseInfo from its source code. Remove or replace some lines.
https://github.com/qgindi/LibreAutomate/...elMouse.cs
https://github.com/qgindi/LibreAutomate/...elMouse.cs
var p = mouse.xy;
var c = wnd.fromXY(p);
var w = c.Window;
string wName = w.Name;
string lineSep = "\r\n";
int limit = 10000;
var b = new StringBuilder("<>");
var cn = w.ClassName;
if (cn != null) {
var pc = p; w.MapScreenToClient(ref pc);
b.AppendFormat("<b>Mouse</b> {0,5} {1,5} . <b>in window</b> {2,5} {3,5} .. <b>Program</b> {4}",
p.x, p.y, pc.x, pc.y, w.ProgramName?.Escape(limit));
if (c.UacAccessDenied) b.Append(" <c red>(admin)<>");
b.AppendFormat("{0}<b>Window ", lineSep);
var name = wName?.Escape(limit); if (!name.NE()) b.AppendFormat("</b>{0} . <b>", name);
b.Append("cn</b> ").Append(cn.Escape(limit));
if (c != w) {
b.AppendFormat("{0}<b>Control id</b> {1} . <b>cn</b> {2}",
lineSep, c.ControlId, c.ClassName?.Escape(limit));
var ct = c.Name;
if (!ct.NE()) b.Append(" . <b>name</b> ").Append(ct.Escape(limit));
} else if (cn == "#32768") {
var m = MenuItemInfo.FromXY(p, w, 50);
if (m != null) {
b.AppendFormat("{0}<b>Menu id</b> {1}", lineSep, m.ItemId);
if (m.IsSystem) b.Append(" (system)");
//print.it(m.GetText(true, true));
}
}
//rejected. Makes this func 5 times slower.
//var color = CaptureScreen.Pixel(p);
}
var s = b.ToString();
print.it(s);