Jump to content

don't forget your usb key


sylvanie
 Share

Recommended Posts

Slightly different take...

Still uses the same basic concept

#include <Misc.au3>
;False = Beep, True = Play Sound
$sound = True
;Visible
$show_error = True

$dlist = _ListDrives()

While 1
    Sleep(100)
    If _IsPressed("a5") <> 1 Then ; test if the AltGR key is not pressed. This test avoids that the program executes the function detect() when this key is pressed because AltGR => ctrl +alt (it's not always true but in our case it is)
        If _IsPressed("11") Then ; test if the Ctrl key is pressed
            If _IsPressed("12") Then ;test if the alt key is pressed
                _CheckDrives()
            EndIf
        EndIf
    EndIf
WEnd

Func _CheckDrives()
    $c = 0
    $a = DriveGetDrive("REMOVABLE")
    If Not @error Then $c += $a[0]
    $b = DriveGetDrive("CDROM")
    If Not @error Then $c += $b[0]
    If $c > $dlist[0] Then $dlist = _ListDrives()
    For $i = 1 To $dlist[0]
        If DriveStatus($dlist[$i] & "\") = "READY" Then
            If $sound = True Then
                SoundPlay(@WindowsDir & "\media\tada.wav", 1)
            Else
                For $i = 1 To 10
                    Beep(500, 200)
                    Sleep(20)
                Next
            EndIf
            If $show_error Then MsgBox (0, "Check Drive", "Please check drive """ & $dlist[$I] & """ for media.")
        EndIf
    Next
EndFunc   ;==>_CheckDrives

Func _ListDrives()
    Local $big_array[1], $count = 1
    $cds = DriveGetDrive("CDROM")
    If Not @error Then
        ReDim $big_array[UBound($big_array) + $cds[0]]
        For $i = 1 To $cds[0]
            $big_array[$count] = $cds[$i]
            $count += 1
        Next
    EndIf
    $cds = DriveGetDrive("REMOVABLE")
    If Not @error Then
        ReDim $big_array[UBound($big_array) + $cds[0]]
        For $i = 1 To $cds[0]
            $big_array[$count] = $cds[$i]
            $count += 1
        Next
    EndIf
    $big_array[0] = $count - 1
    Return $big_array
EndFunc   ;==>_ListDrives

Maybe a little faster?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...