MCE Remote and its green button... (1 Viewer)

Brocklander

Retired Team Member
  • Premium Supporter
  • September 15, 2004
    347
    2
    Wellington
    Home Country
    New Zealand New Zealand
    Paranoid Delusion said:
    I agree with Brocklander MPtray is great but windows system sounds suck if you have ever rebooted a pc after everyone else has gone to
    bed and forgot to turn the speakers off, you'll know what i mean.

    Ray 8)

    Rebooting a Mac is even more fun in the middle of the night - the startup noise is always at least twice as loud as you'd expect (and booming through a 5.1 system) :D
     

    Tech Geek

    Portal Pro
    January 29, 2006
    354
    0
    Denver, CO USA
    CodeMonkey said:
    Thanks guys, and praticularly you Smirnuff for writing it :) My MP PC has no mouse or keyboard attached normally, and if I setup the machine to start MP on bootup then about 75% of the time my wireless connection won't initialize (I have no idea why, it starts up 100% of the time if I don't autostart MP). So until now I had to VNC into the box to start MP. You can see how pushing the green button is much easier :)

    Thanks again.

    Ok, the problem is *probably* caused by MP taking too much CPU time and the wireless driver isn't responding fast enough durring the connection process.

    There is a simple way around this... well... sorta simple.
    You launch a program that waits for however long the network normally takes to connect and then it launches MP.
    Great if you are a programmer right?
    Actually, there is a simple scripting tool called AutoIt that lets you do something like this with just 2 lines of code, it's free and it can generate executables.

    I use this program at work to automate the launch, login and setup of programs used for remote video security. I have it lauching web pages, loading programs, moving windows, clicking on buttons, typing logins... all sorts of stuff. It's very slick and pretty easy to learn.

    Here's the website:
    http://www.autoitscript.com/autoit3/


    I think the script you'd need would look something like this:

    ;------------------------------------
    ;AutoIt 3 script to delay and then launch MediaPortal
    ;build into an executable and then place in the startup folder.
    ;------------------------------------
    ;sleep for 2 minutes. (Fine tune for your startup. 1000 = 1 sec)
    Sleep(120000)

    ;launch MediaPortal. (Check the path and executable name)
    Run ( "C:\Program Files\TeamMediaPortal\MediaPortal\MP.exe", "" )

    ;Done!
    ;------------------------------------
     

    CodeMonkey

    Portal Pro
    December 8, 2004
    360
    30
    North America
    Home Country
    United States of America United States of America
    Tech Geek said:
    Ok, the problem is *probably* caused by MP taking too much CPU time and the wireless driver isn't responding fast enough durring the connection process.

    There is a simple way around this... well... sorta simple.
    You launch a program that waits for however long the network normally takes to connect and then it launches MP.
    Great if you are a programmer right?
    Actually, there is a simple scripting tool called AutoIt that lets you do something like this with just 2 lines of code, it's free and it can generate executables.

    I use this program at work to automate the launch, login and setup of programs used for remote video security. I have it lauching web pages, loading programs, moving windows, clicking on buttons, typing logins... all sorts of stuff. It's very slick and pretty easy to learn.

    Here's the website:
    http://www.autoitscript.com/autoit3/


    I think the script you'd need would look something like this:

    ;------------------------------------
    ;AutoIt 3 script to delay and then launch MediaPortal
    ;build into an executable and then place in the startup folder.
    ;------------------------------------
    ;sleep for 2 minutes. (Fine tune for your startup. 1000 = 1 sec)
    Sleep(120000)

    ;launch MediaPortal. (Check the path and executable name)
    Run ( "C:\Program Files\TeamMediaPortal\MediaPortal\MP.exe", "" )

    ;Done!
    ;------------------------------------

    Thanks, I had already done that. But there are a few problems with your batch fiile. Here is mine:

    Code:
    sleep 60000
    rem
    "C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe"

    XP does not have a sleep, but you can get one from the win2k resource kit or google one.
     

    Tech Geek

    Portal Pro
    January 29, 2006
    354
    0
    Denver, CO USA
    CodeMonkey said:
    Thanks, I had already done that. But there are a few problems with your batch fiile. Here is mine:

    Code:
    sleep 60000
    rem
    "C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe"

    XP does not have a sleep, but you can get one from the win2k resource kit or google one.

    Well, I'm at work and couldn't look at the path and executable name, hence the comment.


    Corrected script:

    Code:
    ;------------------------------------ 
    ;AutoIt 3 script to delay 1 minute and then launch MediaPortal 
    ;build into an executable and then place a link to it in the startup folder. 
    ;------------------------------------ 
    Sleep(60000) 
    Run ( "C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe",  "" )
     

    trailboy

    Portal Member
    January 23, 2006
    22
    0
    44
    London, United Kingdom
    Home Country
    Italy Italy
    Tech Geek said:
    CodeMonkey said:
    Thanks, I had already done that. But there are a few problems with your batch fiile. Here is mine:

    Code:
    sleep 60000
    rem
    "C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe"

    XP does not have a sleep, but you can get one from the win2k resource kit or google one.

    Well, I'm at work and couldn't look at the path and executable name, hence the comment.


    Corrected script:

    Code:
    ;------------------------------------ 
    ;AutoIt 3 script to delay 1 minute and then launch MediaPortal 
    ;build into an executable and then place a link to it in the startup folder. 
    ;------------------------------------ 
    Sleep(60000) 
    Run ( "C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe",  "" )


    Hello,

    If I am right, this code you are giving would work if MP was set to run on windows startup.

    But has anyone an idea on how to make MP to get the focus after launching it by pressing the green button?

    I have had a look at the available functions in AutoIt, I could create a script that checks if MP is running (with ProcessList i could check if MP process is in the process list) and then give the focus back to MP (with WinActivate). To make it cleaner I could pause the script until MP has not been closed, or does not has the focus any more, or even close the script once MP has the focus... Well it's a nice program with many options.

    My problem is that mptray was working fine at the begining and it is not any more, has anyone experienced that? I spend the whole day at work scratching my head (yes, I am a developer as well) and when I get back home I like just enjoying a film from the confort of my sofa...

    I would not like to start coding something unless it is really necessaire...

    Has anyone had the same problem with mptray? If so, how did you fix it?

    Thanks.
     

    trailboy

    Portal Member
    January 23, 2006
    22
    0
    44
    London, United Kingdom
    Home Country
    Italy Italy
    hello all!

    i could not stand any more MP randomly loosing the focus on startup so i decided to write a small script to force MP to get the focus back.

    i have seen a few posts on that issue, it looks that i am not the only one. some people fixed it by uninstalling divx6 or any other program that was stealing the focus (from the task bar or anywhere else).

    it is not my case, i have very few applications installed and non of them are responsible of this random behaviour, it does not even happen every time! and it also only happens on MP startup...

    i have solved this with the following script written with autoit http://www.autoitscript.com/autoit3/

    Code:
    ;-----------
    ;this small script wait for a window to exist and then force it to get the focus
    ;-----------
    
    ;variable needed for the infinite loop
    $i = 0 
    
    ;start infinite loop, it will never finish... 
    ;you can manually exit the script from the tray
    Do 
    
      ;this will make the script to wait for Media Portal window to be opened
      ;the script will wait here until Media Portal is started
      WinWait("Media Portal - ") 
    
      ;if we get here it's because the Media Portal is open
      ;this will activate (give focus) to Media Portal window 
      WinActivate("Media Portal - ", "") 
    
      ;this will make the script to sleep until the window is not active 
      ;the script will wake up again and carry on looping
      WinWaitNotActive("Media Portal - ")
    
    ;this condition will never happen and will keep the script alive
    ;everything starts over again and from the beginning of the loop
    Until $i = 1
    
    ;-----------

    i have compiled AutoFocusOnMP.exe for you all, you can get it from here http://www.lorenyleti.info/test/AutoFocusOnMP.exe

    i run AutoFocusOnMP.exe on windows startup. mptray.exe is there as well listening to my mce remote for the green button to be pushed to launch MP. using mptray.exe you will then be able to open MP from the remote and with AutoFocusOnMP.exe you will make sure MP does not lose the focus.

    in case MP loses the focus, AutoFocusOnMP.exe will quickly give the focus back to MP. the setting Media Portal Always On Top is not needed any more but it won´t harm anyone either... as you can understand that feature doesn't work every time for me, hence this script!

    i can not test it when MP is on a secondary screen. i only have 1 monitor. it my work on a multi display setup as well... who knows!

    this script takes 3580K memory, 00% when waiting and only up to 02% when running (it runs for a few milliseconds only...)

    suggestions, comments welcome.

    it works for me, i hope it does for you as well!
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Very nice!

    One question though:

    You say that when MP looses focus it automatically gets the focus back? So does that mean that its impossible to have MP just run in the background and do some other work in MP? I think thats what it means.

    If so, could you make available another version that simply waits for MP to load, but then exits instead of sitting there and waiting for it to loose focus again?

    I think this should solve the issue with MP not getting focus initially, but still making a manual focus switch possible. Correct?

    Inker
     

    trailboy

    Portal Member
    January 23, 2006
    22
    0
    44
    London, United Kingdom
    Home Country
    Italy Italy
    You say that when MP looses focus it automatically gets the focus back?
    That's correct. If for any reason MP looses the focus, AutoFocusOnMP.exe will put the focus back on MP.
    So does that mean that its impossible to have MP just run in the background and do some other work in MP? I think thats what it means.
    That's correct again. AutoFocusOnMP.exe is only useful if you are running MP and you do not intend to do anything else apart from that while MP is running. I mean that this script will not allow you to run MP in a window while surfing the web or writing a text with your favorite text editor at the same time. AutoFocusOnMP.exe will always keep the focus on MP either in fullscreen and windowed mode.

    I did this script because I wanted to be able to start MP with my MCE remote (green button) and never loose the focus on MP. I hate walking to my PC when I am already sitting on the sofa just to click anywhere in the screen in order to set the focus on MP when runnig fullscreen...

    I first installed mptray (as cheezey told me to do) and then since I started experiencing problems with MP losing the focus I wrote this script. It allows me to run MP from the remote, close it, run it again, close it... And I never loose the focus on it! I do not have to move any more from the sofa!!!

    If so, could you make available another version that simply waits for MP to load, but then exits instead of sitting there and waiting for it to loose focus again?
    What you are asking for is not difficult, but if I make the script to exit after giving the focus to MP you may have the same problem if you reopen MP without executing the script first...

    I have a better idea. Let's make the script stay alive like the previous one but let's only allow it to give the focus back to MP once (5seconds after MP starts).

    The following script will wait until you open MP and after 5 seconds it will force MP to get the focus. The script will then wait until MP is shut down to carry on with its execution. If MP is reopened, the script will then start again from scratch. Doing this, MP is forced to get the focus on startup after 5 seconds and will allow you to manually set the focus onto something else... I think that is what you want... But if for any reason MP looses the focus again without any user interaction after those 5 seconds, MP will not get the focus back until you restart it or set manually the focus on it!
    Code:
    ;-----------
    ;this small script waits for MP to start and after 5 seconds it will force the focus onto it
    ;the focus can be manually set to something else after those 5 seconds
    ;-----------
    
    ;variable needed for the infinite loop
    $i = 0
    
    ;start infinite loop, it will never finish...
    ;you can manually exit the script from the tray
    Do
    
      ;this will make the script to wait for Media Portal window to be opened
      ;the script will wait here until Media Portal is started
      WinWait("Media Portal - ")
    
      ;wait for 5 seconds 
      Sleep(5000)
    
      ;if we get here it's because the Media Portal window has been opened 5 seconds ago
      ;this will activate (give focus) to Media Portal window
      WinActivate("Media Portal - ", "")
    
      ;this will make the script to sleep until Media Portal is closed 
      ;when Media Portal is closed, the script will wake up and carry on looping
      ProcessWaitClose("MediaPortal.exe")
    
    ;this condition will never happen and will keep the script alive
    ;everything starts over again and from the beginning of the loop
    Until $i = 1
    
    ;-----------

    Grab ForceFocusOnMPAfter5Sec.exe from here http://www.lorenyleti.info/test/ForceFocusOnMPAfter5Sec.exe

    I have the feeling that this would work work as well in a dual display setup, but I cannot test it. By the way, I am at work and I cannot test this just created ForceFocusOnMPAfter5Sec.exe with MP but have done my tests with other windows and it works fine.

    Load this on windows startup like AutoFocusOnMP.exe!

    Remember both scripts do similar things but in different ways, choose yours!

    Small and easy scripts that give me a lot of satisfaction... I like a lot MP and would like to contribute in any way I can... If this can be considered as a contribution I will be then be very pleased to help you all in anything I can.

    Suggestions, questions and comments welcome.

    See you soon!
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Wow cool, will try it out and report back. Thanks for modifying this version for me.

    And yes you were correct, sometimes I need to do some other things on my MP box such as start a download or even change some settings etc.

    Anyways, I will report back later.

    Inker
     

    trailboy

    Portal Member
    January 23, 2006
    22
    0
    44
    London, United Kingdom
    Home Country
    Italy Italy
    How did it go Inker? Have anyone tryed those scripts?

    I am using the fist one I wrote, AutoFocusOnMP.exe. It works perfectly, holds just over 3500K in memory and makes my MP never loose the focus!
     

    Users who are viewing this thread

    Top Bottom