def set_appusermodel(window_id, appid, icon_path, relaunch_command, relaunch_display_name):
    from win32com.propsys import propsys, pscon
    store = propsys.SHGetPropertyStoreForWindow(window_id, propsys.IID_IPropertyStore)
    id = store.GetValue(pscon.PKEY_AppUserModel_ID)
    store.SetValue(pscon.PKEY_AppUserModel_ID, propsys.PROPVARIANTType(appid))
    store.SetValue(pscon.PKEY_AppUserModel_RelaunchCommand, propsys.PROPVARIANTType(relaunch_command))
    store.SetValue(pscon.PKEY_AppUserModel_RelaunchDisplayNameResource, propsys.PROPVARIANTType(relaunch_display_name))
    store.SetValue(pscon.PKEY_AppUserModel_RelaunchIconResource, propsys.PROPVARIANTType(icon_path))
Exemple #2
0
 def set_window_group(hwnd, lhandle):
     try:
         ps = propsys.SHGetPropertyStoreForWindow(hwnd)
         key = propsys.PSGetPropertyKeyFromName("System.AppUserModel.ID")
         value = propsys.PROPVARIANTType(lhandle)
         log("win32 hooks: calling %s(%s, %s)", ps.SetValue, key, value)
         ps.SetValue(key, value)
     except Exception as e:
         log("set_window_group(%s, %s)", hwnd, lhandle, exc_info=True)
         log.error("Error: failed to set group leader '%s':", lhandle)
         log.error(" %s", e)
Exemple #3
0
 def set_group(leader):
     try:
         log("win32 hooks: set_group(%#x)", leader.handle)
         ps = propsys.SHGetPropertyStoreForWindow(handle)
         key = propsys.PSGetPropertyKeyFromName(
             "System.AppUserModel.ID")
         value = propsys.PROPVARIANTType(leader.handle)
         log("win32 hooks: calling %s(%s, %s)", ps.SetValue, key,
             value)
         ps.SetValue(key, value)
     except Exception as e:
         log.error("failed to set group leader: %s", e)
def set_appusermodel(
    window_id,
    appid=None,
    icon_path=None,
    relaunch_command=None,
    relaunch_display_name=None,
    appname=None,
):
    """Set the appID details for the window, configuring how it appears in the taskbar
    and its pinning/relaunching behaviour. If appid, icon_path, relaunch_command or
    relaunch_display_name are None, they will be inferred from the appname, which must
    not be None if the other arguments are not provided. If the appid matches one of our
    known apps, then the other arguments will be ignored, as if appname was passed in
    and all other arguments were None. This is so that we can fix faulty relaunch
    commands being produced by older versions of the apps whilst accepting how they call
    us, without crashing, for backwards compatibility."""
    _check_windows()

    if appid is not None:
        for known_appname, known_appid in appids.items():
            if appid == known_appid:
                appname = known_appname
                appid = icon_path = relaunch_command = relaunch_display_name = None

    if appid is None:
        appid = appids[appname]
    if icon_path is None:
        icon_path = os.path.join(labscript_installation, appname,
                                 appname + '.ico')
    if relaunch_command is None:
        target, args = launch_command(appname)
        relaunch_command = ' '.join([target, args])
    if relaunch_display_name is None:
        relaunch_display_name = app_descriptions[appname]

    store = propsys.SHGetPropertyStoreForWindow(window_id,
                                                propsys.IID_IPropertyStore)
    id = store.GetValue(pscon.PKEY_AppUserModel_ID)
    store.SetValue(pscon.PKEY_AppUserModel_ID, propsys.PROPVARIANTType(appid))
    store.SetValue(
        pscon.PKEY_AppUserModel_RelaunchCommand,
        propsys.PROPVARIANTType(relaunch_command),
    )
    store.SetValue(
        pscon.PKEY_AppUserModel_RelaunchDisplayNameResource,
        propsys.PROPVARIANTType(relaunch_display_name),
    )
    store.SetValue(pscon.PKEY_AppUserModel_RelaunchIconResource,
                   propsys.PROPVARIANTType(icon_path))
Exemple #5
0
def win32_propsys_set_group_leader(self, leader):
    """ implements set group leader using propsys """
    hwnd = get_window_handle(self)
    if not hwnd:
        return
    try:
        lhandle = leader.handle
    except:
        return
    if not lhandle:
        return
    #returns the setter method we can use
    try:
        log("win32 hooks: set_group(%#x)", lhandle)
        propsys = get_propsys()
        ps = propsys.SHGetPropertyStoreForWindow(hwnd)
        key = propsys.PSGetPropertyKeyFromName("System.AppUserModel.ID")
        value = propsys.PROPVARIANTType(lhandle)
        log("win32 hooks: calling %s(%s, %s)", ps.SetValue, key, value)
        ps.SetValue(key, value)
    except Exception as e:
        log.error("failed to set group leader: %s", e)
    def run(self):
        self.mainWindow = PipboyMainWindow()

        if (self.startedFromWin32Launcher):
            basepath = os.path.dirname(os.path.realpath(__file__))
            launcherpath = os.path.abspath(
                os.path.join(basepath, os.pardir, 'PyPipBoyApp-Launcher.exe'))
            print('launcherpath: ' + str(launcherpath))
            if 'nt' in os.name:
                from win32com.propsys import propsys, pscon
                import pythoncom
                hwnd = self.mainWindow.winId()
                propStore = propsys.SHGetPropertyStoreForWindow(
                    hwnd, propsys.IID_IPropertyStore)
                propStore.SetValue(
                    pscon.PKEY_AppUserModel_ID,
                    propsys.PROPVARIANTType(u'matzman666.pypipboyapp.win32',
                                            pythoncom.VT_ILLEGAL))
                propStore.SetValue(
                    pscon.PKEY_AppUserModel_RelaunchDisplayNameResource,
                    propsys.PROPVARIANTType('PyPipBoyApp',
                                            pythoncom.VT_ILLEGAL))
                propStore.SetValue(
                    pscon.PKEY_AppUserModel_RelaunchCommand,
                    propsys.PROPVARIANTType(launcherpath,
                                            pythoncom.VT_ILLEGAL))
                propStore.Commit()
        # Load Styles
        self._loadStyles()
        # Load widgets
        self.helpWidget = uic.loadUi(os.path.join('ui', 'helpwidget.ui'))
        self.helpWidget.textBrowser.setSource(
            QtCore.QUrl.fromLocalFile(
                os.path.join('ui', 'res', 'helpwidget.html')))
        self.mainWindow.addDockWidget(QtCore.Qt.TopDockWidgetArea,
                                      self.helpWidget)
        self._loadWidgets()
        # Restore saved window state
        savedFullScreen = bool(
            int(self.settings.value('mainwindow/fullscreen', 0)))
        if savedFullScreen:
            self.mainWindow.showFullScreen()
        savedGeometry = self.settings.value('mainwindow/geometry')
        if savedGeometry:
            self.mainWindow.restoreGeometry(savedGeometry)
        savedState = self.settings.value('mainwindow/windowstate')
        if savedState:
            self.mainWindow.restoreState(savedState)
        # Create widgets menu entry
        self.widgetMenu.setTitle('Widgets')
        menuActions = self.mainWindow.menuBar().actions()
        self.mainWindow.menuBar().insertMenu(menuActions[len(menuActions) - 1],
                                             self.widgetMenu)
        # connect with main window
        self.mainWindow.actionConnect.triggered.connect(
            self.startAutoDiscovery)
        self.mainWindow.actionConnectTo.triggered.connect(
            self.showConnectToDialog)
        self.mainWindow.actionDisconnect.triggered.connect(self.disconnect)
        self.mainWindow.actionQuit.triggered.connect(self.requestQuit)
        self.mainWindow.signalWantsToQuit.connect(self.requestQuit)
        self.mainWindow.actionShowAbout.triggered.connect(self.showAboutDialog)
        self.mainWindow.actionShowAboutQt.triggered.connect(self.aboutQt)
        self.mainWindow.actionAuto_Connect_on_Start_up.triggered.connect(
            self.autoConnectToggled)
        self.mainWindow.actionExportData.triggered.connect(self.exportData)
        self.mainWindow.actionImportData.triggered.connect(self.importData)
        self.mainWindow.actionVersionCheck.triggered.connect(
            self.startVersionCheckVerbose)
        stayOnTop = bool(int(self.settings.value('mainwindow/stayOnTop', 0)))
        self.mainWindow.actionStayOnTop.toggled.connect(
            self.setWindowStayOnTop)
        self.mainWindow.actionStayOnTop.setChecked(stayOnTop)
        promptBeforeQuit = bool(
            int(self.settings.value('mainwindow/promptBeforeQuit', 1)))
        self.mainWindow.actionPromptBeforeQuit.toggled.connect(
            self.setPromptBeforeQuit)
        self.mainWindow.actionPromptBeforeQuit.setChecked(promptBeforeQuit)
        self.mainWindow.actionRelayModeSettings.triggered.connect(
            self._slotRelayModeSettings)
        # Init Relay Mode
        self.relayModeEnabled = bool(
            int(self.settings.value('mainwindow/relayModeEnabled', 0)))
        self.relayModeAutodiscovery = bool(
            int(self.settings.value('mainwindow/relayModeAutodiscovery', 0)))
        self.relayModePort = int(
            self.settings.value('mainwindow/relayModePort', 27000))
        self.relayController = RelayController(self.dataManager)
        if self.relayModeEnabled:
            self.relayController.startRelayService(port=self.relayModePort)
            if self.relayModeAutodiscovery:
                self.relayController.startAutodiscoverService()
        # Main window is ready, so show it
        self.mainWindow.init(self, self.networkChannel, self.dataManager)
        self._initWidgets()
        self.mainWindow.show()
        # start main event loop
        if int(self.settings.value('mainwindow/autoconnect', 0)):
            self.mainWindow.actionAuto_Connect_on_Start_up.setChecked(True)
            host = 'localhost'
            port = 27000
            if self.settings.value('mainwindow/lasthost'):
                host = self.settings.value('mainwindow/lasthost')
            if self.settings.value('mainwindow/lastport'):
                port = int(self.settings.value('mainwindow/lastport'))
            self.signalConnectToHost.emit(host, port, True)
        self.startVersionCheck()
        sys.exit(self.exec_())