Announcement

Collapse
No announcement yet.

write command lines to stdIn

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • write command lines to stdIn

    Hello,
    I was trying to send commandlines to pdPlayer from Pythons subprocess module using stdin.write(). Unfortunately it seems that i'm doing something wront or pdPlayer simply isn't reading stdin.
    I was wondering if is was possible to pass Command lines to a pdPlayer instance directly without startin a new instance using --attach. How does the new pdPlayer instance send the command line to the existing instance?

    Thanks in advance,

    Mitja

  • #2
    Originally posted by filmkorn View Post
    How does the new pdPlayer instance send the command line to the existing instance?
    Hi,

    Pdplayer uses SendMessage with WM_COPYDATA to pass the (Unicode) command line to the existing window. Here's the relevant section of the code:

    Code:
    static bool try_existing_window( std::wstring const & cmdline )
    {
    	wchar_t const * class_name = L"__pdplayer_main_class";
    
    	HWND hWnd = FindWindowW( class_name, 0 );
    
    	if( hWnd == 0 )
    	{
    		return false;
    	}
    	else
    	{
    		DWORD dwProcessId = 0;
    		GetWindowThreadProcessId( hWnd, &dwProcessId );
    
    		AllowSetForegroundWindow( dwProcessId );
    
    		COPYDATASTRUCT cds = { 0, static_cast< DWORD >( cmdline.size() * 2 ), const_cast< wchar_t * >( cmdline.data() ) };
    		SendMessage( hWnd, WM_COPYDATA, 0, (LPARAM)&cds );
    
    		return true;
    	}
    }
    Note that 'cmdline' contains the application name as its first argument, so it would typically be something like "pdplayer64.exe --attach --play_forward". If you just pass "--play_forward", it will be ignored as it will be assumed to be the application name (argv[0]).
    Peter Dimov
    Asynthetic
    www.pdplayer.com

    Comment


    • #3
      Thank you Peter,

      I got it working!

      Cheerz,
      Mitja

      Comment

      Working...
      X