Page 1 of 1
Is There a way to command..to open and close a CD tray?
Posted: Wed Apr 04, 2018 8:33 pm
by Fasasoftware
Is There a way to command..to open and close a cd?
i need a solution cross-platform at least for window10 and mac os x for livecode community.....
I s there an easy way??? i know...livecode do not do....why???
Thanks a lot in advance,
Lestroso

Re: Is There a way to command..to open and close a cd?
Posted: Wed Apr 04, 2018 8:51 pm
by Klaus
Buonasera Lestroso,
what exactly do you mean with "open and close a cd"?
To "open" a card you need to "go to cd xyz" and to "close" it you need to go to another card or close the stack. Is that what you are looking for? Of course this can be scripted.
Best
Klaus
Re: Is There a way to command..to open and close a cd?
Posted: Wed Apr 04, 2018 8:52 pm
by DavJans
Something like this?
Code: Select all
on rawKeyDown pKey
--F1
if pKey is "65470" then
go to next card
--or go to card "card name"
else
pass rawKeyDown
end if
end rawKeyDown
Re: Is There a way to command..to open and close a cd?
Posted: Wed Apr 04, 2018 10:24 pm
by bogs
I believe he means a 'cd/dvd player', not a cd(card). I could be wrong though.
Re: Is There a way to command..to open and close a cd?
Posted: Wed Apr 04, 2018 10:46 pm
by Fasasoftware
Yes, bogs, i'm sorry...you're right....
i need a command to eject the cd inside the computer..is there a manner cross platform?? thanks a lot..
i saw the trick...launch the applescript to do that...ok but in windows??? ok....in addition the launch command don't work....
thanks a lot...
lestroso

Re: Is There a way to command..to open and close a cd?
Posted: Wed Apr 04, 2018 10:49 pm
by Fasasoftware
This applescript works fine! how i can launch this?? the command "launch" don't open any app!!!
i have made an app from this code....manually ok work but i f put a button and the script launch don't work...
Code: Select all
tell application "Finder"
eject (disks whose ejectable is true)
end tell
Best regards,
Lestroso
Re: Is There a way to command..to open and close a cd?
Posted: Wed Apr 04, 2018 11:13 pm
by bogs
I believe what you are going to wind up using is "shell" function, probably within an if/then or case/switch statement (since you'll have to issue different command line functions based on windows/mac), but maybe someone else has actually played with ejecting cds/dvds and will know better.
Re: Is There a way to command..to open and close a cd?
Posted: Thu Apr 05, 2018 11:08 am
by Klaus
AHA!
OK, on the Mac you can use shell to open and close the CD try:
Code: Select all
...
## Open:
get shell("drutil tray eject")
...
## Close:
get shell("drutil tray close")
...
Tested and works!
Since this is still listed in the dictionary you could try this on Windows:
Code: Select all
...
## Open:
get MCISendString("set cdaudio door open")
...
## Close
get MCISendString("set cdaudio door closed")
...
No idea if and how it will work if you have more than one CD/DVD device attached to your machine.
Best
Klaus
Re: Is There a way to command..to open and close a cd?
Posted: Thu Apr 05, 2018 10:42 pm
by Fasasoftware
thank a lot klaus.... i'll try your code...thanks again...
cheers!
Lestroso

Re: Is There a way to command..to open and close a CD tray?
Posted: Fri Apr 06, 2018 9:31 am
by mrcoollion
For Windows you may find the answer in the link below in combination with using the 'get shell' or 'get MCISendString' commands in livecode as the great Klaus suggested .
https://superuser.com/questions/972447/ ... le_rich_qa
Never tried it myself so you have to experiment
Regards,
Paul
Re: Is There a way to command..to open and close a CD tray?
Posted: Fri Apr 06, 2018 12:42 pm
by Fasasoftware
Dear friends,
i have tryed this script for Mac os x in a button :
Code: Select all
on mousedown
## Open:
get shell("drutil tray eject")
end mousedown
This works very fine!!!! Now i will try for windows...Thanks a lot to everybody!!!
Best regards,
Lestroso
Re: Is There a way to command..to open and close a CD tray?
Posted: Fri Apr 06, 2018 1:17 pm
by Klaus
Fasasoftware wrote: ↑Fri Apr 06, 2018 12:42 pm
Code: Select all
on mousedown
## Open:
get shell("drutil tray eject")
end mousedown
This works very fine!!!!
That's what I meant with "Tested and works".

Re: Is There a way to command..to open and close a CD tray?
Posted: Fri Apr 06, 2018 3:47 pm
by bogs
Klaus wrote: ↑Fri Apr 06, 2018 1:17 pm
Fasasoftware wrote: ↑Fri Apr 06, 2018 12:42 pm
This works very fine!!!!
That's what I meant with "Tested and works".
He's just confirming your not exploiting a
bug 
Re: Is There a way to command..to open and close a CD tray?
Posted: Fri Apr 06, 2018 4:00 pm
by Klaus
bogs wrote: ↑Fri Apr 06, 2018 3:47 pm
Klaus wrote: ↑Fri Apr 06, 2018 1:17 pm
Fasasoftware wrote: ↑Fri Apr 06, 2018 12:42 pm
This works very fine!!!!
That's what I meant with "Tested and works".

He's just confirming your not exploiting a
bug 
OK, I think can live with that.
