Belini Posted February 12 Share Posted February 12 (edited) I can't play videos using winmm.dll if there is space in the directory path and I can't solve this, in the research I did I found people with the same problem and the solution they gave was to put the path in quotes but in Autoit it didn't work, is there anything Another way to pass paths with space to the _mciSendString() function that works in Autoit? Similar problem to mine: https://stackoverflow.com/questions/1148022/mcisendstring-cannot-save-to-directory-path My attempts: Func _Video_Open($sFile, $hWnd, $iX, $iY, $iH, $iW, $sDevice = "") Local $sVID, $gId, $iRet, $sDT = "" ;$sFile = '"' & $sFile & '"' ; <============================ It didn't work with space in the name ;$sFile = chr(32) & $sFile & chr(32) ; <===================== It didn't work with space in the name ;I need another way to pass the path with space to open the videos ; <============================ My problem If Not FileExists($sFile) Then Return SetError(1, 0, "") If Not IsHWnd($hWnd) Then Return SetError(2, 0, "") If $sDevice <> "" Then If Not _mciDeviceExists($sDevice) Then Return SetError(3, 0, "") $sDT = " type " & $sDevice EndIf $gId = Dec(StringTrimLeft($hWnd, 2)) $sVID = _RandomStr() $iRet = _mciSendString("open " & FileGetShortName($sFile) & " alias " & $sVID & $sDT) If $iRet <> 0 Then Return SetError(4, 0, "") $iRet = _mciSendString("window " & $sVID & " handle " & $gId) If $iRet <> 0 Then _mciSendString("close " & $sVID) Return SetError(5, 0, "") EndIf $iRet = _mciSendString("put " & $sVID & " destination at " & $iX & " " & $iY & " " & $iH & " " & $iW) If $iRet <> 0 Then _mciSendString("close " & $sVID) Return SetError(6, 0, "") EndIf Return SetError(0, 0, $sVID) EndFunc ;==>_Video_Open Func _mciSendString($string, $iLen = 0) Local $iRet $iRet = DllCall("winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "long", $iLen, "long", 0) If Not @error Then Return $iRet[2] EndFunc ;==>_mciSendString Edited February 12 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Andreik Posted February 12 Share Posted February 12 (edited) 27 minutes ago, Belini said: the solution they gave was to put the path in quotes but in Autoit it didn't work I wonder how you did that. Func _Video_Open($sFile, $hWnd, $iX, $iY, $iH, $iW, $sDevice = "") Local $sVID, $gId, $iRet, $sDT = "" ;$sFile = '"' & $sFile & '"' ; <============================ It didn't work with space in the name ;$sFile = chr(32) & $sFile & chr(32) ; <===================== It didn't work with space in the name ;I need another way to pass the path with space to open the videos ; <============================ My problem If Not FileExists($sFile) Then Return SetError(1, 0, "") If Not IsHWnd($hWnd) Then Return SetError(2, 0, "") If $sDevice <> "" Then If Not _mciDeviceExists($sDevice) Then Return SetError(3, 0, "") $sDT = " type " & $sDevice EndIf $gId = Dec(StringTrimLeft($hWnd, 2)) $sVID = _RandomStr() $iRet = _mciSendString('open "' & FileGetShortName($sFile) & '" alias ' & $sVID & $sDT) ; <<<--- this line is modified If $iRet <> 0 Then Return SetError(4, 0, "") $iRet = _mciSendString("window " & $sVID & " handle " & $gId) If $iRet <> 0 Then _mciSendString("close " & $sVID) Return SetError(5, 0, "") EndIf $iRet = _mciSendString("put " & $sVID & " destination at " & $iX & " " & $iY & " " & $iH & " " & $iW) If $iRet <> 0 Then _mciSendString("close " & $sVID) Return SetError(6, 0, "") EndIf Return SetError(0, 0, $sVID) EndFunc Tested with spaces in path and file name and works properly. Edited February 12 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Gianni Posted February 12 Share Posted February 12 (edited) 34 minutes ago, Belini said: ... is there anything Another way to pass paths with space to the _mciSendString() function that works in Autoit? you could try it like this... $sFile = FileGetShortName($sFile) Edited February 12 by Gianni Belini 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Belini Posted February 12 Author Share Posted February 12 @Andreik just putting quotes I had already tried and it didn't work @Gianni using FileGetShortName() I had also tried and it didn't work My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Andreik Posted February 12 Share Posted February 12 I did it and it works so you have to figure out your issue or to post a runnable script to replicate the behavior. Belini 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Solution Belini Posted February 12 Author Solution Share Posted February 12 (edited) I found the cause of the problem, it doesn't work if you use quotation marks if you are using FileGetShortName() and in the end using quotation marks was the solution but it has to be in the full path and not in the shortest path. $iRet = _mciSendString("open " & FileGetShortName($sFile) & " alias " & $sVID & $sDT); Does not work ; exchanged for $iRet = _mciSendString("open " & '"' & $sFile & '"' & " alias " & $sVID & $sDT); now everything works Thanks @Andreik and @Gianni for trying to help EDITED: I think it has to do with the version of Winmm.dll because I always used FileGetShortName() and it always worked and I never needed to use quotes for it to work but in this version it only works with quotes in the full path and without using FileGetShortName() Edited February 12 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
CYCho Posted February 18 Share Posted February 18 (edited) Further to @Andreik's suggestion, you can use two double quotes around $sFile. In zPlayer, I used the following code to open audio or video files. mciSendString("open """ & $sFile & """ alias myMedia type MPEGVideo wait style popup parent " & $iGui) Edited February 18 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Belini Posted February 19 Author Share Posted February 19 @CYCho the quotation marks really solve the problem, but if you use FileGetShortName() even placing quotation marks does not work in this version of winmm.dll which caused the problem. CYCho 1 My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now