AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Eject a CD-Rom like on Mac OS X

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 814
Location: Germany

PostPosted: Sat Oct 30, 2004 11:15 am    Post subject: Eject a CD-Rom like on Mac OS X Reply with quote

Hello,

I've made a small script, which ejects a drive an shows a transparent symbol like in OS X. Download the Image and place it in the same folder of the script: http://www.rumborak.de/bilddaten/forum/Eject.bmp

Code:

ScrollLock::
   transparent = 150 ; starting transparency
   
   ; calculate position
   distY = %A_ScreenHeight%
   posY = %A_ScreenHeight%
   distY /= 4
   posY -= %distY%
   
   ; create OSD
   Gui, Add, pic,x0 y0, %A_ScriptDir%\eject.bmp
   DetectHiddenWindows on
   WinWait, %A_ScriptName%  ; Set the "last found" window to GUI window.
   WinSet, TransColor,0000FF %transparent%
   WinSet, AlwaysOnTop, On
   Gui, -Caption
   Gui, Show, w150 h150 y%posY%
   
   Sleep, 100 ; a short sleep, so the image will always be shown
   
   Drive, Eject,F:, ; Eject the drive
   if A_TimeSinceThisHotkey < 1000 ; Adjust this time if needed.
   {
      Drive, Eject,F:, 1 ; Close the drive if ejecting fails
   }
   
   ; fade down the OSD
   Loop, %transparent%
   {
      transparent -= 1
      WinSet, TransColor,0000FF %transparent%
   }
   Gui, Destroy
return


Regards, Tekl
Back to top
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Sat Oct 30, 2004 11:42 am    Post subject: Reply with quote

Cool !
Thx, for sharing it Very Happy

[@ Tekl] Smile
Back to top
Gre



Joined: 12 Oct 2004
Posts: 74
Location: São Paulo ,Brazil

PostPosted: Tue Nov 02, 2004 4:26 pm    Post subject: Reply with quote

Nice, an eye-candy.
Thanks
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Jan 31, 2005 11:04 pm    Post subject: Reply with quote

Are you by any chance Wolfgang from C't magazine?
Back to top
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Tue Feb 01, 2005 12:26 am    Post subject: Reply with quote

I sure hope you mean Tekl, not BoBo.... Laughing
Back to top
View user's profile Send private message
RobOtter



Joined: 30 Jan 2005
Posts: 130
Location: Darmstadt, Germany

PostPosted: Tue Feb 01, 2005 9:15 am    Post subject: Reply with quote

Anonymous wrote:
Are you by any chance Wolfgang from C't magazine?


He is, indeed. I asked myself the same question and did a bit of research, it was not too hard to find out.
Thanks to Tekl and his article in the german computer magazine c't, I now spend a bit more time on AHK after seeing what is possible with it...
Back to top
View user's profile Send private message
Bucky3006
Guest





PostPosted: Sat Mar 22, 2008 4:28 pm    Post subject: Eject CDRom Reply with quote

Confused I am very new to this and I don't know how to activate this script. Do I set my own command to activate or what?
Thanks,
Bucky
Back to top
BoBo¨
Guest





PostPosted: Sat Mar 22, 2008 5:05 pm    Post subject: Reply with quote

Execute the script. Nothing happens.
Press the ScrollLock key at your keyboard, because the script is assigned to a "Hotkey". One reason why AutoHotkey is named AutoHotkey.
Back to top
widow
Guest





PostPosted: Sat Mar 22, 2008 7:57 pm    Post subject: Reply with quote

Code:
  Drive, Eject,F:, ; Eject the drive


Also you might want to change "F" to the drive you want to eject.

There is a API to check for what kind of drive is there, but the problem comes when it is a virtual CD drive. Some virtual drivers dont like to be ejected i think.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group