Jump to content
Sign in to follow this  
torels

A little problem with drive lists

Recommended Posts

torels

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

Share this post


Link to post
Share on other sites
KaFu

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

Share this post


Link to post
Share on other sites
torels

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

Share this post


Link to post
Share on other sites
KaFu

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

Share this post


Link to post
Share on other sites
torels

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

Share this post


Link to post
Share on other sites
MilesAhead

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

Share this post


Link to post
Share on other sites
torels

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

Share this post


Link to post
Share on other sites
MilesAhead

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

i don't get it :)

FileExists by itself traps on removable drives with no media.

You really don't see a correlation?

Share this post


Link to post
Share on other sites
mrmacadamia

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

Share this post


Link to post
Share on other sites
mrmacadamia

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

Share this post


Link to post
Share on other sites
mrmacadamia

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

Share this post


Link to post
Share on other sites
mrmacadamia

$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?

Share this post


Link to post
Share on other sites
mrmacadamia

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

Share this post


Link to post
Share on other sites
KaFu

i should put the if NOT @error Then at top of the script...

Looking at the solution it's obvious, but I saw you're request and didn't see it then too, good find :D .

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.