@copylee/dsh-computer-use 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/helper/Capture.cs +4 -0
- package/helper/Overlay.cs +166 -103
- package/helper/Program.cs +2 -0
- package/helper/Uia.cs +198 -5
- package/lib/index.js +2675 -2346
- package/lib/types/computer.d.ts +29 -8
- package/lib/types/overlay.d.ts +25 -1
- package/lib/types/prompt.d.ts +3 -1
- package/lib/types/tools.d.ts +2 -0
- package/lib/types/ui-diff.d.ts +15 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
## 典型场景与核心特色
|
|
15
15
|
|
|
16
|
-
### 1. Codex
|
|
16
|
+
### 1. 常驻 Codex 协作光标 + Set-of-Marks 编号标图(密集同名按钮精准定位)
|
|
17
17
|
|
|
18
|
-
面对表格、后台系统里多个同名「编辑 / 通过」按钮,调用 `ui_elements({ marks: true })` 为每个交互控件叠加编号角标(`#1`、`#2`…),模型按 `#编号`
|
|
18
|
+
面对表格、后台系统里多个同名「编辑 / 通过」按钮,调用 `ui_elements({ marks: true })` 为每个交互控件叠加编号角标(`#1`、`#2`…),模型按 `#编号` 直接精准操作(页面变更或执行动作后自动失效防误点);进入操控模式后,Codex 风格光晕与徽章全程伴随指针无重影,点击后按手势变色带细微涟漪,并优先走后台 UIA 语义触发(三态防双点,超时绝不重复物理点击)。
|
|
19
19
|
|
|
20
20
|

|
|
21
21
|
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
|
|
42
42
|
## 一次操作是怎么完成的
|
|
43
43
|
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
44
|
+
- **按需惰性感知 + 省 Token。** 支持窗口截图(画面未变自动去重、紧凑/标准清晰度分档)、Windows UI Automation 定向查询(`ui_elements({ query, role })`)与**增量 Diff(`diff: true`,重复观察最高省 94% 字符)**、**Set-of-Marks 编号标图**、**Windows 内置 OCR** 以及可选本地 **Chromium CDP** 严格单标签快车道。
|
|
45
|
+
- **确定性语义操作 + 参数化宏。** 支持 `ui_action` 幂等 UIA Pattern(`set_checked`、`expand`/`collapse`、`select`、`set_value`),「填字段 → 提交 → 等成功提示」可放入同一个 `computer_batch`;跑通的固定流程还能存为参数化动作宏一键重放。
|
|
46
|
+
- **生态协同与经验沉淀。** 内置 7 模块零依赖 C# Helper(系统自带 `csc.exe` ~350ms 编译);检测到已安装 [`@copylee/dsh-office`](https://github.com/copylee711/dsh-office) 时自动协同路由 Word/Excel/PPT 到原生 COM 后台编辑;设置页「应用技能」支持折叠搜索与弹窗编辑,输入框支持 `@` 引用运行中窗口。
|
|
47
47
|
|
|
48
48
|
## 操控期间,你仍然掌握主动权
|
|
49
49
|
|
|
50
50
|
- **三档会话启用方式**:在 **设置 → 电脑控制** 可选「按会话开启(默认关闭)」「新会话默认开启」或「总是开启(隐藏输入框左下角「电脑控制」胶囊)」;也支持 `/cu on|off|toggle|status|reset|stop|revoke <应用>` 快捷控制。
|
|
51
|
-
-
|
|
52
|
-
-
|
|
51
|
+
- **实时接管感知 + 三档尺寸迷你卡片**:开始操控后,屏幕四周亮起橙色光晕,迷你进度卡片支持**紧凑 / 标准 / 详情**三档尺寸与按钮悬停中文提示,简短中间回复直接留在卡片内不闪弹主窗口;你随时可按 **Esc** 暂停,或直接用鼠标点击/滚轮/键盘接管——插件会自动将脱敏操作语义(控件名称、窗口、坐标,绝不记录密码与输入明文)实时同步给 AI,让它顺着你的意图继续。
|
|
52
|
+
- **多会话租约与纵深安全**:全工具覆盖单机桌面控制租约(防止多 Agent 并发互抢鼠标),统一拦截密码管理器、密码框(UIA `IsPassword` + Win32 `ES_PASSWORD`)、命令解释器启动及跨标签页 CDP 读取;内置 `pnpm run bench` 8 场景基准回归测试与一键导出脱敏诊断报告。
|
|
53
53
|
|
|
54
54
|
正文一开始输出,就回到 DSH 对话阅读。可查看[暂停时的卡片](assets/demo-paused.png)和[任务结束的画面](assets/demo-complete.png)。授权范围、截图和剪贴板的处理规则见[数据与权限](docs/privacy.md)。
|
|
55
55
|
|
package/helper/Capture.cs
CHANGED
|
@@ -121,9 +121,12 @@ namespace DshComputerUse
|
|
|
121
121
|
byte[] prev = Sample(x, y, w, h);
|
|
122
122
|
long quietSince = -1;
|
|
123
123
|
bool stable = false;
|
|
124
|
+
bool skipped = false;
|
|
124
125
|
while (true)
|
|
125
126
|
{
|
|
127
|
+
if (Overlay.SkipWaitRequested) { skipped = true; break; }
|
|
126
128
|
Thread.Sleep(interval);
|
|
129
|
+
if (Overlay.SkipWaitRequested) { skipped = true; break; }
|
|
127
130
|
byte[] cur = Sample(x, y, w, h);
|
|
128
131
|
long now = watch.ElapsedMilliseconds;
|
|
129
132
|
if (Changed(prev, cur) < 0.002) { if (quietSince < 0) quietSince = now - interval; }
|
|
@@ -135,6 +138,7 @@ namespace DshComputerUse
|
|
|
135
138
|
var d = new Dictionary<string, object>();
|
|
136
139
|
d["ms"] = (int)watch.ElapsedMilliseconds;
|
|
137
140
|
d["stable"] = stable;
|
|
141
|
+
if (skipped) d["skipped"] = true;
|
|
138
142
|
return d;
|
|
139
143
|
}
|
|
140
144
|
|
package/helper/Overlay.cs
CHANGED
|
@@ -376,12 +376,22 @@ namespace DshComputerUse
|
|
|
376
376
|
static int keyBurstCount;
|
|
377
377
|
static volatile bool visible;
|
|
378
378
|
static volatile bool paused;
|
|
379
|
+
static volatile bool petWaiting;
|
|
380
|
+
public static volatile bool SkipWaitRequested;
|
|
379
381
|
static volatile bool clickTargetEnabled = true;
|
|
380
382
|
static string cursorBadge = "DeepSeek";
|
|
381
383
|
static LayeredForm markForm;
|
|
382
384
|
static DateTime markExpiresAt = DateTime.MinValue;
|
|
383
385
|
static bool markActive;
|
|
384
386
|
static bool markIsResting;
|
|
387
|
+
static float cachedMarkScale;
|
|
388
|
+
static bool cachedMarkFlipX, cachedMarkFlipY, cachedMarkRipple, cachedMarkArrow;
|
|
389
|
+
static string cachedMarkText = "";
|
|
390
|
+
static Color cachedMarkColor = Color.Empty;
|
|
391
|
+
static int cachedMarkCx, cachedMarkCy;
|
|
392
|
+
static bool hasCachedMarkBitmap;
|
|
393
|
+
static volatile int latestMouseX, latestMouseY;
|
|
394
|
+
static int mouseMovePending;
|
|
385
395
|
static int lastTyping = int.MinValue / 2;
|
|
386
396
|
static int lastEmit;
|
|
387
397
|
static readonly object RectLock = new object();
|
|
@@ -628,6 +638,13 @@ namespace DshComputerUse
|
|
|
628
638
|
Ui(delegate { paused = value; RenderPill(); });
|
|
629
639
|
}
|
|
630
640
|
|
|
641
|
+
public static void SetWaiting(bool value)
|
|
642
|
+
{
|
|
643
|
+
if (thread == null) return;
|
|
644
|
+
if (value) SkipWaitRequested = false;
|
|
645
|
+
Ui(delegate { petWaiting = value; if (visible) RenderPill(); });
|
|
646
|
+
}
|
|
647
|
+
|
|
631
648
|
public static void Hide()
|
|
632
649
|
{
|
|
633
650
|
if (thread == null) return;
|
|
@@ -640,6 +657,8 @@ namespace DshComputerUse
|
|
|
640
657
|
HideMark();
|
|
641
658
|
CloseInput(false);
|
|
642
659
|
petFinished = false;
|
|
660
|
+
petWaiting = false;
|
|
661
|
+
SkipWaitRequested = false;
|
|
643
662
|
petReply = "";
|
|
644
663
|
visible = false;
|
|
645
664
|
paused = false;
|
|
@@ -704,11 +723,11 @@ namespace DshComputerUse
|
|
|
704
723
|
* arrow with white outline, attached rounded name-tag pill (auto-flipping
|
|
705
724
|
* at all 4 screen edges), and a subtle click ripple ring on post-click.
|
|
706
725
|
*/
|
|
707
|
-
static Bitmap DrawMark(string text, Color color, float scale, bool flipX, bool flipY, bool ripple, out int cx, out int cy)
|
|
726
|
+
static Bitmap DrawMark(string text, Color color, float scale, bool flipX, bool flipY, bool ripple, bool drawArrow, out int cx, out int cy)
|
|
708
727
|
{
|
|
709
728
|
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
710
729
|
float px = 1.333f * s;
|
|
711
|
-
float glowR = (ripple ? 20f :
|
|
730
|
+
float glowR = (ripple ? 20f : 17f) * s;
|
|
712
731
|
float pad = 4f * s;
|
|
713
732
|
using (var font = new Font("Microsoft YaHei UI", 8f * px, FontStyle.Bold, GraphicsUnit.Pixel))
|
|
714
733
|
using (var probe = new Bitmap(1, 1))
|
|
@@ -722,9 +741,10 @@ namespace DshComputerUse
|
|
|
722
741
|
float pillW = textSize.Width > 0 ? (float)Math.Ceiling(textSize.Width + 2f * pillPadX) : 0f;
|
|
723
742
|
float pillH = textSize.Height > 0 ? Math.Max(19f * s, (float)Math.Ceiling(textSize.Height + 5f * s)) : 0f;
|
|
724
743
|
|
|
725
|
-
// Offsets relative to the pointer tip at (0, 0).
|
|
726
|
-
|
|
727
|
-
float
|
|
744
|
+
// Offsets relative to the pointer tip at (0, 0). Clear the native Windows pointer
|
|
745
|
+
// arrow cleanly when attaching to the live OS cursor (drawArrow == false).
|
|
746
|
+
float tagX = flipX ? (-10f * s - pillW) : (drawArrow ? 13f * s : 14f * s);
|
|
747
|
+
float tagY = flipY ? (-10f * s - pillH) : (drawArrow ? 15f * s : 18f * s);
|
|
728
748
|
|
|
729
749
|
float minX = Math.Min(-glowR, pillW > 0 ? tagX : 0f) - pad;
|
|
730
750
|
float maxX = Math.Max(glowR, Math.Max(14f * s, pillW > 0 ? tagX + pillW : 0f)) + pad;
|
|
@@ -750,7 +770,7 @@ namespace DshComputerUse
|
|
|
750
770
|
using (var glow = new PathGradientBrush(spot))
|
|
751
771
|
{
|
|
752
772
|
glow.CenterPoint = new PointF(cx, cy);
|
|
753
|
-
glow.CenterColor = Color.FromArgb(ripple ?
|
|
773
|
+
glow.CenterColor = Color.FromArgb(ripple ? 135 : 115, color);
|
|
754
774
|
glow.SurroundColors = new Color[] { Color.FromArgb(0, color) };
|
|
755
775
|
g.FillPath(glow, spot);
|
|
756
776
|
}
|
|
@@ -786,26 +806,31 @@ namespace DshComputerUse
|
|
|
786
806
|
g.DrawString(text, font, fg, bx + (pillW - textSize.Width) / 2f, by + (pillH - textSize.Height) / 2f - 0.5f * s, fmt);
|
|
787
807
|
}
|
|
788
808
|
|
|
789
|
-
// 4.
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
new PointF(cx, cy + 16.5f * s),
|
|
794
|
-
new PointF(cx + 4.3f * s, cy + 12.8f * s),
|
|
795
|
-
new PointF(cx + 7.4f * s, cy + 19.2f * s),
|
|
796
|
-
new PointF(cx + 10.0f * s, cy + 17.9f * s),
|
|
797
|
-
new PointF(cx + 6.9f * s, cy + 11.7f * s),
|
|
798
|
-
new PointF(cx + 12.4f * s, cy + 11.4f * s),
|
|
799
|
-
};
|
|
800
|
-
var arrowShadow = new PointF[arrow.Length];
|
|
801
|
-
for (int i = 0; i < arrow.Length; i++)
|
|
802
|
-
arrowShadow[i] = new PointF(arrow[i].X + 0.8f * s, arrow[i].Y + 1.5f * s);
|
|
803
|
-
using (var sb = new SolidBrush(Color.FromArgb(72, 0, 0, 0))) g.FillPolygon(sb, arrowShadow);
|
|
804
|
-
using (var fill = new SolidBrush(Color.FromArgb(255, color))) g.FillPolygon(fill, arrow);
|
|
805
|
-
using (var outline = new Pen(Color.FromArgb(248, 255, 255, 255), Math.Max(1.2f, 1.5f * s)))
|
|
809
|
+
// 4. Vector cursor arrow ONLY for capturable post-click markers (screenshots do not
|
|
810
|
+
// capture Windows' hardware cursor). Live resting/gliding states omit the fake arrow
|
|
811
|
+
// so Windows' native cursor never double-renders on top of a duplicate arrow.
|
|
812
|
+
if (drawArrow)
|
|
806
813
|
{
|
|
807
|
-
|
|
808
|
-
|
|
814
|
+
var arrow = new PointF[]
|
|
815
|
+
{
|
|
816
|
+
new PointF(cx, cy),
|
|
817
|
+
new PointF(cx, cy + 16.5f * s),
|
|
818
|
+
new PointF(cx + 4.3f * s, cy + 12.8f * s),
|
|
819
|
+
new PointF(cx + 7.4f * s, cy + 19.2f * s),
|
|
820
|
+
new PointF(cx + 10.0f * s, cy + 17.9f * s),
|
|
821
|
+
new PointF(cx + 6.9f * s, cy + 11.7f * s),
|
|
822
|
+
new PointF(cx + 12.4f * s, cy + 11.4f * s),
|
|
823
|
+
};
|
|
824
|
+
var arrowShadow = new PointF[arrow.Length];
|
|
825
|
+
for (int i = 0; i < arrow.Length; i++)
|
|
826
|
+
arrowShadow[i] = new PointF(arrow[i].X + 0.8f * s, arrow[i].Y + 1.5f * s);
|
|
827
|
+
using (var sb = new SolidBrush(Color.FromArgb(72, 0, 0, 0))) g.FillPolygon(sb, arrowShadow);
|
|
828
|
+
using (var fill = new SolidBrush(Color.FromArgb(255, color))) g.FillPolygon(fill, arrow);
|
|
829
|
+
using (var outline = new Pen(Color.FromArgb(248, 255, 255, 255), Math.Max(1.2f, 1.5f * s)))
|
|
830
|
+
{
|
|
831
|
+
outline.LineJoin = LineJoin.Round;
|
|
832
|
+
g.DrawPolygon(outline, arrow);
|
|
833
|
+
}
|
|
809
834
|
}
|
|
810
835
|
}
|
|
811
836
|
return bmp;
|
|
@@ -820,99 +845,107 @@ namespace DshComputerUse
|
|
|
820
845
|
GlideMark(x, y, text, Accent, holdMs, false, false);
|
|
821
846
|
}
|
|
822
847
|
|
|
823
|
-
/**
|
|
824
|
-
|
|
848
|
+
/** Move or render the mark form: uses ultra-fast SetWindowPos when only (x, y) changed. */
|
|
849
|
+
static void PlaceMarkOnUi(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple, bool resting)
|
|
825
850
|
{
|
|
826
|
-
|
|
827
|
-
|
|
851
|
+
lastMarkX = x;
|
|
852
|
+
lastMarkY = y;
|
|
853
|
+
hasLastMark = true;
|
|
854
|
+
if (markForm == null)
|
|
828
855
|
{
|
|
829
|
-
|
|
830
|
-
|
|
856
|
+
markForm = new LayeredForm(true);
|
|
857
|
+
markForm.Show();
|
|
858
|
+
hasCachedMarkBitmap = false;
|
|
859
|
+
}
|
|
860
|
+
markForm.SetCapturable(capturable || !ExcludeFromCapture);
|
|
861
|
+
float scale; Rectangle mon;
|
|
862
|
+
MonitorAt(x, y, out scale, out mon);
|
|
863
|
+
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
864
|
+
string labelText = text ?? "";
|
|
865
|
+
int estW = (int)((Math.Max(6, labelText.Length) * 11 + 36) * s);
|
|
866
|
+
bool flipX = !mon.IsEmpty && x + estW > mon.Right;
|
|
867
|
+
bool flipY = !mon.IsEmpty && y + (int)(52 * s) > mon.Bottom;
|
|
868
|
+
bool drawArrow = capturable;
|
|
869
|
+
|
|
870
|
+
bool sameVisual = hasCachedMarkBitmap
|
|
871
|
+
&& Math.Abs(scale - cachedMarkScale) < 0.01f
|
|
872
|
+
&& flipX == cachedMarkFlipX && flipY == cachedMarkFlipY
|
|
873
|
+
&& ripple == cachedMarkRipple && drawArrow == cachedMarkArrow
|
|
874
|
+
&& labelText == cachedMarkText && color.ToArgb() == cachedMarkColor.ToArgb();
|
|
875
|
+
|
|
876
|
+
if (sameVisual)
|
|
877
|
+
{
|
|
878
|
+
// Pure DWM sprite move (< 0.05ms, zero GDI+ redraw) for native-smooth cursor tracking.
|
|
879
|
+
Native.SetWindowPos(markForm.Handle, IntPtr.Zero, x - cachedMarkCx, y - cachedMarkCy, 0, 0, 0x0001 | 0x0004 | 0x0010);
|
|
831
880
|
}
|
|
832
881
|
else
|
|
833
882
|
{
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
883
|
+
int cx, cy;
|
|
884
|
+
using (var bmp = DrawMark(labelText, color, scale, flipX, flipY, ripple, drawArrow, out cx, out cy))
|
|
885
|
+
{
|
|
886
|
+
markForm.SetBitmap(bmp, new Rectangle(x - cx, y - cy, bmp.Width, bmp.Height), 255);
|
|
887
|
+
}
|
|
888
|
+
cachedMarkScale = scale;
|
|
889
|
+
cachedMarkFlipX = flipX;
|
|
890
|
+
cachedMarkFlipY = flipY;
|
|
891
|
+
cachedMarkRipple = ripple;
|
|
892
|
+
cachedMarkArrow = drawArrow;
|
|
893
|
+
cachedMarkText = labelText;
|
|
894
|
+
cachedMarkColor = color;
|
|
895
|
+
cachedMarkCx = cx;
|
|
896
|
+
cachedMarkCy = cy;
|
|
897
|
+
hasCachedMarkBitmap = true;
|
|
898
|
+
markForm.KeepOnTop();
|
|
837
899
|
}
|
|
900
|
+
markActive = true;
|
|
901
|
+
markIsResting = resting;
|
|
902
|
+
markExpiresAt = holdMs > 0 ? DateTime.UtcNow.AddMilliseconds(holdMs) : DateTime.MaxValue;
|
|
903
|
+
if (!timer.Enabled) timer.Start();
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
static void SyncRestingCursorOnUi()
|
|
907
|
+
{
|
|
908
|
+
Interlocked.Exchange(ref mouseMovePending, 0);
|
|
909
|
+
if (!visible || !clickTargetEnabled || petFinished || !markActive || !markIsResting) return;
|
|
910
|
+
PlaceMarkOnUi(latestMouseX, latestMouseY, cursorBadge, Accent, 0, false, false, true);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/** Smooth EaseOutCubic glide (~150ms @ ~60-90Hz) moving both OS cursor and cached badge in lockstep. */
|
|
914
|
+
public static void GlideMark(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple)
|
|
915
|
+
{
|
|
916
|
+
int startX, startY;
|
|
917
|
+
Native.POINT cur;
|
|
918
|
+
if (Native.GetCursorPos(out cur)) { startX = cur.X; startY = cur.Y; }
|
|
919
|
+
else if (hasLastMark) { startX = lastMarkX; startY = lastMarkY; }
|
|
920
|
+
else { startX = x; startY = y; }
|
|
838
921
|
double dist = Math.Sqrt((double)(x - startX) * (x - startX) + (double)(y - startY) * (y - startY));
|
|
839
|
-
if (dist >=
|
|
922
|
+
if (dist >= 30.0)
|
|
840
923
|
{
|
|
841
|
-
int steps = Math.Max(
|
|
924
|
+
int steps = Math.Max(8, Math.Min(16, (int)(dist / 65.0) + 8));
|
|
842
925
|
for (int i = 1; i < steps; i++)
|
|
843
926
|
{
|
|
844
927
|
double t = (double)i / steps;
|
|
845
928
|
double ease = 1.0 - Math.Pow(1.0 - t, 3.0); // EaseOutCubic
|
|
846
929
|
int ix = startX + (int)Math.Round((x - startX) * ease);
|
|
847
930
|
int iy = startY + (int)Math.Round((y - startY) * ease);
|
|
931
|
+
try { Native.SetCursorPos(ix, iy); } catch (Exception) { }
|
|
848
932
|
Mark(ix, iy, text, color, holdMs, capturable, false);
|
|
849
|
-
Thread.Sleep(
|
|
933
|
+
Thread.Sleep(10);
|
|
850
934
|
}
|
|
851
935
|
}
|
|
936
|
+
try { Native.SetCursorPos(x, y); } catch (Exception) { }
|
|
852
937
|
Mark(x, y, text, color, holdMs, capturable, ripple);
|
|
853
938
|
}
|
|
854
939
|
|
|
855
940
|
static void ShowRestingMarkOnUi(int x, int y)
|
|
856
941
|
{
|
|
857
|
-
|
|
858
|
-
lastMarkY = y;
|
|
859
|
-
hasLastMark = true;
|
|
860
|
-
if (markForm == null)
|
|
861
|
-
{
|
|
862
|
-
markForm = new LayeredForm(true);
|
|
863
|
-
markForm.Show();
|
|
864
|
-
}
|
|
865
|
-
// Resting Codex cursor stays visible to the user during control mode,
|
|
866
|
-
// while remaining invisible to screenshots so it never obscures target pixels.
|
|
867
|
-
markForm.SetCapturable(false);
|
|
868
|
-
float scale; Rectangle mon;
|
|
869
|
-
MonitorAt(x, y, out scale, out mon);
|
|
870
|
-
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
871
|
-
int estW = (int)((Math.Max(6, cursorBadge.Length) * 11 + 36) * s);
|
|
872
|
-
bool flipX = !mon.IsEmpty && x + estW > mon.Right;
|
|
873
|
-
bool flipY = !mon.IsEmpty && y + (int)(52 * s) > mon.Bottom;
|
|
874
|
-
int cx, cy;
|
|
875
|
-
using (var bmp = DrawMark(cursorBadge, Accent, scale, flipX, flipY, false, out cx, out cy))
|
|
876
|
-
{
|
|
877
|
-
markForm.SetBitmap(bmp, new Rectangle(x - cx, y - cy, bmp.Width, bmp.Height), 255);
|
|
878
|
-
}
|
|
879
|
-
markForm.KeepOnTop();
|
|
880
|
-
markActive = true;
|
|
881
|
-
markIsResting = true;
|
|
882
|
-
markExpiresAt = DateTime.MaxValue;
|
|
942
|
+
PlaceMarkOnUi(x, y, cursorBadge, Accent, 0, false, false, true);
|
|
883
943
|
}
|
|
884
944
|
|
|
885
945
|
public static void Mark(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple)
|
|
886
946
|
{
|
|
887
|
-
lastMarkX = x;
|
|
888
|
-
lastMarkY = y;
|
|
889
|
-
hasLastMark = true;
|
|
890
947
|
Ensure();
|
|
891
|
-
Ui(delegate
|
|
892
|
-
{
|
|
893
|
-
if (markForm == null)
|
|
894
|
-
{
|
|
895
|
-
markForm = new LayeredForm(true);
|
|
896
|
-
markForm.Show();
|
|
897
|
-
}
|
|
898
|
-
markForm.SetCapturable(capturable || !ExcludeFromCapture);
|
|
899
|
-
float scale; Rectangle mon;
|
|
900
|
-
MonitorAt(x, y, out scale, out mon);
|
|
901
|
-
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
902
|
-
int estW = (int)((Math.Max(6, (text ?? "").Length) * 11 + 36) * s);
|
|
903
|
-
bool flipX = !mon.IsEmpty && x + estW > mon.Right;
|
|
904
|
-
bool flipY = !mon.IsEmpty && y + (int)(52 * s) > mon.Bottom;
|
|
905
|
-
int cx, cy;
|
|
906
|
-
using (var bmp = DrawMark(text, color, scale, flipX, flipY, ripple, out cx, out cy))
|
|
907
|
-
{
|
|
908
|
-
markForm.SetBitmap(bmp, new Rectangle(x - cx, y - cy, bmp.Width, bmp.Height), 255);
|
|
909
|
-
}
|
|
910
|
-
markForm.KeepOnTop();
|
|
911
|
-
markActive = true;
|
|
912
|
-
markIsResting = false;
|
|
913
|
-
markExpiresAt = holdMs > 0 ? DateTime.UtcNow.AddMilliseconds(holdMs) : DateTime.MaxValue;
|
|
914
|
-
if (!timer.Enabled) timer.Start();
|
|
915
|
-
});
|
|
948
|
+
Ui(delegate { PlaceMarkOnUi(x, y, text, color, holdMs, capturable, ripple, false); });
|
|
916
949
|
}
|
|
917
950
|
|
|
918
951
|
public static void MarkResult(int x, int y, string button, int count, string coordLabel)
|
|
@@ -931,6 +964,7 @@ namespace DshComputerUse
|
|
|
931
964
|
{
|
|
932
965
|
markActive = false;
|
|
933
966
|
markIsResting = false;
|
|
967
|
+
hasCachedMarkBitmap = false;
|
|
934
968
|
markExpiresAt = DateTime.MinValue;
|
|
935
969
|
if (markForm != null)
|
|
936
970
|
{
|
|
@@ -956,7 +990,8 @@ namespace DshComputerUse
|
|
|
956
990
|
// pause / resume / stop, from Esc or the pill buttons.
|
|
957
991
|
static void Press(string action)
|
|
958
992
|
{
|
|
959
|
-
if (action == "stop") { paused = false; Program.EmitEvent("stop", "button"); }
|
|
993
|
+
if (action == "stop") { paused = false; petWaiting = false; SkipWaitRequested = true; Program.EmitEvent("stop", "button"); }
|
|
994
|
+
else if (action == "skip_wait") { petWaiting = false; SkipWaitRequested = true; Program.EmitEvent("skip_wait", "button"); }
|
|
960
995
|
else if (action == "pause") { paused = true; Program.EmitEvent("pause", "user"); }
|
|
961
996
|
else if (action == "resume") { paused = false; pausedByInput = false; Program.EmitEvent("resume", "user"); }
|
|
962
997
|
else if (action == "expand") petExpanded = !petExpanded;
|
|
@@ -1108,19 +1143,24 @@ namespace DshComputerUse
|
|
|
1108
1143
|
if (paused)
|
|
1109
1144
|
{
|
|
1110
1145
|
main = "已暂停"; sub = "按 Esc 继续";
|
|
1111
|
-
actions = new[] { "resume", "stop" }; captions = new[] { "继续", "
|
|
1146
|
+
actions = new[] { "resume", "stop" }; captions = new[] { "继续", "停止控制" };
|
|
1112
1147
|
return;
|
|
1113
1148
|
}
|
|
1114
1149
|
main = label;
|
|
1115
1150
|
sub = Typing() ? "你正在操作,已暂停" : status.Length > 0 ? status : "Esc 暂停";
|
|
1116
|
-
|
|
1151
|
+
if (petWaiting)
|
|
1152
|
+
{
|
|
1153
|
+
actions = new[] { "skip_wait", "stop" }; captions = new[] { "跳过等待", "停止控制" };
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
actions = new[] { "stop" }; captions = new[] { "停止控制" };
|
|
1117
1157
|
}
|
|
1118
1158
|
|
|
1119
1159
|
static string Key()
|
|
1120
1160
|
{
|
|
1121
1161
|
string main, sub; string[] actions, captions;
|
|
1122
1162
|
Content(out main, out sub, out actions, out captions);
|
|
1123
|
-
return main + "|" + sub + "|" + string.Join(",", actions) + "|" + pillAtBottom + "|" + Typing();
|
|
1163
|
+
return main + "|" + sub + "|" + string.Join(",", actions) + "|" + pillAtBottom + "|" + Typing() + "|" + petWaiting;
|
|
1124
1164
|
}
|
|
1125
1165
|
|
|
1126
1166
|
static bool DarkTheme()
|
|
@@ -1184,7 +1224,8 @@ namespace DshComputerUse
|
|
|
1184
1224
|
|
|
1185
1225
|
static string ButtonTip(string act)
|
|
1186
1226
|
{
|
|
1187
|
-
if (act == "stop") return "
|
|
1227
|
+
if (act == "stop") return "停止控制并回到 DSH";
|
|
1228
|
+
if (act == "skip_wait") return "跳过等待,立即继续";
|
|
1188
1229
|
if (act == "pause") return "暂停操控";
|
|
1189
1230
|
if (act == "resume") return "继续操控";
|
|
1190
1231
|
if (act == "expand") return petExpanded ? "收起详情" : "展开详情";
|
|
@@ -1219,8 +1260,10 @@ namespace DshComputerUse
|
|
|
1219
1260
|
|
|
1220
1261
|
bool isCompact = petSize == "compact";
|
|
1221
1262
|
bool isDetailed = petSize == "detailed";
|
|
1222
|
-
string title = petFinished ? "已完成" : (isCompact && label.Length > 12 ? label.Substring(0, 11) + "…" : label);
|
|
1223
1263
|
string hoverTip = ButtonTip(hoveredBtn);
|
|
1264
|
+
string title = hoverTip.Length > 0
|
|
1265
|
+
? (isCompact ? "" : "DeepSeek")
|
|
1266
|
+
: petFinished ? "已完成" : (isCompact && label.Length > 12 ? label.Substring(0, 11) + "…" : label);
|
|
1224
1267
|
string state = hoverTip.Length > 0 ? hoverTip
|
|
1225
1268
|
: petFinished ? "" : paused ? (input != null ? "输入指令中…" : "已暂停 · Esc 继续")
|
|
1226
1269
|
: Typing() ? "你正在操作,已暂停" : (isCompact ? "" : "Esc 暂停");
|
|
@@ -1231,6 +1274,7 @@ namespace DshComputerUse
|
|
|
1231
1274
|
{
|
|
1232
1275
|
actions.Add("stop"); glyphs.Add("\uE71A");
|
|
1233
1276
|
if (paused) { actions.Add("resume"); glyphs.Add("\uE768"); } else { actions.Add("pause"); glyphs.Add("\uE769"); }
|
|
1277
|
+
if (petWaiting && !paused) { actions.Add("skip_wait"); glyphs.Add("\uE893"); }
|
|
1234
1278
|
}
|
|
1235
1279
|
actions.Add("expand"); glyphs.Add(petExpanded ? "\uE70D" : "\uE70E");
|
|
1236
1280
|
if (!petFinished) { actions.Add("input"); glyphs.Add("\uE70F"); }
|
|
@@ -1316,9 +1360,12 @@ namespace DshComputerUse
|
|
|
1316
1360
|
else if (logo != null) g.DrawImage(logo, iconRect);
|
|
1317
1361
|
else using (var brush = new SolidBrush(Accent)) g.FillEllipse(brush, RectangleF.Inflate(iconRect, -3 * s, -3 * s));
|
|
1318
1362
|
float tx = iconRect.Right + 8 * s;
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1363
|
+
if (title.Length > 0)
|
|
1364
|
+
{
|
|
1365
|
+
SizeF headSize = g.MeasureString(title, fHead, 100000, fmt);
|
|
1366
|
+
using (var b = new SolidBrush(ink)) g.DrawString(title, fHead, b, tx, hy + (hh - headSize.Height) / 2f, fmt);
|
|
1367
|
+
tx += headSize.Width + 8 * s;
|
|
1368
|
+
}
|
|
1322
1369
|
|
|
1323
1370
|
buttons.Clear();
|
|
1324
1371
|
float d = (isCompact ? 24f : 26f) * s, bx = body.Right - pad;
|
|
@@ -1328,7 +1375,7 @@ namespace DshComputerUse
|
|
|
1328
1375
|
bx -= d;
|
|
1329
1376
|
var hitRect = new RectangleF(bx, hy + (hh - d) / 2f, d, d);
|
|
1330
1377
|
bool stop = act == "stop";
|
|
1331
|
-
bool on = (act == "input" && input != null) || (act == "resume");
|
|
1378
|
+
bool on = (act == "input" && input != null) || (act == "resume") || (act == "skip_wait");
|
|
1332
1379
|
bool hover = hoveredBtn == act;
|
|
1333
1380
|
bool press = pressedBtn == act;
|
|
1334
1381
|
float inflate = press ? -0.8f * s : hover ? 1.1f * s : 0f;
|
|
@@ -1349,7 +1396,7 @@ namespace DshComputerUse
|
|
|
1349
1396
|
using (var ring = new Pen(Color.FromArgb(dark ? 150 : 120, Accent), Math.Max(1f, 1.2f * s)))
|
|
1350
1397
|
g.DrawEllipse(ring, circle);
|
|
1351
1398
|
}
|
|
1352
|
-
string glyph = glyphFont.Length > 0 ? glyphs[i] : (stop ? "■" : act == "pause" ? "❚❚" : act == "resume" ? "▶" : act == "expand" ? (petExpanded ? "˅" : "˄") : act == "close" ? "✕" : "✎");
|
|
1399
|
+
string glyph = glyphFont.Length > 0 ? glyphs[i] : (stop ? "■" : act == "skip_wait" ? "⏭" : act == "pause" ? "❚❚" : act == "resume" ? "▶" : act == "expand" ? (petExpanded ? "˅" : "˄") : act == "close" ? "✕" : "✎");
|
|
1353
1400
|
Color glyphColor = stop ? Color.White : (hover || on) ? (dark ? Color.White : Color.FromArgb(168, 72, 42)) : ink;
|
|
1354
1401
|
using (var b = new SolidBrush(glyphColor)) g.DrawString(glyph, fGlyph, b, circle, center);
|
|
1355
1402
|
buttons.Add(new KeyValuePair<Rectangle, string>(Rectangle.Round(hitRect), act));
|
|
@@ -1653,7 +1700,23 @@ namespace DshComputerUse
|
|
|
1653
1700
|
if (nCode >= 0 && visible)
|
|
1654
1701
|
{
|
|
1655
1702
|
int msg = wParam.ToInt32();
|
|
1656
|
-
//
|
|
1703
|
+
// Hardware-rate cursor tracking on WM_MOUSEMOVE: never triggers takeover, only moves
|
|
1704
|
+
// the cached resting badge via SetWindowPos for silky native-grade responsiveness.
|
|
1705
|
+
if (msg == 0x0200)
|
|
1706
|
+
{
|
|
1707
|
+
if (clickTargetEnabled && !petFinished && markActive && markIsResting && invoker != null)
|
|
1708
|
+
{
|
|
1709
|
+
var mm = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Native.MSLLHOOKSTRUCT));
|
|
1710
|
+
latestMouseX = mm.pt.X;
|
|
1711
|
+
latestMouseY = mm.pt.Y;
|
|
1712
|
+
if (Interlocked.Exchange(ref mouseMovePending, 1) == 0)
|
|
1713
|
+
{
|
|
1714
|
+
try { invoker.BeginInvoke((MethodInvoker)SyncRestingCursorOnUi); }
|
|
1715
|
+
catch (Exception) { Interlocked.Exchange(ref mouseMovePending, 0); }
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return Native.CallNextHookEx(mouseHook, nCode, wParam, lParam);
|
|
1719
|
+
}
|
|
1657
1720
|
bool isClick = msg == 0x0201 || msg == 0x0204 || msg == 0x0207;
|
|
1658
1721
|
bool isWheel = msg == 0x020A || msg == 0x020E;
|
|
1659
1722
|
if (isClick || isWheel)
|
package/helper/Program.cs
CHANGED
|
@@ -221,6 +221,7 @@ namespace DshComputerUse
|
|
|
221
221
|
case "clipboard_set": if (Args.Bool(r, "agent", false)) Clip.AgentSet(Args.Str(r, "text", "")); else Clip.Set(Args.Str(r, "text", ""), false); return null;
|
|
222
222
|
case "clipboard_restore": { var d = new Dictionary<string, object>(); d["restored"] = Clip.RestoreAgent(); return d; }
|
|
223
223
|
case "ui": return Uia.Elements(r);
|
|
224
|
+
case "ui_find": return Uia.Find(r);
|
|
224
225
|
case "text": return Uia.Text(r);
|
|
225
226
|
case "ocr": return Ocr.Read(r);
|
|
226
227
|
case "marks": return Uia.Marks(r);
|
|
@@ -228,6 +229,7 @@ namespace DshComputerUse
|
|
|
228
229
|
case "ui_point_click": return Uia.ClickAtPoint(r);
|
|
229
230
|
case "overlay_show": Overlay.ExcludeFromCapture = Args.Bool(r, "excludeFromCapture", true); Overlay.Show(r); return null;
|
|
230
231
|
case "overlay_pause": Overlay.SetPaused(Args.Bool(r, "paused", false)); return null;
|
|
232
|
+
case "overlay_waiting": Overlay.SetWaiting(Args.Bool(r, "waiting", false)); return null;
|
|
231
233
|
case "window_card": CardLayer.SetOpacity(Args.Int(r, "opacity", 100)); return Windows.Card(new IntPtr(Convert.ToInt64(r["hwnd"])), Args.Int(r, "x", 0), Args.Int(r, "y", 0), Args.Int(r, "width", 0), Args.Int(r, "height", 0));
|
|
232
234
|
case "window_uncard": return Windows.Uncard(new IntPtr(Convert.ToInt64(r["hwnd"])));
|
|
233
235
|
case "overlay_status": Overlay.Status(Args.Str(r, "status", "")); return null;
|