Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Eject a CD-Rom like on Mac OS X


  • Please log in to reply
8 replies to this topic
Tekl
  • Members
  • 814 posts
  • Last active: May 03 2009 03:28 PM
  • Joined: 24 Sep 2004
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....forum/Eject.bmp

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

BoBo
  • Guests
  • Last active:
  • Joined: --
Cool !
Thx, for sharing it :D

[@ Tekl] :)

Gre
  • Members
  • 74 posts
  • Last active: Nov 22 2004 06:23 AM
  • Joined: 12 Oct 2004
Nice, an eye-candy.
Thanks

  • Guests
  • Last active:
  • Joined: --
Are you by any chance Wolfgang from C't magazine?

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
I sure hope you mean Tekl, not BoBo.... :lol:

RobOtter
  • Members
  • 133 posts
  • Last active: Jul 24 2014 11:29 AM
  • Joined: 30 Jan 2005

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

Bucky3006
  • Guests
  • Last active:
  • Joined: --
:? 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

BoBo¨
  • Guests
  • Last active:
  • Joined: --
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.

widow
  • Guests
  • Last active:
  • Joined: --
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.