How to know if the "Windows animations" option is disabled in Win32?

Asked

Viewed 49 times

4

In the CSS there is the prefers-reduced-motion. This media-query says that the user prefers reduced animations (off) or not, it respects the configuration that the user chose in the Windows settings (or other operating system):

In Windows 10: Settings > Ease of Access > Display > Show animations in Windows.


How can I get the same information (whether the animations are turned off or not) natively? How the browser itself can identify whether such a feature is disabled?

Is there any Windowproc when this setting is changed?


For more details: I am creating a Windows window using user32.dll (CreateWindowExW), and then drawing her with Opengl. I’m using Golang, calling the DLL via syscall.NewLazySystemDLL. I need to know when animations are off so that the application behavior in Windows and browser are identical.

  • This probably gets recorded in the Windows registry

1 answer

2


You can use the following code:

package main

import (
    "fmt"
    "syscall"
    "unsafe"
)

const (
    SPI_GETCLIENTAREAANIMATION = 0x1042
)

var (
    user32DLL            = syscall.NewLazyDLL("user32.dll")
    systemParametersInfo = user32DLL.NewProc("SystemParametersInfoW")
)

func main() {
    var enabled bool
    _, _, err := systemParametersInfo.Call(uintptr(SPI_GETCLIENTAREAANIMATION), 0, uintptr(unsafe.Pointer(&enabled)), 0)
    if err != syscall.Errno(0) {
        panic(err)
    }

    fmt.Println(enabled)
}

https://play.golang.org/p/vGlfqpcGgLJ

Remembering that you should handle errors correctly, as you are already using the syscall and unsafe package, you obviously have experience with this.

To test the behavior, you can change the Windows configuration in System Properties -> Performance -> Settings

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.