This will be extremely short, and you will need to experiment by yourself to make it perfectly suited to your needs. drutil has many options all listed here https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/drutil.1.html
Basically, you got two options. The simplest is to ask drutil for the status of the disk in the timer. Put this in the Action event of a timer :
dim s as new shell
s.execute "drutil -drive 1 status"
if instr(s.result,"No Media Inserted") = 0 then
msgbox "Thank you for inserting a disk"
end if
s.Close
I assume the Mac has only one DVD drive. When a media is inserted, the msgbox appears. Note that it can be anything : blank or not. To determine which has been inserted, you need to look at the content of Result. Here is what I get for a CD :
[code]Vendor Product Rev
HL-DT-ST DVDRW GA32N KE06
Type: CD-R Name: /dev/disk4
Write Speeds: 10x, 16x, 24x
Overwritable: 79:57:69 blocks: 359844 / 736.96MB / 702.82MiB
Space Free: 79:57:69 blocks: 359844 / 736.96MB / 702.82MiB
Space Used: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
Writability: appendable, blank, overwritable
[/code]
You will need to experiment with your particular configuration to see what is of interest for your app.
The issue with the timer technique is that it puts a drain on the app every time the timer executes, since it needs to run a new drutil.
A more elaborate solution is to :
- Insert a class
- Make its super “Shell”
- Drag an instance over your window ; lets call it
S1
.
- Add to the instance the DataAvailable event
- S1.execute(“drutil -drive 1 poll”)
From now on, every action on the drive will trigger DataAvailable and feed S1.Result. A lot of information is available on the type of media, the status of the drive, etc.
This is kind of equivalent to a thread, since drutil poll works in the background and sends information to your app only when something new happens.