This commit is contained in:
Steven Tracey 2023-05-04 13:18:19 -04:00
parent e1f3fae563
commit 7770df3341
7 changed files with 62 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/BackgroundHasselhoff.iml" filepath="$PROJECT_DIR$/.idea/BackgroundHasselhoff.iml" />
</modules>
</component>
</project>

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module main
go 1.20
require golang.org/x/sys v0.8.0

2
go.sum Normal file
View File

@ -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=

1
imgLocations.txt Normal file
View File

@ -0,0 +1 @@
C:\Program Files\BackgroundHasselhoff\imgs

29
main.go Normal file
View File

@ -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)
}