-1

i made little script to work with xbmc and i'm not able to get it work. Here the code:

import xbmcgui
import xbmc

while (not xbmc.abortRequested):

    win = (xbmcgui.getCurrentWindowId())
    menu = 0

    if win == 10000 and menu != 10000:
        print ("Home menu")
        menu = 10000

All i want is that when home menu is there, write to log (but only once) for now it always write in the log when on menu

Thanks in advance

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 3
    Your indentation is not currently valid after the `while` or the `if`. – eldarerathis Feb 07 '13 at 23:53
  • 5
    Please edit your question to ident the code correctly, in the case of Python, it's essential to understand where each block starts and ends. – pcalcao Feb 07 '13 at 23:53
  • 1
    I can see why you must be getting errors. – tkbx Feb 07 '13 at 23:54
  • You means the space, in the code there some space for the indentation, but when i copy pass the code, space have been earase. If i understand what you mean, sorry i'm a newbie in python – user2052746 Feb 07 '13 at 23:55
  • 1
    Accept the answer. You have lots of open questions. – Geoff Mar 19 '13 at 01:48

1 Answers1

5

Set menu = 0 outside of your while loop; you are resetting it to 0 each time otherwise:

menu = 0

while (not xbmc.abortRequested):
    win = (xbmcgui.getCurrentWindowId())

    if win == 10000 and menu != 10000:
        print ("Home menu")
        menu = 10000
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343