This repository was archived by the owner on Feb 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.go
More file actions
84 lines (76 loc) · 2.03 KB
/
control.go
File metadata and controls
84 lines (76 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//go:build windows
package main
import (
"log"
"syscall"
"github.com/tailscale/walk"
. "github.com/tailscale/walk/declarative"
)
// 创建反控窗口
func CreateControlWindow() error {
if controlWindow != nil {
controlWindow.Show()
controlWindow.BringToTop()
return nil
}
err := Dialog{
AssignTo: &controlWindow,
Title: "Mythgone 极域反控",
Icon: func() *walk.Icon {
icon, err := walk.NewIconFromResourceId(2)
if err != nil {
log.Fatal(err)
}
return icon
}(),
MinSize: Size{Width: 200, Height: 200},
Size: Size{Width: 200, Height: 200},
FixedSize: true,
Layout: VBox{Margins: Margins{Left: 12, Top: 12, Right: 12, Bottom: 12}},
CancelButton: nil,
DefaultButton: nil,
Children: []Widget{
VSpacer{},
// 底部链接
Composite{
Layout: HBox{},
Children: []Widget{
HSpacer{},
LinkLabel{
Text: `由 dotcubecn 与所有贡献者开发 (<a href="https://github.com/dotcubecn/mythgone">GitHub</a>)`,
OnLinkActivated: func(link *walk.LinkLabelLink) {
OpenURL(link.URL())
},
},
HSpacer{},
},
},
},
}.Create(mainWindow)
if err != nil {
return err
}
// 同步主窗口状态
if preventCaptureCheckbox != nil && preventCaptureCheckbox.Checked() {
SetWindowDisplayAffinity(syscall.Handle(controlWindow.Handle()), WindowDisplayAffinityExcludeFromCapture)
}
if topmostCheckbox != nil && topmostCheckbox.Checked() {
SetWindowTopmost(syscall.Handle(controlWindow.Handle()), true)
}
// 窗口关闭事件处理
controlWindow.Closing().Attach(func(canceled *bool, reason walk.CloseReason) {
controlWindow = nil
})
controlWindow.Show()
return nil
}
// 更新禁止捕获状态
func UpdateControlWindowCaptureState(preventCapture bool) {
if controlWindow != nil {
if preventCapture {
SetWindowDisplayAffinity(syscall.Handle(controlWindow.Handle()), WindowDisplayAffinityExcludeFromCapture)
} else {
SetWindowDisplayAffinity(syscall.Handle(controlWindow.Handle()), WindowDisplayAffinityNone)
}
}
}