Jump to content

Recommended Posts

Posted (edited)

when I go to display and choose console I can control VLC by command line by typing in its console window, does anyone know if there is any way to send the commands directly without opening the console window and without having to close and reopen vlc to send the command?

Sem-t-tulo.jpg

Edited by Belini
Posted

I managed to do what I wanted by making the command window invisible but I still wanted to find a way to send commands directly to vlc without having to use its console window.

if ProcessExists("vlc.exe") then 

WinSetTrans("[CLASS:ConsoleWindowClass]", "", 0)

ControlSend("[CLASS:ConsoleWindowClass]", '', '', "f on  " & "{enter}"); Fullscreen on
Sleep(1000)
ControlSend("[CLASS:ConsoleWindowClass]", '', '', "f off  " & "{enter}"); Fullscreen off

endif

 

Posted (edited)

This is a solution I get from this post :

And I had this script from the topic : (Whitch helped me a lot in lot of similar situation.)

It could react the same with your shell console. You have to redefine the code as you need.

#include <constants.au3>
#include <string.au3>
#RequireAdmin

; Use RunAs if you want use a fixed username/password within the script:
; Global $hPowerShellPID = RunAs("UserName", "Domain", "Password", "", "powershell.exe", '', @SW_HIDE, BitOR($STDIN_CHILD, $STDERR_MERGED))

; or use #RequireAdmin and a simple Run Statement to enter Admin credentials (if needed) at runtime
; Here we start a "permanent" powershell prompt with redirected streams
Global $hPowerShellPID = Run("powershell.exe", '', @SW_HIDE, BitOR($STDIN_CHILD, $STDERR_MERGED))

; this little loop is to wait for the "welcome" message from powershell
; just a way to be sure that the powershell is running and "streaming"
Do
    StdoutRead($hPowerShellPID)
Until @extended ; out stream started

; example:
; Here we "execute a command via the Powershell that is running in background...
; ...and we get back to resulting output
Local $Out = _Run_Cmdlet("Get-ItemPropertyValue 'Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'EnableLUA'", $hPowerShellPID)
ConsoleWrite($Out)

; here another command
ConsoleWrite(_Run_Cmdlet("dir c:\", $hPowerShellPID))

; .... and so on ...

; this function execute the passed powershell command and returns the resulting output
Func _Run_Cmdlet($sCmd, ByRef $hPS)
    Local $sStdOut = ''
    ; we insert a start and an end message in order to identify the "body" of the result of the command executed
    $sCmd = 'write-host "->StartOfStream<-"; ' & $sCmd & '; write-host "->EndOfStream<-"' & @CRLF
    StdinWrite($hPS, $sCmd)
    Do
        Sleep(250)
        $sStdOut &= StdoutRead($hPS)
        ; the presence of the known end message signals the end of the execution
    Until StringInStr($sStdOut, "->EndOfStream<-" & @LF)
    ; return only the body of the outpu of the passed command
    Return _StringBetween($sStdOut, "->StartOfStream<-" & @LF, "->EndOfStream<-" & @LF)[0]
EndFunc   ;==>_Run_Cmdlet

I'm sure you could done your goal with this ;)

 

Enjoy.

Thanks @Gianni btw.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted (edited)

Thanks for the tip @caramen but I've already managed to send all the commands I need using the vlc console itself, for sure what you posted will be useful for other things and I'll do tests with it.

ShellExecute("vlc.exe", "vlc -I rc", @ScriptDir); open vlc console without opening its graphical interface
Sleep(200)
WinSetTrans("[CLASS:ConsoleWindowClass]", '', 0); make the console window invisible
Sleep(3000)
ControlSend("[CLASS:ConsoleWindowClass]", '', '', "f on " & "{enter}"); put the video in full screen
Sleep(3000)
ControlSend("[CLASS:ConsoleWindowClass]", '', '', "f off " & "{enter}"); put the video in windowed mode

 

Edited by Belini
  • 2 weeks later...
Posted

@Belini

better way is to replace:

 WinSetTrans 

to:

 

WinSetState

script:


ShellExecute("vlc.exe", "vlc -I rc", @ScriptDir); open vlc console without opening its graphical interface
Sleep(200)
WinSetState("[CLASS:ConsoleWindowClass]","",@SW_HIDE)
Sleep(3000)
ControlSend("[CLASS:ConsoleWindowClass]", '', '', "f on " & "{enter}"); put the video in full screen
Sleep(3000)
ControlSend("[CLASS:ConsoleWindowClass]", '', '', "f off " & "{enter}"); put the video in windowed mode

none

Posted

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
  • Recently Browsing   0 members

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