zhenxin168 发表于 2008-12-6 12:52:16

如何实现这个功能

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\oddtest.kxf
$Form1 = GUICreate("ODD Test", 641, 408, 237, 133)
$Pic1 = GUICtrlCreatePic("odd11.JPG", 0, 0, 640, 250, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("ODD Letter:", 12, 256, 210, 37)
GUICtrlSetFont(-1, 14, 800, 0, "Arial Black")
$Label2 = GUICtrlCreateLabel("ODD Model:", 12, 301, 160, 37)
GUICtrlSetFont(-1, 14, 800, 0, "Arial Black")
$Label3 = GUICtrlCreateLabel("ODD Status:", 12, 348, 160, 37)
GUICtrlSetFont(-1, 14, 800, 0, "Arial Black")
$Button1 = GUICtrlCreateButton("OPEN DVD", 492, 344, 129, 41, 0)
GUICtrlSetFont(-1, 16, 400, 0, "黑体")
$Button2 = GUICtrlCreateButton("DVD TEST", 492, 252, 129, 41, 0)
GUICtrlSetFont(-1, 16, 400, 0, "黑体")
$Button3 = GUICtrlCreateButton("PASS", 492, 344, 129, 41, 0)
GUICtrlSetFont(-1, 16, 400, 0, "黑体")
$Button4 = GUICtrlCreateButton("FAIL", 492, 252, 129, 41, 0)
GUICtrlSetFont(-1, 16, 400, 0, "黑体")
$Label4 = GUICtrlCreateLabel("Not found letter", 135, 257, 200, 32)
GUICtrlSetFont(-1, 14, 800, 0, "Arial Black")
GUICtrlSetColor(-1, 0x008000)
$Label5 = GUICtrlCreateLabel("not found ODD", 135, 303, 360, 32)
GUICtrlSetFont(-1, 14, 800, 0, "Arial Black")
GUICtrlSetColor(-1, 0x008000)
$Label6 = GUICtrlCreateLabel("No Ready!", 135, 350, 200, 32)
GUICtrlSetFont(-1, 14, 800, 0, "Arial Black")
GUICtrlSetColor(-1, 0x008000)
GUISetState(@SW_SHOW)
GUICtrlSetState (9,$GUI_HIDE)
GUICtrlSetState (10,$GUI_HIDE)
#EndRegion ### END Koda GUI section ###
ControlFocus("ODD TEST", "弹出光驱", 7)
$odd = DriveGetDrive('cdrom')
GUICtrlSetData($Label4, StringUpper($odd) & "\")
info()
Func info()

        $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
        $odd1 = $objWMIService.ExecQuery ("Select * from Win32_CDROMDrive")
       
       
        For $object In $odd1
                GUICtrlSetData($Label5, StringStripWS($object.name, 1))
        Next
EndFunc   ;==>info




While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button2
                        GUICtrlSetState (8,$GUI_HIDE)
                        GUICtrlSetState (7,$GUI_HIDE)
                        GUICtrlSetState (9,$GUI_SHOW)
                        GUICtrlSetState (10,$GUI_SHOW)
                Case $Button1
                        GUICtrlSetState (9,$GUI_HIDE)
                        GUICtrlSetState (10,$GUI_HIDE)
                       
                        $odd = DriveGetDrive('cdrom')
                        If Not @error Then CDTray($odd, "open")
                       
                       
                       

        EndSwitch
WEnd
请问各位大侠:
1.我该如何将光驱中的MP3文件做成一个M3U文件,不通过DOS命令。
2.如何读取光驱中的文件.
AU3中好像并没有类似DOS DIR命令。如果有的话,请详细说明。谢谢。。。

大绯狼 发表于 2008-12-6 13:33:11

网上查了下 M3U的命令应该是dir ./b/s>h:\yinyue.m3u
这样的话通过AU3可以遍历.MP3然后写入一个文本文档就可以
读取光驱用DriveGetDrive ( "类型" ) 来获取光驱路径

详细资料请自行搜索已解决问题

zhenxin168 发表于 2008-12-6 14:14:09

谢谢楼上的,其实使用DOS的,我已经解决,只是希望AU3本身具备这些能力,而不借助于DOS,由于我对AU3不是很熟悉。希望能个比较具体的解决方法,我所要的效果,就是读取光驱中的MP3文件保存为一个M3U。然后通过WMP播放这个M3U,达到播放光驱中的MP3歌曲。
以下是BAT。

@echo off
if exist k.txt del /q k.txt
set "var=fsutil fsinfo drives"
set "var1=fsutil fsinfo drivetype"
for /f "skip=2 tokens=1 delims= " %%a in ('%VAR%^|MORE') do (
%var1% %%a|find /i "cd-rom"^|if errorlevel 1 goto nocd
find /i "cd-rom">k.txt&&for /f "tokens=1 delims=- " %%c in (k.txt) do (
dir /s /b %%c>%tmp%hi.m3u 2>nul
find /i "mp3" %tmp%hi.m3u>nul
if errorlevel 1 goto cdfail
start %tmp%hi.m3u&&goto end
)
)

:cdfail
CLS
ECHO             *****************************************************
echo             **       你未插入光盘,或所插入的光盘不含MP3!      **
ECHO             *****************************************************
goto end


:nocd
CLS
ECHO             *****************************************************
echo             **      当前机器未安装光驱,或光驱未安装好.      **
ECHO             *****************************************************
goto end

:end
pause>Nul

大绯狼 发表于 2008-12-6 14:35:05

通过AU3可以实现

zhenxin168 发表于 2008-12-6 14:43:30

如果可以实现的话,可以通过哪几个命令或函数。。请赐教。。。

大绯狼 发表于 2008-12-6 14:46:09

先用DriveGetDrive获得光驱盘符
再用以下代码获得所有MP3文件的路径 写入M3U文件就可以了

Search("J:\", ".MP3")
Func Search($current, $ext)
      Local $search = FileFindFirstFile($current & "\*.*")
      While 1
                Dim $file = FileFindNextFile($search)
                If @error Or StringLen($file) < 1 Then ExitLoop
                If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
                        If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
;~                                 MsgBox(0,0,$current & "\" & $file)
                        EndIf
                EndIf
                If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."Or $file <> "..") Then
                        Search($current & "\" & $file, $ext)
               
                EndIf
      WEnd
      Return
EndFunc   ;==>Search

zhenxin168 发表于 2008-12-6 15:02:32

好的,谢谢..我回家去试试。谢谢。。
页: [1]
查看完整版本: 如何实现这个功能