Jump to content
Sign in to follow this  

how can i send keyboard commands to mplayer?

Recommended Posts



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)
#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);
        Case $GUI_EVENT_CLOSE ;ok


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


Share this post

Link to post
Share on other sites


I'm doing something very similar at the moment, and I had the same problem until I remembered to flush stdin. :D That should solve your problem.


Share this post

Link to post
Share on other sites

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

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.