Problem with Getting Current Window Id
#1
I have a strange problem with getting the window id in my python script. It's the same bit of code in another module which works flawlessly. But it seems that this one doesn't work.

When I call getCurrentWindowId in this particular module, it always reports 10000. ActivateWindow never works unless I call it from the skin, and even then, the Window Id is still returned as 10000.

Here's a sample from the script:

Code:
oldWindowId = xbmcgui.getCurrentWindowId()
# oldWindowId here returns 10000

if oldWindowId <> 11340:
    # Activate the Window
    xbmc.executebuiltin('ActivateWindow(1340)')
    newWindowId = xbmcgui.getCurrentWindowId()
    # newWindowId is still 10000....

Both oldWindowId and newWindowId both report to contain "10000". If I activate the Window through a menu item on the skin, that works fine. However getCurrentWindowId always reports 10000.

I also use "oldWindow<>11340" because I noted elsewhere that the Window Id is having 10000 added to them.

Here's a sample

Code:
<?xml version="1.0" encoding="UTF-8"?>
<window id="1340">
    <onload>RunScript(special://home/scripts/cubeone.script.bluetooth.calls)</onload>
    <depth>DepthOSD</depth>
    <coordinates>
        <left>0</left>
        <top>0</top>
    </coordinates>
    <controls>
        <include>CommonBackground</include>
        <include>ContentPanelBackgrounds</include>
        # Controls Here
        <include name="CommonWindowHeader">
            <param name="Icon" value="" />
            <param name="Label" value="Name" />
        </include>
    </controls>
</window>

As said, the Window loads perfectly through the menu with

Code:
<onclick>ActivateWindow(1340)</onclick>

So Im confused as to why

  • ActivateWindow is not working on the script
  • Even with the window 1340 loaded, getCurrentWindowId still returns 10000

Any thoughts?

Thanks
Simon
Reply
#2
I've figured out one part. Adding a
Code:
"time.sleep(2)"
after the ActivateWindow resolves this.

The ActivateWindow is called, but doesn't get shown until after I've tried to get all the controls.

Why the delay?

Not entirely sure. Though I suspect it's something to do with:

Code:
gobject.threads_init()
gobject.timeout_add_seconds(1, self.timeMonitor)
self.mainloop = gobject.MainLoop()
self.mainloop.run()

This does nothing else than monitor the DBus.

Code:
self._bus.add_signal_receiver(self.device_property_changed_cb, bus_name=self.DEVICE_PATH, signal_name="PropertiesChanged", path_keyword="device_path", interface_keyword="interface")

and device_property_changed_cb() also calls back another function.

Not sure why the delay.

Simon
Reply
#3
You should do something like this:
Code:
# Wait for window to open
time_passed = 0
while not xbmc.getCondVisibility("Window.IsVisible(%s)" % window_id) and time_passed < timeout:
    xbmc.sleep(100)
    time_passed += 100

Where timeout is a timeout set by you (you can set 2000 ms) and window_id is your window id, of course :p
This way you are checking when the window is visible.
Reply

Logout Mark Read Team Forum Stats Members Help
Problem with Getting Current Window Id0