Detect recording in progress from external script (AHK) (1 Viewer)

Rob Hexenmeister

MP Donator
  • Premium Supporter
  • May 12, 2011
    151
    34
    Slaithwaite
    United Kingdom United Kingdom
    Country flag
    I use an AHK script to launch Mediaportal.

    The reason is that I can tell it to perform other tasks before launching the programme (for instance switching on my Energenie sockets etc) as well as remapping some of my remote control buttons.

    The one shortcoming is that doing it this way necessitates having certain Power Scheduler settings (it is all to do with wake up timings and waiting for the Energenie and other USB controllers to register as active again before I can send the socket-on request).

    However, I have got all of part that working and my script even detects whether the PC was woken by a timer or the Power Button

    What I want to do is script the HTPC to go back to sleep when it has finished recording after a wake timer. I am nearly there. But what I am struggling with is finding a DLL call or similar to detect if TV Server is recording.

    Does anyone know of a way of querying if a Recording is active?
     

    Rob Hexenmeister

    MP Donator
  • Premium Supporter
  • May 12, 2011
    151
    34
    Slaithwaite
    United Kingdom United Kingdom
    Country flag
    No Power Scheduler cannot do it for the reason given in the original post. I am hoping there is a DLL call that will return a value.
     

    CyberSimian

    Test Group
  • Team MediaPortal
  • June 10, 2013
    1,999
    1,234
    Southampton
    United Kingdom United Kingdom
    Country flag
    What I want to do is script the HTPC to go back to sleep when it has finished recording after a wake timer.
    There is a different solution to this, one that I use on my HTPC.

    The important factor to realise is that Windows will not sleep or hibernate the system whilst a recording is in progress. If the sleep or hibernation timeout is set to a very small value (e.g. one minute), the system will sleep or hibernate one minute after the unattended recording has finished. I think that this is the outcome that you want.

    The problem with using a very short sleep or hibernation timeout is that if you leave MP on a menu or with video paused in order (say) to make a cup of coffee, Windows will sleep or hibernate the system one minute after you have left the room. This is probably not the outcome that you want.

    So the solution is to vary the sleep or hibernation timeout according to the state of the system. When you start using the system, your script should set the timeout to a large value (e.g. one hour). When you have finished using the system, the script should set the timeout to a small value and allow Windows to sleep or hibernate the system.

    I wrote a tool in the C programming language to control this, but I prototyped it using a BAT file, so I think that you could do similar from an AutoHotKey script. I originally used the presence or absence of a display screen to decide how to set the timeout, and this is what the prototype BAT version checks. The refined C version checks a USB hub powered via an IR remote-controlled mains socket switched on and off by my Harmony 650 remote control.

    I still have the prototype BAT version and can post it if you are interested in exploring this solution further.

    -- from CyberSimian in the UK
     

    Rob Hexenmeister

    MP Donator
  • Premium Supporter
  • May 12, 2011
    151
    34
    Slaithwaite
    United Kingdom United Kingdom
    Country flag
    Interesting post CyberSimian.

    That wouldn't work for me though as that would shut down the computer on idle, no matter how it was switched on. The method I am using detects whether it was a wake timer or the power button that woke the computer. If it was the power button, it will not try to shut down. I will post the whole script when it is done.

    Meanwhile a little progress on the principle of accessing functions within DLLs - as per this AHK test script:

    DllCall ("C:\Program Files (x86)\Team Media Portal\MediaPortal TV Server\Hauppauge.dll\GetAudBitRate", "double", Recording)
    MsgBox %Recording%
    MsgBox %ErrorLevel%

    Now... unfortunately I cannot seem to find the function I want despite Edalex's helpful pointers above. Looking for IsAnyCardRecording in TVControl.dll generated a not found error code, which has baffled me for the time being.
     

    Rob Hexenmeister

    MP Donator
  • Premium Supporter
  • May 12, 2011
    151
    34
    Slaithwaite
    United Kingdom United Kingdom
    Country flag
    Well I have come up with something that works. It is very dirty and brutal but does the job. I tried other methods, such as SetThreadExecutionState to no avail - despite the DLL appearing to call and report success, it seemed to have no effect at all.

    So here is what I have:

    Three Autohotkey (AHK) Scripts.

    Wake Up.Exe is called by Task Scheduler, triggered by a power state change message. This therefore kicks in if the computer is woken up from sleep
    Start MP.Exe is scheduled to run at start up and is the "main" controller programme. It is also called by Wake Up.Exe to make sure everything starts afresh on wake.
    Dummy Process.Exe is exactly as it sounds it does nothing. It is run by Start MP if the computer was woken with the power button or switched on by the user. The key is to tell PowerScheduler not to shut down if "Dummy Process" is running and you can do that in the PowerScheduler configuration in TV Server.

    I include the compiled exe programmes and the ahk scripts for you to examine in notepad. There are other things in those, such as the switching on of my Energenie Sockets and the hiding of the mouse pointer (the latter which I cannot take full credit for at all, I just did the bit which repositions it to where it was when the mouse was disabled)

    I have left the failed experiments in the scripts as comments, in case anyone can tidy this up and make it work with the DLLs which would be much tidier.

    The original idea which I would still like to pursue if possible is to detect if TV recording has stopped, and send the PC to sleep if it wasn't switched on with the power button. Sadly, while the AHK DllCall function finds the DLL, it can't find the command that reports if any card is recording. It may be a privileges issue, or maybe it is a 32 bit issue. I just don't know, that is beyond my powers.
     

    Attachments

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    I MP Server goes into suspend, because it doesn't detect the MP Client General Support 6
    M What does MP homeserver detection need at the client end, and what does the server need to transmit? General 6
    morpheus_xx Some stats of IPInfo (detecting location for Weather plugin) MediaPortal 2 0
    M How do you disable USB drives from being detected by MP? General Support 0
    toricred Recordings Change : to _ in Series Name General 0
    P Recording films that have an "intermission" General 2
    H MP2 database won't keep in synch with recordings General 4
    toricred Only Show Actual Recordings General 1
    ajs How recreate Recording thumbs TV-Server 4
    P [solved] MP2 new install, 2 x hdhomerun tuners, client on same PC unable to view TV & recordings Newcomers Forum 8
    CyberSimian [Proposal] Tool to display time of next recording MediaPortal 1 0
    Golf4 TV-Records werden als Audio-Files importiert ? Allgemeines Support- und Diskussionsforum 0
    R [solved] Unable to delete single recording General 2
    R Correct setting for recordings on shared folder General 0
    W [solved] MP suddenly Crashes when starting live TV on most channels and on recordings from the same channels General Support 20
    W [solved] MP suddenly Crashes when starting live TV on some channels and on some recordings Television (MyTV frontend and TV-Server) 1
    S Shortcuts MP1 My Recorded & TV Guide General 10
    F How to reset tv recordings database General 5
    P Recordings not showing up unless re-imported and not possible to delete General 0
    X Recording import hängt Allgemeines Support- und Diskussionsforum 0
    F Recording starts at second time only MediaPortal 1 Talk 6
    T TV Recording Schedule General 2
    T Unwanted recording Newcomers Forum 18
    bta489 [solved] DVB-T2 Recordings: Sometimes no Audio after muxing with mkvmerge Tools and other software 2
    N Play a TV recording needs a double selection - twice ok on remote Television (MyTV frontend and TV-Server) 2
    Similar threads

























    Top Bottom