package main import ( "fmt" "golang.org/x/sys/windows" "math/rand" "os" "strconv" "unsafe" ) func main() { fileBytes, err := os.ReadFile("./imgsLocation.txt") if err != nil { fmt.Printf("Error loading dir info from ./imgsLocation.txt: %v\nPress to continue...", err) fmt.Scanln() os.Exit(1) } files, err := os.ReadDir(string(fileBytes)) if err != nil { fmt.Printf("Error reading images from directory %v: %v\nPress to continue...", string(fileBytes), err) fmt.Scanln() os.Exit(1) } procSystemParamInfo := windows.NewLazyDLL("user32.dll").NewProc("SystemParametersInfoW") imagePath, _ := windows.UTF16PtrFromString(string(fileBytes) + `\` + strconv.Itoa(rand.Intn(len(files)-1)+1) + ".jpg") procSystemParamInfo.Call(20, 0, uintptr(unsafe.Pointer(imagePath)), 0x001A) }