Календарь Windows 11
Возможно ли сделать так, чтобы календарь Windows из таскбара не закрывался после клика по другому месту? Пытался искать решение, так и не нашел.
Ответы (1 шт):
Автор решения: Владимир Клыков
→ Ссылка
По просьбе из комментария:
Поиск дескриптора активного окна(Golang):
package main
import (
"fmt"
"syscall"
"time"
"unsafe"
"golang.org/x/sys/windows"
)
var (
mod = windows.NewLazyDLL("user32.dll")
procGetWindowText = mod.NewProc("GetWindowTextW")
procGetWindowTextLength = mod.NewProc("GetWindowTextLengthW")
)
type (
HANDLE uintptr
HWND HANDLE
)
func GetWindowTextLength(hwnd HWND) int {
ret, _, _ := procGetWindowTextLength.Call(
uintptr(hwnd))
return int(ret)
}
func GetWindowText(hwnd HWND) string {
textLen := GetWindowTextLength(hwnd) + 1
buf := make([]uint16, textLen)
procGetWindowText.Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(&buf[0])),
uintptr(textLen))
return syscall.UTF16ToString(buf)
}
func getWindow(funcName string) uintptr {
proc := mod.NewProc(funcName)
hwnd, _, _ := proc.Call()
return hwnd
}
func main() {
for {
if hwnd := getWindow("GetForegroundWindow"); hwnd != 0 {
text := GetWindowText(HWND(hwnd))
fmt.Println(text,hwnd)
time.Sleep(1 * time.Second)
}
}
}
