Autorun removable drive

前端 未结 1 776
小蘑菇
小蘑菇 2021-01-07 17:41

Autorun was disabled in Windows. I am looking for an alternative. I got this AutoIt script :

 $DBT_DEVICEARRIVAL = \"0x00008000\"
 $WM_DEVICECHANGE = 0x0219
         


        
相关标签:
1条回答
  • 2021-01-07 18:22

    I searched for some WAVE-files on a Removable Device (SD-Card) with this code:

    #include <Array.au3>
    
    ; Register search function
    Global $DBT_DEVICEARRIVAL = "0x00008000"
    Global $WM_DEVICECHANGE = 0x0219
    Global $drives = DriveGetDrive("REMOVABLE")
    GUIRegisterMsg($WM_DEVICECHANGE, "searchOnSD")
    
    ; check all already known removable devices
    If UBound($drives) > 0 Then
        For $drive In $drives
            If StringRegExp($drive, "^[[:alpha:]]:$") Then check($drive)
        Next
    EndIf
    
    ; search for WAV-file on SD-Card
    Func searchOnSD($hWndGUI, $MsgID, $WParam, $LParam)
        If $WParam == $DBT_DEVICEARRIVAL Then
            $newDrives = DriveGetDrive("REMOVABLE")
            $drive = $newDrives
            For $i = 0 To UBound($drives) - 2
                _ArrayDelete($drive, 0)
            Next
            If UBound($drive) > 0 Then
                $drive = $drive[0]
                If StringRegExp($drive, "^[[:alpha:]]:$") Then
                    ConsoleWrite("new removable (" & $drive & ") found." & @CR)
                    check($drive)
                EndIf
            EndIf
        EndIf
        $drives = DriveGetDrive("REMOVABLE")
    EndFunc   ;==>searchOnSD
    

    In the check($drive) function I then performed something with the WAVE file after evaluating DriveStatus($drive) == "READY" And FileExists($wavFile).

    0 讨论(0)
提交回复
热议问题