Created
August 16, 2015 01:32
-
-
Save maimainoue/bb28221b50f1d0150d96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cs ---------------------------------------------------------------------------- | |
AutoIt Version: 3.3.12.0 | |
Author: maimai | |
Script Function: | |
auto Ripping script. | |
#ce ---------------------------------------------------------------------------- | |
#include <GuiConstantsEx.au3> | |
; Script Start | |
DBGPRINT("処理開始"& @CR) | |
; CDドライブ数取得 | |
Local $DriveArr = DriveGetDrive('CDROM') | |
Local $DriveCount = $DriveArr[0] | |
DBGPRINT("ドライブ数:"&$DriveCount&@CR) | |
GUICreate("autoRip", 128+300, ((128+1)*$DriveCount)+20) | |
GUISetIcon("cd.ico", 0) | |
Local $idFilemenu = GUICtrlCreateMenu("ファイル(&F)") | |
Local $idExititem = GUICtrlCreateMenuItem("終了(&E)", $idFilemenu) | |
DBGPRINT("メニュー作成完了"& @CR) | |
Local $Drives = _Drives_Init() | |
; GUI MESSAGE LOOP | |
GUISetState(@SW_SHOW) | |
Local $cnt | |
While 1 | |
Switch GUIGetMsg() | |
Case $GUI_EVENT_CLOSE, $idExititem | |
Exit | |
EndSwitch | |
If $cnt > 250 Then | |
_Drives_GetData($Drives) | |
$cnt = 0 | |
EndIf | |
$cnt += 1 | |
WEnd | |
Func DBGPRINT(Const $msg) | |
ControlSend("[CLASS:Notepad]", "", "Edit1", $msg) | |
EndFunc | |
Func _Drives_Init() | |
Local $Columns = 8 | |
Local $DriveArr = DriveGetDrive('CDROM') | |
Local $DriveCount = $DriveArr[0] | |
Local $Drives[($DriveCount + 1)][$Columns] | |
$Drives[0][0] = -1 | |
Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2'); | |
If (IsObj($Obj_WMIService)) And (Not @error) Then | |
Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_CDROMDrive') | |
Local $Obj_Items | |
Local $tmpY, $tmpName = "" | |
For $Obj_Items In $Col_Items | |
$Drives[0][0] += 1 | |
$tmpY = 0 + ($Drives[0][0] * (128 + 1)) | |
$Drives[Number($Drives[0][0] + 1)][0] = $Obj_Items.DeviceID | |
$Drives[Number($Drives[0][0] + 1)][1] = $Obj_Items.Description | |
$tmpName = $Obj_Items.Name | |
$tmpName = StringReplace( $tmpName, " ATA Device", "" ) | |
$tmpName = StringReplace( $tmpName, " SCSI CdRom Device", "" ) | |
$tmpName = StringReplace( $tmpName, " USB Device", "" ) | |
$Drives[Number($Drives[0][0] + 1)][2] = $tmpName | |
$Drives[Number($Drives[0][0] + 1)][3] = $Obj_Items.Drive | |
$Drives[Number($Drives[0][0] + 1)][4] = 999 | |
$Drives[Number($Drives[0][0] + 1)][5] = GUICtrlCreatePic("cd-in.jpg", 0, $tmpY, 128, 128) | |
$Drives[Number($Drives[0][0] + 1)][6] = GUICtrlCreatePic("cd-out.jpg", 0, $tmpY, 128, 128) | |
$Drives[Number($Drives[0][0] + 1)][7] = GUICtrlCreateLabel("", 128, $tmpY, 300, 128) | |
GUICtrlSetBkColor($Drives[Number($Drives[0][0] + 1)][7], 0xFFFFFF) | |
Next | |
$Drives[0][0] += 1 | |
Return $Drives | |
Else | |
Return 0 | |
EndIf | |
EndFunc | |
Func _Drives_GetData(ByRef $Drives) | |
Local $DriveCount = $Drives[0][0] | |
$Drives[0][0] = -1 | |
Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2'); | |
If (IsObj($Obj_WMIService)) And (Not @error) Then | |
Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_CDROMDrive') | |
Local $Obj_Items | |
Local $tmpY, $tmpName = "" | |
For $Obj_Items In $Col_Items | |
$Drives[0][0] += 1 | |
$tmpY = 0 + ($Drives[0][0] * (128 + 1)) | |
$Drives[Number($Drives[0][0] + 1)][0] = $Obj_Items.DeviceID | |
$Drives[Number($Drives[0][0] + 1)][1] = $Obj_Items.Description | |
$tmpName = $Obj_Items.Name | |
$tmpName = StringReplace( $tmpName, " ATA Device", "" ) | |
$tmpName = StringReplace( $tmpName, " SCSI CdRom Device", "" ) | |
$tmpName = StringReplace( $tmpName, " USB Device", "" ) | |
$Drives[Number($Drives[0][0] + 1)][2] = $tmpName | |
$Drives[Number($Drives[0][0] + 1)][3] = $Obj_Items.Drive | |
If $Drives[Number($Drives[0][0] + 1)][4] <> $Obj_Items.MediaLoaded Then | |
IF $Obj_Items.MediaLoaded Then | |
; CDが挿入された | |
DBGPRINT($tmpName&" is Insert"& @CR) | |
GUICtrlSetState( $Drives[Number($Drives[0][0] + 1)][5], $GUI_SHOW ) | |
GUICtrlSetState( $Drives[Number($Drives[0][0] + 1)][6], $GUI_HIDE ) | |
Run( @ComSpec&" /c "&"rip.bat "&$Obj_Items.Drive, "E:\MusicServer\CD自動リッピング\", @SW_HIDE ) | |
Else | |
GUICtrlSetState( $Drives[Number($Drives[0][0] + 1)][5], $GUI_HIDE ) | |
GUICtrlSetState( $Drives[Number($Drives[0][0] + 1)][6], $GUI_SHOW ) | |
EndIf | |
$tmpName = $Drives[Number($Drives[0][0] + 1)][2] | |
$tmpName = $tmpName&" ("&$Drives[Number($Drives[0][0] + 1)][3]&")" | |
GUICtrlSetData($Drives[Number($Drives[0][0] + 1)][7], $tmpName) | |
EndIf | |
$Drives[Number($Drives[0][0] + 1)][4] = $Obj_Items.MediaLoaded | |
Next | |
$Drives[0][0] += 1 | |
Return $Drives | |
Else | |
Return 0 | |
EndIf | |
EndFunc | |
#cs | |
Func _Drives_Update(Const $Drives) | |
$LoopCount = 0 | |
While $LoopCount < $Drives[0][0] | |
If $Drives[$LoopCount+1][4] Then | |
; CDが挿入されている | |
GUICtrlSetState( $Drives[$LoopCount+1][5], $GUI_SHOW ) | |
GUICtrlSetState( $Drives[$LoopCount+1][6], $GUI_HIDE ) | |
Else | |
; CDは入ってない | |
GUICtrlSetState( $Drives[$LoopCount+1][5], $GUI_HIDE ) | |
GUICtrlSetState( $Drives[$LoopCount+1][6], $GUI_SHOW ) | |
EndIf | |
$tmpName = $Drives[$LoopCount+1][2] | |
$tmpName = $tmpName&" ("&$Drives[$LoopCount+1][3]&")" | |
GUICtrlSetData($Drives[$LoopCount+1][7], $tmpName) | |
$LoopCount += 1 | |
WEnd | |
EndFunc | |
#ce |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment