Sign in to follow this  
Followers 0
Chimaera

Cant get the time right for dvd drive

6 posts in this topic

Its a simple one i guess, but im trying to open the dvd drive then wait 5 secs then close it again

Should be simple enough but i get the right delay between the open and close but the script runs on for another 10 secs or so before closing?

Global $var = DriveGetDrive( "CDROM" )
    If not @error Then
        For $i = 1 to $var[0]
            Local $var2 = CDTray($var[$i] , "open")
        Next
        Sleep(5000)
        For $i = 1 to $var[0]
            $var2 = CDTray($var[$i] , "closed")
        Next
    EndIf

Even with exit at the end it still runs on

Any thoughts

Share this post


Link to post
Share on other sites



Just out of curiosity, try something like this to see if it still hangs (am not where I can test at the moment):

$wmp = ObjCreate("WMPlayer.OCX.7" )
$colCDROMs = $wmp.cdromCollection

If $colCDROMs.Count >= 1 Then
        For $i = 0 to $colCDROMs.Count - 1
            $colCDROMs.Item($i).Eject
                Sleep(5000)
            $colCDROMs.Item($i).Eject
        Next
EndIf

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It appeared to JLo, but after testing...

$wmp = ObjCreate("WMPlayer.OCX.7")

$colCDROMs = $wmp.cdromCollection



If $colCDROMs.Count >= 1 Then

    ;For $i = 0 To $colCDROMs.Count - 1

        $colCDROMs.Item(0).Eject
        ;Beep(700, 100)
        Sleep(5000)
        ;Beep(700, 100)
        $colCDROMs.Item(0).Eject
        Beep(700, 100)
    ;Next

EndIf

That never, so it's possible that it's opening and closing my virtual clonedrive disc.

EDIT: confirmed, 2 beeps from below.

$wmp = ObjCreate("WMPlayer.OCX.7")

$colCDROMs = $wmp.cdromCollection



If $colCDROMs.Count >= 1 Then

    For $i = 0 To $colCDROMs.Count - 1

        $colCDROMs.Item($i).Eject
        ;Beep(700, 100)
        Sleep(2000)
        ;Beep(700, 100)
        $colCDROMs.Item($i).Eject
        Beep(700, 100)
    Next

EndIf

Another 2 beeps below.

Global $var = DriveGetDrive( "CDROM" )
    If not @error Then
        For $i = 1 to $var[0]
            Local $var2 = CDTray($var[$i] , "open")
        Next
        Sleep(2000)
        For $i = 1 to $var[0]
            $var2 = CDTray($var[$i] , "closed")
            Beep(700,100)
        Next

    EndIf

One beep, no delay below

Global $var = DriveGetDrive( "CDROM" )
    If not @error Then
        ;For $i = 1 to $var[0]
            Local $var2 = CDTray($var[1] , "open")
        ;Next
        Sleep(2000)
        ;For $i = 1 to $var[0]
            $var2 = CDTray($var[1] , "closed")
            Beep(700,100)
       ; Next

    EndIf
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I tried the wmplayer ones but i dont have it installed on my machine so it throws an must be object error

The last one of JohnOne's

Works as it should, many thanks

Global $var = DriveGetDrive( "CDROM" )
    If not @error Then
        Local $var2 = CDTray($var[1] , "open")
            Sleep(7000)
        $var2 = CDTray($var[1] , "closed")
        Beep(700,100)
    EndIf

Thing is what happens if you have multiple drives will it still open them all without the For/Next ?

Edited by Chimaera

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  
Followers 0