firts excuse me for my English it`s super Freak. Sorry
I have a big problem , i need finish my applicatión in VB6.0 for a test in my High Schooll and i can`t find the solution, My app open a FFmpeg.EXE file which open a cmd window Prompt and start a trascoding process, i need link the last line generated into the Prompt of the CMD window (Or top Bottom) , in this line exists Values what change , in this trascoding process the result are bit Rates , which fluctuates acording to others var.
The idea it´s what into the form of my app i can read this line in real time to bulid a progress bar (File Size/Bitrate average)=time to process.
Can you help me. Thanks for the answer....
Put a reference to Windows Scripting Host Object Model and try this snippet
Option Explicit
Private Sub Command1_Click()
Dim oExec As WshExec
Dim sRow As String
With New WshShell
Set oExec = .Exec("tasklist.exe")
End With
Do While oExec.Status = WshRunning
sRow = oExec.StdOut.ReadLine
If InStr(1, sRow, "vb6.exe", vbTextCompare) > 0 Then
MsgBox sRow, vbExclamation
End If
Loop
End Sub
Basicly try executing FFmpeg.EXE and ReadLine until you find some key text.
Send the output to a textfile then read this textfile.
Should look something like this:
ping >e:\test.txt
Where ping is the FFmpge.EXE and e:\test.txt the output textfile
rdkleine
I read your answer and this is great work very good , only that it shows in the log a death value "text", and i need the value of fluctuates bitrates of conversion , which changes in real time in the prompt of the cmd window. i'm trying now with the source code of wqw , i'm working in there.
Thak's for your answer..
Related
I'm facing a random problem. When executing SAS programs with VBScript and the SASEGObjectModel.Application.7.1, looping through CodeCollection get stuck sometimes, even if the program execution was succeeded (the final data bases are correctly created in our server). The script simple doesn't go to the next program of CodeCollection (the prompt executing the script still open... ad infinitum). The SAS program It happens is random, also the frequency. I'm going with something like this:
Dim oSasApp
Set oSasApp = CreateObject("SASEGObjectModel.Application.7.1")
oSasApp.SetActiveProfile("some-profile")
Dim oSasProj
Set oSasProj = oSasApp.Open("some-project.egp", "")
Dim oProgramList
Set oProgramList = oSasProj.CodeCollection
Dim programOrder
Set programOrder = ...here I assign the SAS programs order array reading from a .txt...
For Each program in programOrder
For Each sasProgram in oProgramList
If sasProgram.Name = program Then
sasProgram.Run
sasProgram.Log.SaveAs "some-folder/" & sasProgram.Name & ".txt"
End If
Next
Next
oSasProj.Close
oSasApp.Quit
The problem is not the Log saving, as the log txt file of the stucked program is also correctly created.
Any idea? Maybe problems in our SAS server? Should I declare some kind of options?
SAS Guide version: 7.15
Windows: 10
Tks
So... for people facing the same problem. As I commented above, if I press enter on prompt the script flows again. So it is waiting for my input, for reasons I can't tell. I did 2 things to get around it. Not sure if all of them are necessary or if only one solves it, but here it goes:
First, by VBScript I turned off a list of generations and I applied a delay after the SAS program runs:
For Each program in programOrder
For Each sasProgram i oProgramList
If sasProgram.Name = program Then
sasProgram.GenSasReport = False
sasProgram.GenHTML = False
sasProgram.GenListing = False
sasProgram.GenPDF = False
sasProgram.GenRTF = False
sasProgram.Run
WScript.Sleep(2000)
sasProgram.Log.SaveAs "some-folder/" & sasProgram.Name & ".txt"
End If
Next
Next
Them, in my batch file, wich I use to call the VBScript with the "cscript" command, I set it to apply "y" to every single message the VBScript could ask:
cd ./script-folder
echo y | cscript script-file-name.vbs
And that is it.
I am trying to create a VBScript that opens Word and inputs text into it.
My code:
::Set wshshell = WScript.CreateObject("WScript.Shell")
::Set objShell = CreateObject("WScript.Shell")
::objShell.AppActivate "word"
::userProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%")
::WScript.Sleep 10000
::wshshell.SendKeys "Hello World!"
Perhaps surprisingly, you cannot interact with Word unless you actually started the program in the first place. As documented the AppActivate method activates an application window, i.e. brings the window of an already running application to the foreground.
To start Word programmatically use something like this:
Set wd = CreateObject("Word.Application")
wd.Visible = True
You can open a document like this:
Set doc = wd.Documents.Open("C:\path\to\your.docx")
or create a new document like this:
Set doc = wd.Documents.Add
Text can be entered for instance via the TypeText method:
doc.Selection.TypeText "some text"
Save the document like this:
doc.Save
doc.Close
or like this (if it's a new document or you want to save it under a different name/path):
doc.SaveAs "C:\path\to\new.docx", 16
doc.Close
Exit from the application like this:
wd.Quit
Do NOT use SendKeys for anything. EVER. Not unless you're being forced at gunpoint.
Also do NOT write Frankenscript that mixes different languages (like batch and VBScript) in the same file. It's a pain in the rear to debug and maintain.
Is it possible to get the name of the current song playing in WMP with a VBS script? My goal is to have a .txt file that contains the name of the currently playing song. I'm using a livestream program (OBS) which can display text from a file, and since so many people ask me for my playlist while streaming, I'd like to have OBS display the name of the current song. To accomplish this, I'm just going to have it change the "Current Song" text to whatever is in currentsong.txt located on my Desktop, but I just don't know how update that txt to contain the current song.
I've searched around on Google and I haven't been able to find any way to get the current MWP song :(
Help please :(
Note: Retrieving information on a sequence can be done only when the load status "Transitioning" is reached.
Option Explicit
Dim Sound,Name,NameLog,fso,ws
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("wscript.Shell")
Set Sound = CreateObject("WMPlayer.OCX.7")
Sound.URL = "C:\FaceSong.mp3"
'Disable the sound
Sound.settings.mute = True
Sound.Controls.play
'Note: Retrieving information on a sequence can be done only when the load status "Transitioning" is reached.
While Sound.playState = 9
Name = Sound.currentMedia.getItemInfo("Name")
NameLog = Name & ".txt"
if fso.FileExists(NameLog) Then
fso.DeleteFile NameLog
end If
MsgBox Name,VbInformation,Name
Call WriteLog(Name,NameLog)
Wend
ws.run NameLog
'***********************************************************************************************
Sub WriteLog(strText,LogFile)
Dim fs,ts
Const ForAppending = 8
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(LogFile,ForAppending,True)
ts.WriteLine strText
ts.Close
End Sub
'************************************************************************************************
You need to either read Media Player's documentation (so when you looked on the internet you did look at MSDN.com which is where it lives, like all Microsoft's documentation.?). If you have a programming IDE (like VBA in Office) then use it's object browser.
Start an office app, press Alt + F11, then F2.
Right click somewhere and choose References add Windows Media Player from list. Change drop down from All Libraries to just Media Player.
You have a property for filename. And a method to get any info on the song.
Property FileName As String
Member of MediaPlayer.MediaPlayer
Returns or sets the current file name and path
and
Function GetMediaInfoString(MediaInfoType As MPMediaInfoType) As String
Member of MediaPlayer.MediaPlayer
Returns an Information String for the Media
Remember VBS doesn't have access to the type library so you have to use constant's values instead of constant's names. So in the above you woulduse 8 and not mpClipTitle to get the title.
I am a novice when it comes to object oriented program. That said, I have been trying to construct a vbscript that will capture a screenshot of the desktop and immediately save it to a folder I specify. Here is the code I have so far:
' START
Dim screenSize
screenSize = New screenSize.Size(Screen.PrimaryScreen.Bounds.X,Screen.PrimaryScreen.Bounds.Y)
Dim screenGrab
screenGrab = New screenGrab.Bitmap(My.Computer.Screen.Bounds.Width, my.Computer.Screen.Bounds.Height)
Dim g
g = g.System.Drawing.Graphics.FromImage(screenGrab)
dim copyS
copyS = Graphics.CopyPixels4.PaintEventArgs
dim copyS2
copyS2 = copyS.Graphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation)
dim saveTo
saveTo = screenGrab.Save("C:\temp\screenGrab.bmp")
' END
I prefer to keep this in VBSCRIPT as this script will be incorporated into an existing vbscript I created. I currently get an error at line 3 stating "class not defined 'screensize". I am also concerned that even if I fix the error at line 3 I may run into other syntax issues afterward. The overall intent of the script is to 1) get the screen dimensons ; 2) perform the screenshot ; 3) and save the file to a destination. I am open to any suggestions to make this work.
I appreciate any help I can get at this point. Thank you.
It seems like you have messed VB.NET with VBScript.
screenSize, screenGrab, System.Drawing.Graphics - there are no such classes in VBScript by default.
What I'd suggest is to use some screen capture ActiveX (google it).
Or create your own ActiveX with VB6 by using code like this. Create new ActiveX project in VB6, add that module and compile.
And remember to run regsvr32.exe youractivex.ocx before using it in your script.
I have a problem: I want to run a file from lotusscript code:
Dim result As Integer
result = Shell("D:\testF.dsx", 1)
And I get the following error: Illegal function call.
If I want to execute it from formula it works:
#Command([Execute]; "D:\\testF.dsx")
Thanks a lot!
I had the same problem with the shell function in lotus script with PDF files. And my workaround is to use the windows scripting host to launch the file. I am pretty sure this will solve your problem too.
Set objShell = CreateObject("WScript.Shell")
returnValue = objShell.Run("d:\testF.dsx", 3, false)enter code here
It is not possible to "Execute" a Textfile. usually there is no "run" function defined for dsx- files.
You could do it like:
Dim result as Integer
result = Shell("notepad.exe D:\testF.dsx", 1)
Or find out, which program is linked to dsx (via registry) and execute the corresponding exe with filename as Parameter. If the filename contains spaces, then it has to be enclosed:
Dim result as Integer
result = Shell({notepad.exe "D:\testF.dsx"}, 1)
And reading your last question this approach for sure is NOT the right for your request. You have to use "open" in order to process files... Like Per Hendrik told you in his response.
I had similar problems passing parameters to Outlook.
On some windows machines, this #Formula worked perfectly:
#Command([Execute]; "Outlook.exe"; "/recycle")
On Windows Terminal Servers, it caused Outlook to be unable to parse the "/recycle"
The Shell-command from LotusScript wasn't even able to locate the Outlook.exe, as it was not in the PATH.
Ralf's code helped me in this respect. The "WScript.Shell" seems able to interact with Windows registry settings. Anyway, here is the code that works for activating an open Outlook window.
Dim objShell, returnValue
Set objShell = CreateObject("WScript.Shell")
returnValue = objShell.Run("outlook.exe /recycle", 3, False)