Forum: Poser Python Scripting


Subject: Useful Code Snippets

structure opened this issue on Jun 27, 2019 ยท 94 posts


structure posted Fri, 25 December 2020 at 9:13 AM Forum Coordinator

get Poser's install directory from the windows registry While this is actually mostly redundant
thanks to Poser's AppLocation() it does show how to access the registry to read keys / data.

import winreg as reg


class _REGISTRY:
    def _find_poser_win(self, version):
        poser = r"SOFTWARE\\Poser Software\\Poser\\Poser %d" % version
        with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, poser) as key:
            if poser.endswith(str(version)) and key:
                return(reg.QueryValueEx(key, "InstallDir")[0])

# example code


installdirs = []
for version in (10, 11, 12):
    print(f"testing Poser {version}")
    try:
        installdir = _REGISTRY()._find_poser_win(version)
    except:
        installdir = "Not Installed"
    if not installdir in installdirs:
        installdirs.append(installdir)
    print(installdir)

Locked Out