Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Help with While statement

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

Help with While statement

Post by molitar »

I wish to run this loop 3 times but not sure what I am doing wrong in my While statement. It reports error at the While statement line what am I doing wrong? I am trying to get it to refresh my OSD ever second for 3 seconds but the code reports syntax error.

Code: Select all

mpc = eg.WindowMatcher(u'mpc-hc.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])
    eg.result = title.split(".m")[0]  

Find_MPC_Time=eg.WindowMatcher(u'mpc-hc.exe', u'{*}Media Player Classic{*}', u'MediaPlayerClassicW', None, u'Static', 2, True, 0.0, 0)
hwnd = Find_MPC_Time()

x = 1

While x < 4:
    if len(hwnd) > 0:
        if eg.globals.WindowsState == "Fullscreen": howManyBars = 80
        if eg.globals.WindowsState != "Fullscreen": howManyBars = 80

        timeE,timeR = eg.WinApi.GetWindowText(hwnd[0]).split(' / ')
        secArray = timeE.split(':')
        secArrayTotal = timeR.split(':')
        secondsTotal = int(secArrayTotal[0])*(60)+int(secArrayTotal[1])
        secondsElapsed = int(secArray[0])*(60)+int(secArray[1])
        percent = (secondsElapsed*howManyBars)/secondsTotal
        osd = eg.result + "\n \n" + "[" + "|"*(percent) + " "*(howManyBars-percent) + "]" + "\n" + " "*30 + timeE + " / " + timeR
    
        if eg.globals.WindowsState != "Fullscreen":
            eg.plugins.EventGhost.ShowOSD(osd, u'0;-50;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 0, 1.0, False)
        else:
            eg.plugins.EventGhost.ShowOSD(osd, u'0;-50;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 1, 1.0, False)
        mpc = eg.WindowMatcher(u'mpc-hc.exe', None, u'MediaPlayerClassicW', None, None, None, True, 0.0, 0)
    hWnd = mpc()
X = X + 1
stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Help with While statement

Post by stottle »

You going to say "D'oh!"

It's case sensitive. Should be while, not While.

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

Re: Help with While statement

Post by molitar »

stottle wrote:You going to say "D'oh!"

It's case sensitive. Should be while, not While.

Brett
Thanks didn't know Python was case sensitive for the statement commands. Thanks working great now.
Post Reply