Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 01, 2015, 01:11:02 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Eject/CloseCD  (Read 10648 times)

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Eject/CloseCD
« on: February 05, 2008, 03:10:17 AM »
Works great :Thmbsup: but...

Have changed script to reflect only one drive, but it still does 2 simultaneously?

 :)

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,218
    • View Profile
    • Coding Snacks by Lanux128
    • Donate to Member
Re: Eject/CloseCD
« Reply #1 on: February 05, 2008, 08:58:30 PM »
post modified script here so that someone can have a look and suggest what's wrong. ;)

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #2 on: February 06, 2008, 05:19:42 AM »
I think I'm confusing Title line in the shortcut?

Anyway here's script on EjectCD

;EjectCD.ahk
; Ejects all CD drives, or add the drives to eject to the command line.
;  Example: EjectCD.exe E
;Skrommel @2006

list=%1%
If 0=0
  DriveGet,list,List,CDROM

Loop,Parse,list
  Drive,Eject,%A_LoopField%:


Thanks

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Eject/CloseCD
« Reply #3 on: February 06, 2008, 05:38:45 AM »
I know what the problem is. A recent ahk update broke the following line:
Code: [Select]
if 0=0

Which was supposed to check if there were no command line arguments.
Replace it with:
Code: [Select]
if (list = "")
And it should be fixed ;)

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #4 on: February 06, 2008, 05:47:42 AM »
Don't work  :(

Code:

;EjectCD.ahk
; Ejects all CD drives, or add the drives to eject to the command line.
;  Example: EjectCD.exe E
;Skrommel @2006

list=%1%
if (list = "")
  DriveGet,list,List,CDROM

Loop,Parse,list
  Drive,Eject,%A_LoopField%:

« Last Edit: February 06, 2008, 05:49:26 AM by CleverCat »

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #5 on: February 06, 2008, 05:55:54 AM »
Am I supposed to add something in the 'start in' or 'arguments' line on my shortcut?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Eject/CloseCD
« Reply #6 on: February 06, 2008, 06:36:48 AM »
Oh, i thought you already were doing that!

Yes, in the "arguments" line, add the letter of the drive you want to eject!
(better add it with the ':' for example, e: )

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #7 on: February 06, 2008, 07:36:30 AM »
Done that on open and close...

Still opening both?? :(

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Eject/CloseCD
« Reply #8 on: February 06, 2008, 07:56:04 AM »
I made a small mistake, you're supposed to only use the drive letter (without the ':').

Does it close only one but open both of them?

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,218
    • View Profile
    • Coding Snacks by Lanux128
    • Donate to Member
Re: Eject/CloseCD
« Reply #9 on: February 06, 2008, 12:42:21 PM »
CleverCat, how do you launch your EjectCD app, i mean by clicking on icon or via command-line and how many optical drives do you have? because the above if run by itself is designed eject all drives but you can insert drive parameters to selectively eject.

also, you can use a command-line tool called Eject to open/close a CD-ROM drive. this can be called via Farr alias as i did here thanks to jgpaiva.

ws-farr-eject-1.png

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #10 on: February 07, 2008, 06:32:47 AM »
Opens both/closes both... :D

Via Icon on Dock.

Trying to make it work thru farr - but I'm not really sure what I'm doing!  ;D

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #11 on: February 07, 2008, 06:44:24 AM »
I've downloaded eject - is it non install - do I place it where I want it? :tellme:

« Last Edit: February 07, 2008, 06:54:05 AM by CleverCat »

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,137
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #12 on: February 09, 2008, 05:01:21 AM »
I've gone back to using Wizmo...

http://www.grc.com/wizmo/wizmo.htm

Working great.... :Thmbsup:

johnnyzero

  • Participant
  • Joined in 2006
  • *
  • gravatar avatar
  • Posts: 25
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #13 on: July 12, 2008, 08:16:40 PM »
I'd like to modify your EjectCD script so that it will either eject or close a certain drive, depending on its current state. To toggle the drive's "tray state", if you will.

I've tried modifying your script by just adding "1" as the last argument (Drive,Eject,%A_LoopField%:,1). According to the AutoHotKey command docs, that argument should make the Eject command work the way I want.

Unfortunately, it doesn't work. My recompiled script will close the tray if it's open, but it won't eject it if it's closed. Any suggestions? As you can tell, I'm not an AutoHotkey scripting expert... :)

best,
JohnB

btw, I've also made the if (list = "") change to your script, as mentioned in a previous post.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Eject/CloseCD
« Reply #14 on: July 13, 2008, 04:00:50 AM »
Hi johnnyzero!
From what I understand from reading the help file, the '0' is for eject and the '1' is for close.
You can try the following, though:

Code: [Select]
{
Drive,Eject,%A_LoopField%:,0
if (Errorlevel = 0)
  Drive,Eject,%A_LoopField%:,1
}

Instead of the Drive,Eject line.
That'll check if the state of the drive changed, and if not, do the other command.

johnnyzero

  • Participant
  • Joined in 2006
  • *
  • gravatar avatar
  • Posts: 25
    • View Profile
    • Donate to Member
Re: Eject/CloseCD
« Reply #15 on: July 13, 2008, 10:53:28 AM »
Thanks for the reply, jgpaiva. Good idea - your code seems like it should work, but it didn't for me. Oh well...

I ended up using this rather clever example code from the AHK docs to create a hotkey-based script, converted it to an EXE, and I have the EXE autorun at system startup:

F11::
Drive, Eject
; If the command completed quickly, the tray was probably already ejected.
; In that case, retract it:

if A_TimeSinceThisHotkey < 1000 ; Adjust this time if needed.
     Drive, Eject,, 1
return

Works great - pressing F11 toggles my drive tray open/closed. That's actually more convenient than having to click on something.

best,
JohnB