Sign in to follow this  
Followers 0
Processor

[Solved] Help in Syntax

21 posts in this topic

#1 ·  Posted (edited)

Hi ,

I tried to convert this syntax in several ways but it don't work:

I wanted to change this :

run("cmd")
     WinWaitActive("[CLASS:ConsoleWindowClass]")
     Send('"' & @ScriptDir & '\mediainfo.exe" --Output=Video;%Duration/String3% "' & $file & '" > ' & '"' & @ScriptDir & '\Duration.txt"' & '{enter}')
     send("exit" & "{enter}")
     WinWaitClose("[CLASS:ConsoleWindowClass]")

to something like :

Run('"' & @ScriptDir & '\mediainfo.exe" --Output=Video;%Duration/String3% "' & $file & '" > ' & '"' & @ScriptDir & '\Duration.txt"')

but a have an MS-Dos message error which disapear to quickly to see what's happening.

Thx by advance for your help

Processor.

Edited by Processor

Share this post


Link to post
Share on other sites



So the first code snippet works but not the second? What about ShellExecute instead?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Hi ,

I tried to convert this syntax in several ways but it don't work:

I wanted to change this :

run("cmd")
     WinWaitActive("[CLASS:ConsoleWindowClass]")
     Send('"' & @ScriptDir & '\mediainfo.exe" --Output=Video;%Duration/String3% "' & $file & '" > ' & '"' & @ScriptDir & '\Duration.txt"' & '{enter}')
     send("exit" & "{enter}")
     WinWaitClose("[CLASS:ConsoleWindowClass]")

to something like :

Run('"' & @ScriptDir & '\mediainfo.exe" --Output=Video;%Duration/String3% "' & $file & '" > ' & '"' & @ScriptDir & '\Duration.txt"')

but a have an MS-Dos message error which disapear to quickly to see what's happening.

Thx by advance for your help

Processor.

maybe try this to see what error you are getting.

Run(@ComSpec & " /k " & @ScriptDir & "\mediainfo.exe --Output=Video;%Duration/String3% " & $file & " > " & @ScriptDir & "\Duration.txt", @SW_SHOW)

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

maybe try this to see what error you are getting.

Run(@ComSpec & " /k " & @ScriptDir & "\mediainfo.exe --Output=Video;%Duration/String3% " & $file & " > " & @ScriptDir & "\Duration.txt", @SW_SHOW)

Nothing happen with this command, no error, but nothing done. :

what should have happened?

Share this post


Link to post
Share on other sites

So the first code snippet works but not the second? What about ShellExecute instead?

Already tried with shellexecute but the problem is the same. :nuke:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Processor,

Your run cmd is trying to pipe output to a file. I don't think you can do that. You may be able to get the output using stdoutread.

kylomas

edit: also you are using DOS cmd syntax which will not work (;%Duration/String3%)

edit2: maybe the syntax is OK for that pgm's parameter, don't know as I do not have that pgm.

edit3: you did not answer guinness's question. And is there more to the original snippet that we are not seeing?

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Is there a text file called duration.txt in the script directory? If so there's probably information in it that might tell you what's happening.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You had the @SW_SHOW as second parameter which is the WorkDir! Also added the double quote back in which I expect are needed.

Try the following:

Run(@ComSpec & ' /k "' & @ScriptDir & '\mediainfo.exe" --Output=Video;%Duration/String3% "' & $file & '" > Duration.txt', @ScriptDir ,@SW_MAXIMIZE)

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Processor,

Your run cmd is trying to pipe output to a file. I don't think you can do that. You may be able to get the output using stdoutread.

kylomas

edit: also you are using DOS cmd syntax which will not work (;%Duration/String3%)

edit2: maybe the syntax is OK for that pgm's parameter, don't know as I do not have that pgm.

edit3: you did not answer guinness's question. And is there more to the original snippet that we are not seeing?

my purpose is get the information provided by the command mediainfo.exe --output=video;%Duration/String3% and put it to a file called duration.txt

I aleady did these kind of things with another PGM without any problem. Error I used send keys :x

The Syntax is ok as it works in CMD box.

What is snippet?

Processor

Edited by Processor

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thx for the syntax, I now know where is the problem.

There is a space in the folder name of the scriptdir so the command launched is someting like:

C:userstotodesktopnew

whereas it should be :

"c:userstotodesktopnew foldermediainfo.exe" ...

so it seems the run command doesn't care of the quotes our double quotes in my syntax whereas the send does :(

Edited by Processor

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You can try to use this...

Run(@ComSpec & " /c " & 'mediainfo.exe --Output=Video;%Duration/String3% "' & $file & '" > Duration.txt', @ScriptDir, @SW_MAXIMIZE)

Double quotes inside single quotes...

Edited by Darkbeo

Share this post


Link to post
Share on other sites

Have you tried the syntax I supplied ?

Didn't that work either?

Yes I did, that's how I saw that there was a path problem (space in path)

You can try to use this...

Run(@ComSpec & " /c " & 'mediainfo.exe --Output=Video;%Duration/String3% "' & $file & '" > Duration.txt', @ScriptDir, @SW_MAXIMIZE)

Double quotes inside single quotes...

I tried this, it's a little bit better as the file duration.txt is created, but the file is empty :

As Kytomas said it's maybe impossible to pipe to an output file.

Share this post


Link to post
Share on other sites

You could try to use the file's shortname:

Run(@ComSpec & ' /k "' & FileGetShortName(@ScriptDir & '\mediainfo.exe') & '" --Output=Video;%Duration/String3% "' & $file & '" > Duration.txt', @ScriptDir ,@SW_SHOW)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Mediainfo telling the syntax in not good I keep trying

Share this post


Link to post
Share on other sites

This syntax give the right value :

Run(@ComSpec & " /k " & 'mediainfo.exe --Output=Video;%Duration/String3% "' & $file & '"', @ScriptDir, @SW_MAXIMIZE)

I just to find a way to put the result into a text file.

Share this post


Link to post
Share on other sites

You might look and/or for more inspiration.

Share this post


Link to post
Share on other sites

Procesor,

Perhaps I have not made myself clear. You cannot pipe to a file using the run command. What Jos and EndFunc are showing you is a way to run through the command processor so you can pipe your output.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Hi All,

Finally got what I wanted using the dll, I had a first read while ago but it seemed to complicated for me. this morning in five mins I found the solution:

; Open Media Info dll
$hDLL = DllOpen("MediaInfo.dll")
; New MediaInfo handle
$aMediaInfo = DllCall($hDLL, "ptr", "MediaInfo_New")
$hMediaInfo = $aMediaInfo[0]

; Open
DllCall($hDLL, "dword", "MediaInfo_Open", "ptr", $hMediaInfo, "wstr", "C:\HNI_001.avi" ) ; Full path
; MediaInfo
$aMediaInfoGet = DllCall($hDLL, "wstr", "MediaInfo_Get", "ptr", $hMediaInfo, "int", 0, "int", 0, "wstr", "Duration/String3", "int", 1, "int", 0)
$sMediaInfo = $aMediaInfoGet[0]
MsgBox("","",$sMediaInfo & @CRLF)
DllClose($hDLL)

The problem is that even if it works, I don't totally understand what I'm doing. :pirate:

if someone could explain what are the PTR, WSTR it would be great.

Processor

Edited by Processor

Share this post


Link to post
Share on other sites

Ok Very last problem I guess:

the code in stand alone works great but in this format

select
       case msg=$toto

         ; Open Media Info dll
      $hDLL = DllOpen("MediaInfo.dll")
      ; New MediaInfo handle
      $aMediaInfo = DllCall($hDLL, "ptr", "MediaInfo_New")
      $hMediaInfo = $aMediaInfo[0]

      ; Open
      DllCall($hDLL, "dword", "MediaInfo_Open", "ptr", $hMediaInfo, "wstr", "C:\HNI_001.avi" ) ; Full path
      ; MediaInfo
      $aMediaInfoGet = DllCall($hDLL, "wstr", "MediaInfo_Get", "ptr", $hMediaInfo, "int", 0, "int", 0, "wstr", "Duration/String3", "int", 1, "int", 0)
      $sMediaInfo = $aMediaInfoGet[0]
      MsgBox("","",$sMediaInfo & @CRLF)
bla
bla
bla

return the following error:

==> Subscript used with non-Array variable.:

$hMediaInfo = $aMediaInfo[0]

$hMediaInfo = $aMediaInfo^ ERROR

Thx by advance for the help

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  
Followers 0