Jump to content

A little problem with drive lists


torels
 Share

Recommended Posts

Hi guys.

I have this piece of code that's driving me mad. What I basically want to do is this:

get a list of removble drives and see which of these is an iPod

$list = DriveGetDrive("removable")
For $i = 1 to $list[0]
    If _IsiPod($list[$i] & "\") Then 
        GUICtrlSetData($Combo, $list[$i] & "\")
    EndIf
Next
Func _IsiPod($drive)
    If DriveGetType($drive)="Removable" And FileExists($drive & "iPod_Control\iTunes\") Then Return 1
    Return 0
EndFunc   ;==>_IsiPod

it is always givving me an ugly Win2k style error with a big red cross on it. It says "Exception Processing Message c0000013 Parameters 75b1bf7c 4 75b1bf7c 75b1bf7c" it's title is "Windows - Disco non presente" (meaning the drive isn't there) and it has 3 buttons. Abort,Try Again,Continue. It pops up twice (clicking continue).

Why does this happen ?

Thanks in advance!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Try

$list = DriveGetDrive("removable")
For $i = 1 to $list[0]
    If _IsiPod($list[$i] & "\") Then 
        GUICtrlSetData($Combo, $list[$i] & "\")
    EndIf
Next

Func _IsiPod($drive)
    If DriveGetType($drive)="Removable" And DriveStatus($drive) = "READY" then
        if FileExists($drive & "iPod_Control\iTunes\") Then Return 1
    EndIf
    Return 0
EndFunc   ;==>_IsiPod
Link to comment
Share on other sites

yes it's working perfectly

thank you!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Had the same problem with ShellTristateTreeView / SMF :)... it recognizes the drive and tries to access it, but there's no media inserted! Had this issue not with USB but with my disk drive a:.

Link to comment
Share on other sites

actually I too believed it was a: giving problems (It's the floppy disk drive, and there was no floppy disk in it XD)

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

  • 3 months later...

actually I too believed it was a: giving problems (It's the floppy disk drive, and there was no floppy disk in it XD)

I'm getting a strange problem.

After reading this thread I wrote this function to test for valid path

;returns False if no media in drive or file/folder doesn't exist
Func _ValidPath($path)
    If $path = "" Then Return False
    Local $drive = StringLeft($path,3)
    Local $driveType = DriveGetType($drive)
    If @error Then Return False
    If $driveType <> "FIXED" And DriveStatus($drive) <> "READY" Then Return False
    Return FileExists($path)
EndFunc

However I have a DVD in drive E:. I can open the dvd in explorer. Open VIDEO_TS folder, in a cmd prompt I can do dir e:\video_ts and it all works. If I do ShellExecute("e:\video_ts") explorer gives me the error

"parameter invalid" even though there's no space in the path. I'm not getting any errors launching folders from the HD.

Edit: seems it only acts up in Vista64. If I put a data disc in, I can open it using the 64 bit shell by double clicking in explorer. If I try to do the same with a 32 bit shell window on Vista64, I get the "Burn a Disc" format window. Also if I choose Explorer from FreeCommander it does the same thing. Something 32 bit on my Vista64 is interfering.

Edited by MilesAhead
Link to comment
Share on other sites

wht's the function got to do with the rest of the post ?

i don't get it :)

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

  • 3 weeks later...

hi,

your script give me an idea to make like a shortcut on the desktop to access removable media.

I have a laptop with usb port and integrated SD/MMC/MG/CF port.

So, whenever I want to access the removable media, i just can double click on the script and open the

usb removable windows.

Anyway, I wanted the script goes like this.

1. whenever a removable media is inserted and detected the needed files in it, it will open the window.

2. whenever a removable media is inserted and no files that is required in it, it will give msg like "another/new usb is inserted"

3. whenever no removable media is inserted but the user run the script, it will give msg like "please insert usb"

I think i able to make the script work until #2. I tried the #3 but still don't get it.

$list = DriveGetDrive("REMOVABLE")
For $i = 1 to $list[0]
    If _IsUSB($list[$i] & "\") Then
        ShellExecute($list[$i])
    EndIf
Next

Func _IsUSB($drive)
    If DriveGetType($drive)="REMOVABLE" And DriveStatus($drive) = "READY" then
        if FileExists($drive & "COMMONFILES\MP3\") Then 
            Return 1
        Else
            MsgBox(4096, "error", "new usb inserted!")
        EndIf
    EndIf   
EndFunc  ;==>_IsUSB
Link to comment
Share on other sites

ahah, i think i figured it out.

i tried and tested...it worked on my computer though..

$list = DriveGetDrive("REMOVABLE")

For $i = 1 to $list[0]
    If _IsUSB($list[$i] & "\") Then
        ShellExecute($list[$i])
    EndIf
Next

If @error = 1 Then
    MsgBox(4096, "error", "NEW usb inserted!")
ElseIf @error = 2 Then
    MsgBox(4096, "error", "NO usb inserted!")
EndIf

Func _IsUSB($drive)
    If DriveGetType($drive)="REMOVABLE" And DriveStatus($drive) = "READY" Then
        If FileExists($drive & "COMMONFILES\MP3\") Then 
            Return 1
        Else
            SetError(1)
        EndIf
    Else
        If DriveGetType($drive)="REMOVABLE" And DriveStatus($drive) = "NOTREADY" Then
            SetError(2)
        EndIf
    EndIf
EndFunc  ;==>_IsUSB
Link to comment
Share on other sites

Well, anyway...i do have a question though...

How can I call the drive that has been detected in the script?

example

If @error = 1 Then
    do something or open the drive<-----------------------instead of calling msgbox
ElseIf @error = 2 Then
    MsgBox(4096, "error", "NO usb inserted!")
EndIf
Link to comment
Share on other sites

  • 2 weeks later...

$list = DriveGetDrive("removable")
For $i = 1 to $list[0]
    If _IsiPod($list[$i] & "\") Then
        msgbox(0, "test", "test")
    EndIf
Next

Func _IsiPod($drive)
    If DriveGetType($drive)="Removable" And DriveStatus($drive) = "READY" then
        if FileExists($drive & "iPod_Control\iTunes\") Then Return 1
    EndIf
    Return 0
EndFunc  ;==>_IsiPod

i'm using this script on this one computer and tried and gave me an error like this

C:\Documents and Settings\GUNZed\??????\isipod.au3 (2) : ==> Subscript used with non-Array variable.:
For $i = 1 to $list[0]
For $i = 1 to $list^ ERROR

the other computer runs well...

any idea why?

Link to comment
Share on other sites

$list = DriveGetDrive("removable")
For $i = 1 to $list[0]
    If _IsiPod($list[$i] & "\") Then
        msgbox(0, "test", "test")
    EndIf
Next

Func _IsiPod($drive)
    If DriveGetType($drive)="Removable" And DriveStatus($drive) = "READY" then
        if FileExists($drive & "iPod_Control\iTunes\") Then Return 1
    EndIf
    Return 0
EndFunc ;==>_IsiPod

i'm using this script on this one computer and tried and gave me an error like this

C:\Documents and Settings\GUNZed\??????\isipod.au3 (2) : ==> Subscript used with non-Array variable.:
For $i = 1 to $list[0]
For $i = 1 to $list^ ERROR

the other computer runs well...

any idea why?

ok i solved it...

i should put the

if NOT @error Then
...
...

top of the script...

glad the autoit help file really help me...

Link to comment
Share on other sites

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...