Is There a way to command..to open and close a CD tray?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Is There a way to command..to open and close a CD tray?

Post by Fasasoftware » Wed Apr 04, 2018 8:33 pm

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 :oops:

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Is There a way to command..to open and close a cd?

Post by Klaus » Wed Apr 04, 2018 8:51 pm

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

DavJans
Posts: 270
Joined: Thu Dec 12, 2013 4:21 pm
Location: Spokane, WA USA

Re: Is There a way to command..to open and close a cd?

Post by DavJans » Wed Apr 04, 2018 8:52 pm

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
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Is There a way to command..to open and close a cd?

Post by bogs » Wed Apr 04, 2018 10:24 pm

I believe he means a 'cd/dvd player', not a cd(card). I could be wrong though.
Image

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: Is There a way to command..to open and close a cd?

Post by Fasasoftware » Wed Apr 04, 2018 10:46 pm

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 :oops:

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: Is There a way to command..to open and close a cd?

Post by Fasasoftware » Wed Apr 04, 2018 10:49 pm

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Is There a way to command..to open and close a cd?

Post by bogs » Wed Apr 04, 2018 11:13 pm

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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Is There a way to command..to open and close a cd?

Post by Klaus » Thu Apr 05, 2018 11:08 am

AHA! :D

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

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: Is There a way to command..to open and close a cd?

Post by Fasasoftware » Thu Apr 05, 2018 10:42 pm

thank a lot klaus.... i'll try your code...thanks again...
cheers!
Lestroso :D

mrcoollion
Posts: 719
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Is There a way to command..to open and close a CD tray?

Post by mrcoollion » Fri Apr 06, 2018 9:31 am

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 :shock:

Regards,

Paul

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: Is There a way to command..to open and close a CD tray?

Post by Fasasoftware » Fri Apr 06, 2018 12:42 pm

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!!! :D
Best regards,
Lestroso

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Is There a way to command..to open and close a CD tray?

Post by Klaus » Fri Apr 06, 2018 1:17 pm

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". 8)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Is There a way to command..to open and close a CD tray?

Post by bogs » 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". 8)
He's just confirming your not exploiting a bug :D
Image

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Is There a way to command..to open and close a CD tray?

Post by Klaus » Fri Apr 06, 2018 4:00 pm

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". 8)
He's just confirming your not exploiting a bug :D
OK, I think can live with that. ;-)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”