新增: 电子相册全屏模式+开机启动+Win10兼容
This commit is contained in:
85
win32.go
85
win32.go
@@ -23,7 +23,8 @@ var (
|
||||
procSetWindowLongPtrW = user32.NewProc("SetWindowLongPtrW")
|
||||
procGetWindowLongPtrW = user32.NewProc("GetWindowLongPtrW")
|
||||
procGetDpiForWindow = user32.NewProc("GetDpiForWindow")
|
||||
procGetClientRect = user32.NewProc("GetClientRect")
|
||||
procGetClientRect = user32.NewProc("GetClientRect")
|
||||
procMessageBoxW = user32.NewProc("MessageBoxW")
|
||||
procGetMessageW = user32.NewProc("GetMessageW")
|
||||
procPostMessageW = user32.NewProc("PostMessageW")
|
||||
procTranslateMessage = user32.NewProc("TranslateMessage")
|
||||
@@ -35,11 +36,28 @@ var wvHwnd uintptr
|
||||
var jsQueue = make(chan string, 64)
|
||||
var paused int32
|
||||
|
||||
const wmEvalJS = 0x0401
|
||||
const wmSetHtml = 0x0402
|
||||
const (
|
||||
wmEvalJS = 0x0401
|
||||
wmSetHtml = 0x0402
|
||||
)
|
||||
|
||||
const (
|
||||
gwlStyle = uintptr(0xFFFFFFF0) // GWL_STYLE = -16
|
||||
wsPopup = uintptr(0x80000000)
|
||||
wsVisible = uintptr(0x10000000)
|
||||
wsChild = uintptr(0x02000000)
|
||||
wsSizebox = uintptr(0x00040000)
|
||||
wsMaxbox = uintptr(0x00010000)
|
||||
)
|
||||
|
||||
var htmlQueue = make(chan string, 1)
|
||||
|
||||
var (
|
||||
classProgman = uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("Progman")))
|
||||
classShellDefView = uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("SHELLDLL_DefView")))
|
||||
classWorkerW = uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("WorkerW")))
|
||||
)
|
||||
|
||||
func evalJS(js string) {
|
||||
select {
|
||||
case jsQueue <- js:
|
||||
@@ -54,21 +72,64 @@ func evalJS(js string) {
|
||||
|
||||
func findWorkerW() uintptr {
|
||||
progman, _, _ := procFindWindowW.Call(
|
||||
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("Progman"))), 0)
|
||||
classProgman, 0)
|
||||
if progman == 0 {
|
||||
log.Println("findWorkerW: Progman not found")
|
||||
return 0
|
||||
}
|
||||
// 发送 0x052C 触发 Progman 创建 WorkerW
|
||||
var result uintptr
|
||||
procSendMessageTimeoutW.Call(progman, 0x052C, 0, 0, 0x0000, 1000, uintptr(unsafe.Pointer(&result)))
|
||||
shellDefView, _, _ := procFindWindowExW.Call(progman, 0,
|
||||
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("SHELLDLL_DefView"))), 0)
|
||||
workerwAfterShell, _, _ := procFindWindowExW.Call(progman, shellDefView,
|
||||
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("WorkerW"))), 0)
|
||||
if workerwAfterShell != 0 {
|
||||
return workerwAfterShell
|
||||
|
||||
// 方法1: Progman 下找 SHELLDLL_DefView,再找其后的 WorkerW
|
||||
shellDefView, _, _ := procFindWindowExW.Call(progman, 0, classShellDefView, 0)
|
||||
if shellDefView != 0 {
|
||||
ww, _, _ := procFindWindowExW.Call(progman, shellDefView, classWorkerW, 0)
|
||||
if ww != 0 {
|
||||
log.Printf("findWorkerW: 方法1成功, WorkerW=0x%x", ww)
|
||||
return ww
|
||||
}
|
||||
}
|
||||
|
||||
// 方法2: 遍历顶层 WorkerW,找到含 SHELLDLL_DefView 的那个,取它后面的 WorkerW
|
||||
var prev uintptr
|
||||
for {
|
||||
ww, _, _ := procFindWindowExW.Call(0, prev, classWorkerW, 0)
|
||||
if ww == 0 {
|
||||
break
|
||||
}
|
||||
child, _, _ := procFindWindowExW.Call(ww, 0, classShellDefView, 0)
|
||||
if child != 0 {
|
||||
// 这个 WorkerW 包含 SHELLDLL_DefView,找它后面的 WorkerW
|
||||
next, _, _ := procFindWindowExW.Call(0, ww, classWorkerW, 0)
|
||||
if next != 0 {
|
||||
log.Printf("findWorkerW: 方法2成功, WorkerW=0x%x (after 0x%x)", next, ww)
|
||||
return next
|
||||
}
|
||||
}
|
||||
prev = ww
|
||||
}
|
||||
|
||||
// 方法3: 遍历顶层 WorkerW,找任意不含 SHELLDLL_DefView 的可见 WorkerW
|
||||
prev = 0
|
||||
for {
|
||||
ww, _, _ := procFindWindowExW.Call(0, prev, classWorkerW, 0)
|
||||
if ww == 0 {
|
||||
break
|
||||
}
|
||||
child, _, _ := procFindWindowExW.Call(ww, 0, classShellDefView, 0)
|
||||
if child == 0 {
|
||||
log.Printf("findWorkerW: 方法3成功, WorkerW=0x%x", ww)
|
||||
return ww
|
||||
}
|
||||
prev = ww
|
||||
}
|
||||
|
||||
// 方法4: 兜底,Progman 下的第一个 WorkerW
|
||||
ww, _, _ := procFindWindowExW.Call(progman, 0, classWorkerW, 0)
|
||||
if ww != 0 {
|
||||
log.Printf("findWorkerW: 方法4(兜底), WorkerW=0x%x", ww)
|
||||
}
|
||||
ww, _, _ := procFindWindowExW.Call(progman, 0,
|
||||
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr("WorkerW"))), 0)
|
||||
return ww
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user