Jump to content

TrayQuickie


R.L.
 Share

Recommended Posts

Just a small one to play with the open tray function in Autoit

It is designed to open whatever drive letter quickly. By default, it will open D: drive, wait for 10 seconds and then close the tray. Press <Enter> will close the tray early. Press <Insert> will extend another 15 seconds. If a different drive than D: drive is used (e.g., e: drive), one can make a command in

the shortcut after the script is complied (e.g., Trayquickie.exe E: ) and it will launch the drive specified. Hence more than one drives can be pointed to by shortcuts.

July, 7, 04: NEW CODE UPLOADED http://www.autoitscript.com/fileman/users/public/RL/trayquickie.au3

Edited by R.L.
Link to comment
Share on other sites

  • 2 weeks later...

If $CMDLINE[0]= 0 Then

Global $dr = "d:"

call ("operation")

Else

Global $dr = $CMDLINE[1]

call ("operation")

EndIf

Func status()

If DriveStatus($dr) = "ready" Then

Global $status = "occupied"

elseif DriveStatus($dr) = "notready" Then

Global $status = "empty"

else

Global $status = "not read"

endif

EndFunc

Func operation()

  AutoItSetOption("TrayIconHide",1)

call ("status")

CDTray($dr, "open")

HotKeySet ( "{ENTER}", "close" )

HotKeySet("{insert}", "delay")

ToolTip("Tray " & $dr &" was " & $status & "; closes in 10 sec (hit <Enter> to close; <insert> to delay)", 8, 0)

sleep(10000)

CDTray($dr, "close")

EndFunc

func delay()

  ToolTip("Tray " & $dr &" was " & $status & "; closes in 15 sec (hit <Enter> to close; <insert> to delay)", 8, 0)

  sleep (15000)

Call("close")

  EndFunc

Func close()

CDTray($dr, "close")

exit

EndFunc

I think you could change this

If $CMDLINE[0] = 0 Then
Global $dr = "d:"
call ("operation")

to this:

If $CMDLINE[0] = 0 Then
Global $dr = DriveGetDrive( "cdrom" )

If NOT @error Then
call ("operation")
End If
..
Link to comment
Share on other sites

Thanks. I noticed that error and updated the script (sorry, I should have posted the updated one long ago but have been busy) :(

Now it will give out a "not read" status if the drive is unaccessible due to other programs occupying it :ph34r: But thanks for pointing it out, yours was a nice suggestion, too.

Func status()
If DriveStatus($dr) = "ready" Then
Global $status = "occupied" 
elseif DriveStatus($dr) = "notready" Then
Global $status = "empty" 
else 
Global $status = "not read" 
endif

EndFunc

RL

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