diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/BackgroundHasselhoff.iml b/.idea/BackgroundHasselhoff.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/BackgroundHasselhoff.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f660dbd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..196414e --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module main + +go 1.20 + +require golang.org/x/sys v0.8.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c5eb700 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/imgLocations.txt b/imgLocations.txt new file mode 100644 index 0000000..5e18b1c --- /dev/null +++ b/imgLocations.txt @@ -0,0 +1 @@ +C:\Program Files\BackgroundHasselhoff\imgs \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..7f2bbb0 --- /dev/null +++ b/main.go @@ -0,0 +1,29 @@ +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 any key 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 any key 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) + ".jpg") + procSystemParamInfo.Call(20, 0, uintptr(unsafe.Pointer(imagePath)), 0x001A) +}