Help with script error

If you have a question or need help, this is the place to be.
Post Reply
molitar
Experienced User
Posts: 186
Joined: Fri Sep 11, 2009 6:44 am

Help with script error

Post by molitar » Wed Mar 13, 2019 12:09 am

Since upgrading to Eventghost 0.5 RC6 my script no longer works properly.

Error:
Traceback (most recent call last):
Python script "5", line 34, in <module>
secondsTotal = int(secArrayTotal[0])*(3600)+int(secArrayTotal[1])*(60)+int(secArrayTotal[2])
IndexError: list index out of range
Script:

Code: Select all

import re

mpc = eg.WindowMatcher(u'mpc-hc64.exe', None, u'MediaPlayerClassicW', None, None, None, True, 0.0, 0)
hWnd = mpc()

if len(hWnd) > 0:
    from eg.WinApi import GetWindowText
    title = GetWindowText(hWnd[0])
    if re.search(".mkv",title,re.I):
        title = title.split(".mkv")[0]
    elif re.search(".mp4",title,re.I):
        title = title.split(".mp4")[0]
    elif re.search(".avi",title,re.I):
        title = title.split(".avi")[0]
    elif re.search(".ogm",title,re.I):
        title = title.split(".ogm") [0]
    else:
        title = title.split(".")[0]
        
elaps, rem, total = eg.plugins.MediaPlayerClassic.GetTimes()
#print "elaps, rem, total =",elaps, rem, total

x = 1

while x < 4:

    if elaps != "00:00:00":
        if eg.globals.WindowsState != "Fullscreen": howManyBars = 100
        if eg.globals.WindowsState == "Fullscreen": howManyBars = 100

        secArray = elaps.split(':')
        secArrayTotal = total.split(':')
       
        secondsTotal = int(secArrayTotal[0])*(3600)+int(secArrayTotal[1])*(60)+int(secArrayTotal[2])
        secondsElapsed = int(secArray[0])*(3600)+int(secArray[1])*(60)+int(secArray[2])
       
        percent = (1.0*secondsElapsed)/(secondsTotal)*100
        percent = int(round(percent))
        bars = (percent * howManyBars)/100
       
        osd = title + "\n \n" + "[ " + "|" * bars + " " * (howManyBars - bars) + " ]" + "\n" + " "*30 + elaps + " / " + total

        if eg.globals.WindowsState == "Fullscreen":
            eg.plugins.EventGhost.ShowOSD(osd, u'0;-110;0;0;0;700;0;0;0;0;3;2;1;49;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 1, 1.0, False)
        else:
            eg.plugins.EventGhost.ShowOSD(osd, u'0;-058;0;0;0;700;0;0;0;0;3;2;1;49;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 2, 1.0, False)
    eg.Wait(0.8)
    #print x
    x += 1

User avatar
kgschlosser
Site Admin
Posts: 4495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Help with script error

Post by kgschlosser » Wed Mar 13, 2019 5:34 am

OK so the code below is a redo of what you had posted. it has some nifty triicks
aded as well as some special features. I spent alot of time writing the comments
in the code. It explains what is happening ini detail and why I made the changes
I did. So please do read them.

make sure you leave the first line blank!!

Code: Select all


# this try/except routine is done because the information that is generated
# in a Python script is persistent between runs. Whats this means is that
# anything that is created in a python script when the script gets run a
# second, third, fourth... the objects created the first time are available to
# every run thereafter. So if you have any objects created that are static and
# do not change between runs then there is no need to make them over again.
# To test for this we simply use one of those object names that are static.
# if the object exists it will pass right on by. if it oes not it will
# generate an error that we catch in the except portion of thee code block.
# And that is where we will then create all of the static objects

try:
    user32
except NameError:
    import wx
    import datetime
    import time
    import ctypes
    from ctypes.wintypes import (
        BOOL,
        LONG,
        UINT,
        POINT,
        RECT,
        HWND,
        LPARAM,
        DWORD
    )  # NOQA

    from eg.WinApi import (
        GetWindowText,
        GetTopLevelWindowList,
        GetProcessName
    )  # NOQA


    PID = DWORD
    user32 = ctypes.windll.User32

    # DWORD GetWindowThreadProcessId(
    #   HWND    hWnd,
    #   LPDWORD lpdwProcessId
    # );
    _GetWindowThreadProcessId = user32.GetWindowThreadProcessId
    _GetWindowThreadProcessId.restype = DWORD

    BAR_TEMPLATE = '[{bars}{remaining}] - {percent:.2f}%'
    ELAPSED_TOTAL_TEMPLATE = 'Elapsed: {elapsed} / Total: {duration}'
    OSD_TEMPLATE = '{title}\n \n{bar}\n{elapsed_total}'

# OK so I removed the euse of the eg.WindowMatcher.
# it is a horribly slow thing to use and since we are only looking to see
# if a process is running or not we use GetTopLevelWindowList which returns
# the handles for the base window class of an application. then we ask windows
# to get us the process id (pid) for one of the handles in the returned list.
# Then we use that pid to get the process name. and we match that process name
# up with the one we are looking for.

handles = GetTopLevelWindowList(False)

for handle in handles:
    pid = PID()
    _GetWindowThreadProcessId(HWND(handle), ctypes.byref(pid))

    process_name = GetProcessName(pid.value)

    if process_name == 'mpc-hc64.exe':
        break
else:
    # OK this iis in interesting thing. I do this to keep from getting to
    # many layers of code
    # if:
    #     if:
    #         if:
    #             if:

    # that is to many layers. if for loop exits cleanly (break is not called)
    # the code in the else statement gets run. So this is a nice mechanism to
    # be able to say stop the macro and exit the script if our process was not
    # found
    handle = None
    eg.StopMacro()
    eg.Exit()

window_text = GetWindowText(handle)

# I removed the use of re and did a simple triel and error using a form loop
# with an else statement.
# If i split a string on a value and that value is not n the string it is
# going to return a list with the original string at index 0. So the list
# only las a length of 1. if it did have the value in it the list would have a
# length greater then 1. and we use that to break the loop. This will cause
# the else to not get run.

for item in (".mkv", ".mp4", ".avi", ".ogm"):
    window_text = window_text.split(item)
    if len(window_text) > 1:
        break
    window_text = window_text[0]
else:
    window_text = window_text.split('.')

title = window_text[0]


_elapsed, _remaining, _duration = eg.plugins.MediaPlayerClassic.GetTimes()
# print "elaps, rem, total =",elaps, rem, total

# I removed all of that math involved in trying to get the seconds in
# favor of using time.strptime and datetime.timedelta
# time.strptime will take a string formatted time representation and turn it
# into a python object for us. we simply have to provide details as to how the
# string is formatted. you can get more information on the identifiers here
# http://strftime.org/
# once we have that object which only does the simple
# conversion to hours minutes seconds we need to create another object that
# does the match for us and will return the total seconds

elapsed = time.strptime(_elapsed, '%H:%M:%S')
elapsed = datetime.timedelta(
    hours=elapsed.tm_hour,
    minutes=elapsed.tm_min,
    seconds=elapsed.tm_sec
)

remaining = time.strptime(_remaining, '%H:%M:%S')
remaining = datetime.timedelta(
    hours=remaining.tm_hour,
    minutes=remaining.tm_min,
    seconds=remaining.tm_sec
)

duration = time.strptime(_duration,'%H:%M:%S')
duration = datetime.timedelta(
    hours=duration.tm_hour,
    minutes=duration.tm_min,
    seconds=duration.tm_sec
)


# heere we do a test to see if elapsed has any seconds to it. if iit does
# that means the video is playing and to generate the osd
if elapsed.total_seconds():
    # instead of having to calls to ShowOSD we can set the parameters we want
    # to pass to ShowOSD into a variable you name the variable the same for
    # Fullscreen and not Fullscreen and set the parameters for each variation
    # then when we call ShowOSD the proper set of parameters will be passed
    if eg.globals.WindowsState == "Fullscreen":
        osd_args = (
            u'0;-110;0;0;0;700;0;0;0;0;3;2;1;49;Arial',
            (0, 255, 255),
            (0, 0, 0),
            4,
            (0, 0),
            1,
            2.4,
            False
        )
    else:
        osd_args = (
            u'0;-058;0;0;0;700;0;0;0;0;3;2;1;49;Arial',
            (0, 255, 255),
            (0, 0, 0),
            4,
            (0, 0),
            2,
            2.4,
            False
        )

    # I trimmed down the percent math. iif you want to change an int to a 
    # float you do not need to do 1.0 * int. this will work but the pythonic 
    # way is to wrap that int with float()
    percent = (
        (
            float(elapsed.total_seconds()) /
            float(duration.total_seconds())
        ) * 100.0
    )
    # I removed the conversion of the percent form a float to an int because 
    # i wanted the percent as a float for use further on down the line

    bars = '|' * int(round(percent))
    remaining = '.' * (100 - len(bars))
    
    # I created string templates for the OSD. i split the osd into 3 sections
    # I will explain as to why they are split into 3 sections further down
    # I added the percent that has elapsed to the bar line as a 2 decimal place 
    # float 

    bar = BAR_TEMPLATE.format(
        bars=bars,
        remaining=remaining,
        percent=percent
    )

    elapsed_total = ELAPSED_TOTAL_TEMPLATE.format(
        elapsed=_elapsed,
        duration=_duration
    )

    # OK so this is an odd thing. wx is thee GUI interface we use to generate 
    # all of the graphics, windows and controls in EG. because of how text 
    # gets displayed when using a GUI the characters defined in a font are 
    # not of equal size, so a "G" does not have the same width as an "!"
    # I saw that you were displaying the OSD n the center of the screen with 
    # what looked like center justification. because of that font issue ths 
    # is extremely difficult to do. Portions of the wx library allow us to call 
    # a function called GetTextExtent this function rill return the width and 
    # height in pixels of a string passed into it. we have to set the font we 
    # want to use then call the function. in order to get the center 
    # justification as close as we can and the space is the only thing we can 
    # really do it with we also want to know the width of a space.
    
    frame = wx.Frame(None, -1)
    font = wx.FontFromNativeInfoString(osd_args[0])
    frame.SetFont(font)
    bar_len = frame.GetTextExtent(bar)[0]
    title_len = frame.GetTextExtent(title)[0]
    elapsed_total_len = frame.GetTextExtent(elapsed_total)[0]
    space_len = frame.GetTextExtent(' ')[0]
    
    # so here we do the checking to see which line is longer then the other to 
    # adjust the one that is shorter
    if bar_len < title_len:
        # this is the number of spaces we are going to need. so we find out the
        # pixel difference divide that by the number of pixels a space is.
        # this is going to return the total number of spaces needed to make the
        # line the same length. Now remember center justification. so half of 
        # those spaces would need to be on thee back end of the line. Those
        # we do not need to add to the line. so wee divide the total number of 
        # spaces by 2 to get the number of spaces we need to add to the front 
        # of the line
        
        space_count = (
            int(round(float(title_len - bar_len) / float(space_len))) / 2
        )
        bar = ' ' * space_count + bar

    elif title_len < bar_len:
        space_count = (
            int(round(float(bar_len - title_len) / float(space_len))) / 2
        )
        title = ' ' * space_count + title

    bar_len = frame.GetTextExtent(bar)[0]

    frame.Destroy()

    if elapsed_total_len < bar_len:
        space_count = (
            int(round(float(bar_len - elapsed_total_len) / float(space_len))) / 2
        )
        elapsed_total = ' ' * space_count + elapsed_total

    osd = OSD_TEMPLATE.format(
        title=title,
        bar=bar,
        elapsed_total=elapsed_total
    )
    # and here is the single call to ShowOSD. we prefiix that variable we made 
    # earlier with a * which expands the variable into the parameters that 
    # needs to be passed

    eg.plugins.EventGhost.ShowOSD(osd, *osd_args)
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Help with script error

Post by kgschlosser » Wed Mar 13, 2019 5:46 am

This is a slightly different spin on it.

Code: Select all


# this try/except routine is done because the information that is generated
# in a Python script is persistent between runs. Whats this means is that
# anything that is created in a python script when the script gets run a
# second, third, fourth... the objects created the first time are available to
# every run thereafter. So if you have any objects created that are static and
# do not change between runs then there is no need to make them over again.
# To test for this we simply use one of those object names that are static.
# if the object exists it will pass right on by. if it oes not it will
# generate an error that we catch in the except portion of thee code block.
# And that is where we will then create all of the static objects

try:
    user32
except NameError:
    import wx
    import datetime
    import time
    import ctypes
    from ctypes.wintypes import (
        BOOL,
        LONG,
        UINT,
        POINT,
        RECT,
        HWND,
        LPARAM,
        DWORD
    )  # NOQA

    from eg.WinApi import (
        GetWindowText,
        GetTopLevelWindowList,
        GetProcessName
    )  # NOQA


    PID = DWORD
    user32 = ctypes.windll.User32

    # DWORD GetWindowThreadProcessId(
    #   HWND    hWnd,
    #   LPDWORD lpdwProcessId
    # );
    _GetWindowThreadProcessId = user32.GetWindowThreadProcessId
    _GetWindowThreadProcessId.restype = DWORD

    BAR_TEMPLATE = '[{bars}{remaining}] - {percent:.2f}%'
    ELAPSED_TOTAL_TEMPLATE = 'Elapsed: {elapsed} / Total: {duration}'
    OSD_TEMPLATE = '{title}\n \n{bar}\n{elapsed_total}'

# OK so I removed the euse of the eg.WindowMatcher.
# it is a horribly slow thing to use and since we are only looking to see
# if a process is running or not we use GetTopLevelWindowList which returns
# the handles for the base window class of an application. then we ask windows
# to get us the process id (pid) for one of the handles in the returned list.
# Then we use that pid to get the process name. and we match that process name
# up with the one we are looking for.

handles = GetTopLevelWindowList(False)

for handle in handles:
    pid = PID()
    _GetWindowThreadProcessId(HWND(handle), ctypes.byref(pid))

    process_name = GetProcessName(pid.value)

    if process_name == 'mpc-hc64.exe':
        break
else:
    # OK this iis in interesting thing. I do this to keep from getting to
    # many layers of code
    # if:
    #     if:
    #         if:
    #             if:

    # that is to many layers. if for loop exits cleanly (break is not called)
    # the code in the else statement gets run. So this is a nice mechanism to
    # be able to say stop the macro and exit the script if our process was not
    # found
    handle = None
    eg.StopMacro()
    eg.Exit()

window_text = GetWindowText(handle)

# I removed the use of re and did a simple triel and error using a form loop
# with an else statement.
# If i split a string on a value and that value is not n the string it is
# going to return a list with the original string at index 0. So the list
# only las a length of 1. if it did have the value in it the list would have a
# length greater then 1. and we use that to break the loop. This will cause
# the else to not get run.

for item in (".mkv", ".mp4", ".avi", ".ogm"):
    window_text = window_text.split(item)
    if len(window_text) > 1:
        break
    window_text = window_text[0]
else:
    window_text = window_text.split('.')

title = window_text[0]


_elapsed, _remaining, _duration = eg.plugins.MediaPlayerClassic.GetTimes()
# print "elaps, rem, total =",elaps, rem, total

# I removed all of that math involved in trying to get the seconds in
# favor of using time.strptime and datetime.timedelta
# time.strptime will take a string formatted time representation and turn it
# into a python object for us. we simply have to provide details as to how the
# string is formatted. you can get more information on the identifiers here
# http://strftime.org/
# once we have that object which only does the simple
# conversion to hours minutes seconds we need to create another object that
# does the match for us and will return the total seconds

elapsed = time.strptime(_elapsed, '%H:%M:%S')
elapsed = datetime.timedelta(
    hours=elapsed.tm_hour,
    minutes=elapsed.tm_min,
    seconds=elapsed.tm_sec
)

remaining = time.strptime(_remaining, '%H:%M:%S')
remaining = datetime.timedelta(
    hours=remaining.tm_hour,
    minutes=remaining.tm_min,
    seconds=remaining.tm_sec
)

duration = time.strptime(_duration,'%H:%M:%S')
duration = datetime.timedelta(
    hours=duration.tm_hour,
    minutes=duration.tm_min,
    seconds=duration.tm_sec
)


# heere we do a test to see if elapsed has any seconds to it. if iit does
# that means the video is playing and to generate the osd
if elapsed.total_seconds():
    # instead of having to calls to ShowOSD we can set the parameters we want
    # to pass to ShowOSD into a variable you name the variable the same for
    # Fullscreen and not Fullscreen and set the parameters for each variation
    # then when we call ShowOSD the proper set of parameters will be passed
    if eg.globals.WindowsState == "Fullscreen":
        osd_args = (
            u'0;-82;0;0;0;700;255;0;0;0;3;2;1;34;Verdana', 
            (0, 255, 0), 
            (0, 0, 0), 
            5, 
            (0, 0), 
            1, 
            3.0, 
            None
        )
    else:
        osd_args = (
            u'0;-030;0;0;0;700;255;0;0;0;3;2;1;34;Verdana', 
            (0, 255, 0), 
            (0, 0, 0), 
            5, 
            (0, 0), 
            2, 
            3.0, 
            None
        )

    # I trimmed down the percent math. iif you want to change an int to a 
    # float you do not need to do 1.0 * int. this will work but the pythonic 
    # way is to wrap that int with float()
    percent = (
        (
            float(elapsed.total_seconds()) /
            float(duration.total_seconds())
        ) * 100.0
    )
    # I removed the conversion of the percent form a float to an int because 
    # i wanted the percent as a float for use further on down the line

    bars = '/' * int(round(percent))
    remaining = '.' * (100 - len(bars))
    
    # I created string templates for the OSD. i split the osd into 3 sections
    # I will explain as to why they are split into 3 sections further down
    # I added the percent that has elapsed to the bar line as a 2 decimal place 
    # float 

    bar = BAR_TEMPLATE.format(
        bars=bars,
        remaining=remaining,
        percent=percent
    )

    elapsed_total = ELAPSED_TOTAL_TEMPLATE.format(
        elapsed=_elapsed,
        duration=_duration
    )

    # OK so this is an odd thing. wx is thee GUI interface we use to generate 
    # all of the graphics, windows and controls in EG. because of how text 
    # gets displayed when using a GUI the characters defined in a font are 
    # not of equal size, so a "G" does not have the same width as an "!"
    # I saw that you were displaying the OSD n the center of the screen with 
    # what looked like center justification. because of that font issue ths 
    # is extremely difficult to do. Portions of the wx library allow us to call 
    # a function called GetTextExtent this function rill return the width and 
    # height in pixels of a string passed into it. we have to set the font we 
    # want to use then call the function. in order to get the center 
    # justification as close as we can and the space is the only thing we can 
    # really do it with we also want to know the width of a space.
    
    frame = wx.Frame(None, -1)
    font = wx.FontFromNativeInfoString(osd_args[0])
    frame.SetFont(font)
    bar_len = frame.GetTextExtent(bar)[0]
    title_len = frame.GetTextExtent(title)[0]
    elapsed_total_len = frame.GetTextExtent(elapsed_total)[0]
    space_len = frame.GetTextExtent(' ')[0]
    
    # so here we do the checking to see which line is longer then the other to 
    # adjust the one that is shorter
    if bar_len < title_len:
        # this is the number of spaces we are going to need. so we find out the
        # pixel difference divide that by the number of pixels a space is.
        # this is going to return the total number of spaces needed to make the
        # line the same length. Now remember center justification. so half of 
        # those spaces would need to be on thee back end of the line. Those
        # we do not need to add to the line. so wee divide the total number of 
        # spaces by 2 to get the number of spaces we need to add to the front 
        # of the line
        
        space_count = (
            int(round(float(title_len - bar_len) / float(space_len))) / 2
        )
        bar = ' ' * space_count + bar

    elif title_len < bar_len:
        space_count = (
            int(round(float(bar_len - title_len) / float(space_len))) / 2
        )
        title = ' ' * space_count + title

    bar_len = frame.GetTextExtent(bar)[0]

    frame.Destroy()

    if elapsed_total_len < bar_len:
        space_count = (
            int(round(float(bar_len - elapsed_total_len) / float(space_len))) / 2
        )
        elapsed_total = ' ' * space_count + elapsed_total

    osd = OSD_TEMPLATE.format(
        title=title,
        bar=bar,
        elapsed_total=elapsed_total
    )
    # and here is the single call to ShowOSD. we prefiix that variable we made 
    # earlier with a * which expands the variable into the parameters that 
    # needs to be passed

    eg.plugins.EventGhost.ShowOSD(osd, *osd_args)
If you like the work I have been doing then feel free to Image

molitar
Experienced User
Posts: 186
Joined: Fri Sep 11, 2009 6:44 am

Re: Help with script error

Post by molitar » Wed Mar 13, 2019 4:03 pm

Thank you very much I threw a fiver your way I really appreciate all the help. It worked great.

User avatar
kgschlosser
Site Admin
Posts: 4495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Help with script error

Post by kgschlosser » Thu Mar 14, 2019 3:23 am

I don't know what a fiver is. I am going to assume it is some kind of a donation.

I am happy to see it worked out for ya. I have added a justification feature to the Show OSD action. I will submit it as a pull request and we can see if it will get added to the core code.
There are several changes I have wanted to make to the OSD plugin. like being able to display more then a single OSD at the same time. and also not keeping the OSD frame created the whole time EG is running (waste of resources).

I am also going to add in scrolling text. so if you specify that you want to have a 3 line display but you pass in 15 lines of text to display it will scroll the text. this is going to be tricky to do and make it look right without any jitter. maybe II can also toss in some special effects like fading in and out. and vertical and horizontal removing of the text from the outside in and from the inside out (never done that one before, I wonder if I can make it come out right.) II also wanted to add the ability to display an image along with text. I may write a plugin to do all of this. It can get overly complex. I would need to make some kind of a layout control so the user can place items and set the sizes and what have you.
If you like the work I have been doing then feel free to Image

molitar
Experienced User
Posts: 186
Joined: Fri Sep 11, 2009 6:44 am

Re: Help with script error

Post by molitar » Thu Mar 14, 2019 3:13 pm

One thing I would like to see is ability to display OSD on multiple monitors at same time. I have a global volume control OSD action but I can not have the global control show on more then one display so I had to choose one display only. Is something like that possible with Show OSD?

User avatar
kgschlosser
Site Admin
Posts: 4495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Help with script error

Post by kgschlosser » Thu Mar 14, 2019 4:20 pm

yes and no. but it gets a wee bit complicated to do it. You would have to run EG 2 times on the same computer. install the Network sender plugin on the primary EG. and the net receiver on the secondary EG then have the primary EG send a command to the secondary which would then show the second OSD. That is kind of a work around.
If you like the work I have been doing then feel free to Image

molitar
Experienced User
Posts: 186
Joined: Fri Sep 11, 2009 6:44 am

Re: Help with script error

Post by molitar » Fri Mar 15, 2019 1:26 am

kgschlosser, it worked for the entire day yesterday and then started throwing up this error this morning.. Damn I really HATE HATE Windows 10 and how randomly things just stop working.
Traceback (most recent call last):
Python script "5", line 120, in <module>
elapsed = time.strptime(_elapsed, '%H:%M:%S')
File "_strptime.pyc", line 478, in _strptime_time
File "_strptime.pyc", line 332, in _strptime
ValueError: time data '21:54' does not match format '%H:%M:%S'
So I thought I would try the latest version to see if it fixed it and installed it and that broke everything until I copied my old entire plugin folder back over. But I still can not get my OSD code you provided to work anymore. Why would it work all day yesterday and just stop today?

User avatar
kgschlosser
Site Admin
Posts: 4495
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Help with script error

Post by kgschlosser » Fri Mar 15, 2019 6:36 pm

OK that is because the plugin is returning a formatted time that is not normal.

this is the template that is expected to be returned
00:00:00
hours:minutes:seconds


and this is what was returned for the elapsed time.
21:54

so my question is going to be this. MPC has the ability to play all sorts of files types. when this happens you need to take note of what is playing and what the media type is. this may be happening because you are listening to an audio track. IDK. I can fix it easily enough I am just not sure if the returned value is hours and minutes or iis it minutes and seconds. I am going to assume the latter.


This will fix the issue.
right above this line

Code: Select all

elapsed = time.strptime(_elapsed, '%H:%M:%S')
add this code.

Code: Select all


while _elapsed.count(':') < 2:
    _elapsed = '00:' + _elapsed
while _remaining.count(':') < 2:
    _remaining = '00:' + _remaining
while _duration.count(':') < 2:
    _duration = '00:' + _duration
This is going to make sure the time is formatted hours:minutes:seconds
If you like the work I have been doing then feel free to Image

molitar
Experienced User
Posts: 186
Joined: Fri Sep 11, 2009 6:44 am

Re: Help with script error

Post by molitar » Mon Mar 18, 2019 5:31 am

I found a fatal flaw with this script for my needs. It only works with one MPC open not two. My old script worked with multiples open. Often I will have a video open that I am studying and another player open for some background music. I can no longer do this because of the method it seems where WindowMatcher worked with multiple MPC players at once the new method will not work.

Post Reply