Jump to content
Sign in to follow this  

CD-ROM open/close (with letter in command line)

Recommended Posts

Hello all!
I used to manage the state of my real CD-ROM from the keyboard. I have successfully used a free program HotKey Manager from here http://www.killprog.com/indexe.html.
But this program works correctly only if the real CD-ROM have the letter in the system before the letter of the virtual CD-ROMs.
What do if the CD-ROM has the letter 'Z'?
AutoIT helps!
The text of the script below


#include <WinAPI.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

If $CMDLINE[0] = 0 Then
    MsgBox($MB_SYSTEMMODAL, "No parameter", "Please use parameter: letter of CD-ROM. For example, 'E:'")

If $CMDLINE[0] = 1 Then
    Global $Drive_Letter = $CMDLINE[1]
    ;MsgBox($MB_SYSTEMMODAL, "Drive_Letter", $Drive_Letter)


Func Example()

    ; Create a constant file name.
    Local Const $sFile = "CD_Open.txt"

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFile, $FO_READ)
    If $hFileOpen = -1 Then
        ;MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        ; open CR-ROM, create temporary file and Exit
        CDTray($Drive_Letter, "open")
        Local $hFile = _WinAPI_CreateFile($sFile, 1)
        Return True
        ; close CD-ROM and delete temporary file
        CDTray($Drive_Letter, "close")

    Return True
EndFunc   ;==>Example

Share this post

Link to post
Share on other sites

@Eugen - Welcome to the Forum!

I'm presuming your code is a useful example, and this is not a question, that should be posted in the Q&A section of the Forum.

It would be easier to tell, if you used the AutoIt code tags (quoting) for your code, which makes it eminently more readable.

See the button to the immediate left of the quote balloon button, which is to the left of the paw print button in the post editor.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.


What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)


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  

  • Create New...