Kodi Community Forum

Full Version: ActivateWindowAndFocus to activate add-on's settings dialog
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I understand that the settings dialog could be opened using "Addon.OpenSettings", however, I am wishing to open the add-on settings dialog and focus a certain category/control in it. Is it possible to use ActivateWindowAndFocus by passing the add-on settings dialog id and category/control id, and if so how can I find the id of the add-on's settings dialog?
Well, turn out current add-on settings dialog id is "10140". So I was able to activate it with
Code:
ActivateWindow(10140)
Also, the category (tabs) id in the settings dialog is 9, and the settings (control) area id is 2. (OK=10, Cancel=11, Default=12).
So I could focus the category area with
Code:
SetFocus(9)
However, I couldn't set the focus on the second category (tab) or any other category (tab), it only focus on the first one. I tried specifying the position paramter but nothing changed:
Code:
SetFocus(9, 2)
Same with the control area (id=2)... I was only able to focus the first item.

Maybe I misused the focusing function, so could someone help me with this?
I don't believe this is possible, as activating the window alone doesn't set it up with the appropriate add-on.
True, because it only show the last loaded settings dialog (if loaded). But you can still use xbmcaddon.openSettings() instead of ActivateWindow, then SetFocus will do the rest (at least focusing Tab/Content/Buttons). However, I still cannot focus elements inside the tab/content area.
Well, I managed to do it once I learned that you can enable debugging for skins, and see the IDs of the controls on-screen while in debug mode. Here is a wrapped up function that open the settings dialog for a given Addon ID, and focus a certain setting inside a certain category by providing their offsets.

PHP Code:
# addonId is the Addon ID
# id1 is the Category (Tab) offset (0=first, 1=second, 2...etc)
# id2 is the Setting (Control) offse (0=first, 1=second, 2...etc)
# Example: OpenAddonSettings('plugin.video.name', 2, 3)
# This will open settings dialog focusing on fourth setting (control) inside the third category (tab)

def openAddonSettings(addonIdid1=Noneid2=None):
    
xbmc.executebuiltin('Addon.OpenSettings(%s)' addonId)
    if 
id1 != None:
        
xbmc.executebuiltin('SetFocus(%i)' % (id1 200))
    if 
id2 != None:
        
xbmc.executebuiltin('SetFocus(%i)' % (id2 100)) 

It will allow opening current or other add-on settings, and giving focus to a specific setting (provided that the offsets are correct).
Hope this will help someone in the future.
Hi There,

I have a similar problem.
I want to know the id of the window or action which gave you the list of subtitle languages available

I narrowed it down to:
<i>Info</i>
<d>ActivateWindow(subtitlesearch)</d>
<d mod="longpress">Subtitledelay</d>
<e>ActivateWindow(osdaudiosettings)</e>
<e mod="longpress">NextSubtitle</e>
<c>ActivateWindowAndFocus(10124,9000)</c>
unfortunately it doesn't work yet: any thoughts?
this is my log

Kind regards and sorry for posting it here


14:21:08.246 T:12860 DEBUG: Activating window ID: 10124
14:21:08.246 T:12860 DEBUG: ------ Window Init (DialogSettings.xml) ------
14:21:08.246 T:12860 INFO: Loading skin file: DialogSettings.xml, load type: KEEP_IN_MEMORY
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.volume) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.volumeamplification) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.delay) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.stream) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.outputtoallspeakers) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.digitalanalog) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (subtitles.enable) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (subtitles.delay) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (subtitles.stream) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (subtitles.browser) was not found.
14:21:08.249 T:12860 DEBUG: CSettingsManager: requested setting (audio.makedefault) was not found.
14:21:09.240 T:8236 DEBUG: CVideoPlayer:TonguerocessSubData: Got complete SPU packet
14:21:11.323 T:12860 DEBUG: Previous line repeats 1 times.
14:21:11.323 T:12860 DEBUG: CInputManager:TonguerocessMouse: trying mouse action leftclick
14:21:11.323 T:12860 DEBUG: ------ Window Init (DialogSelect.xml) ------
14:21:11.630 T:8236 DEBUG: CVideoPlayer:TonguerocessSubData: Got complete SPU packet
14:21:15.816 T:12860 DEBUG: Previous line repeats 1 times.
14:21:15.816 T:12860 DEBUG: CInputManager:TonguerocessMouse: trying mouse action leftclick
14:21:16.066 T:12860 DEBUG: ------ Window Deinit (DialogSelect.xml) ------
14:21:16.073 T:8236 DEBUG: CDVDInputStreamNavigator::SetActiveSubtitleStream - id: 2, stream: 2
14:21:16.073 T:8236 NOTICE: Closing stream player 3