Jump to content

how can i send keyboard commands to mplayer?


Recommended Posts

hi

im trying to "remote control" mplayer - i can capture the output from the mplayer (time in seconds etc) but my keyboard commands dont seem to get to mplayer ?

#include <GUIConstants.au3>
;#include <Constants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 193, 115)
$btn_forward = GUICtrlCreateButton(">", 8, 16, 75, 25, 0)
$btn_pause = GUICtrlCreateButton("pause", 104, 16, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=

$mplayerpid = Run('mplayer.exe test.mp3', @ScriptDir, @SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        
        
        ;; doesnt work
        Case $btn_forward
            ;; MsgBox(0,"test", "forward");
            ; Write string to be sorted to child sort.exe's STDIN
            StdinWrite($mplayerpid, Chr(26)) ; right arrow
            
        Case $btn_pause
            
            ConsoleWrite("sending pause" & @CRLF);
            
            StdinWrite($mplayerpid, 'p') ;
            
            If @error = -1 Then
                ConsoleWrite("error sending pause" & @CRLF);
            EndIf
            
            
            
        Case $GUI_EVENT_CLOSE ;ok
            ProcessClose($mplayerpid)
            Exit

    EndSwitch



    ;; this works - output is now displayed in scite window
    $c = StdoutRead($mplayerpid)
    ConsoleWrite($c & @LF);

WEnd
Link to comment
Share on other sites

  • 1 month later...

Maybe you need to sen CRLF after the command

NO, just LF:

3.2.3 Slave mode

The slave mode allow you to build simple frontend to MPlayer. When enabled (with the -slave option) MPlayer will read commands separated by new line (\n) from stdin.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...