DeviceType: 7
DeviceNumber: 2
PartitionNumber: 1
---------------------------
Eject() : For Removable storage devices
Re: Eject() - For CD/DVD and USB Mass Storage devices
jantom, if DeviceType is 7 then sPHDRV will not be blank. Did you insert MsgBox correctly?jantom wrote:DeviceType: 7
DeviceNumber: 2
PartitionNumber: 1
---------------------------
you wrote:hVol = 248
sPHDRV = (blank)
ErrorLevel = -2
Re: Eject() - For CD/DVD and USB Mass Storage devices
But yes, it is blank.
It looks like the following condition is not met:
If I omit the above if clause then sPHDRV = \\\\.\\PHYSICALDRIVE0
It looks like the following condition is not met:
If ( NumGet( STORAGE_DEVICE_NUMBER, "UInt" ) = FILE_DEVICE_DISK )
If I omit the above if clause then sPHDRV = \\\\.\\PHYSICALDRIVE0
Re: Eject() - For CD/DVD and USB Mass Storage devices
hi jantom, give me a day's time. I am about borrow a similar model. I will test and let you know.
Are you trying the function as standalone or running it as a part of an another script?
Not possible, because FILE_DEVICE_DISK := 0x00000007 is initialized and our test revealed DeviceType: 7It looks like the following condition is not met
Are you trying the function as standalone or running it as a part of an another script?
Re: Eject() - For CD/DVD and USB Mass Storage devices
Standalone. I just trigger the function with: Eject ( "F:" ).
Many thanks for looking into it.
Many thanks for looking into it.
Re: Eject() - For CD/DVD and USB Mass Storage devices
Hi jantom, I have tested Eject() function with following "FIXED" type USB drive and it works fine.
Caption: Seagate Backup+ BK USB Device
Description: Disk drive
DeviceID: \\.\PHYSICALDRIVE1
InterfaceType: USB
MediaLoaded: -1
MediaType: External hard disk media
Model: Seagate Backup+ BK USB Device
Name: \\.\PHYSICALDRIVE1
Partitions: 1
PNPDeviceID: USBSTOR\DISK&VEN_SEAGATE&PROD_BACKUP+_BK&REV_0836\NA53TNPC&0
SectorsPerTrack: 63
Status: OK
Re: Eject() - For CD/DVD and USB Mass Storage devices
Great! It works fine with my drive now, too.
Re: Eject() - For CD/DVD and USB Mass Storage devices
Nice script. One trap with using this in a script on the drive itself is that any process with its working directory on the drive (such as the script itself) will prevent it from ejecting. In that case,
Code: Select all
SetWorkingDir % A_WinDir
Eject(A_ScriptDir)
Re: Eject() - For CD/DVD and USB Mass Storage devices
Good catch
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Eject() - For CD/DVD and USB Mass Storage devices
I have never tried anything like this before.lexikos wrote:Code: Select all
SetWorkingDir % A_WinDir Eject(A_ScriptDir)
Thanks.
Re: Eject() - For CD/DVD and USB Mass Storage devices
You mean having a script eject the drive it's running off? I needed this for a script which copies tools onto a PC and then ejects, so I can use the drive elsewhere or run anti-malware scans without having my tools quarantined.
Re: Eject() - For CD/DVD and USB Mass Storage devices
That - I have tried and succeeded.lexikos wrote:You mean having a script eject the drive it's running off?
Eject() is in my std lib folder. I have 5 Win versions on my computer ( XP, Win 7, Win 8.1, Win 7 x64 and Win 8.1 x64 ) and AutoHotkey is installed and shared on a common folder ( D:\AutoHotkey ).
I have now placed your two-liner script in my USB mass storage devices. Double clicking it from Windows Explorer ejects the drive and closes the explorer automatically in Win 7 & 8.1. However, in Win XP, Windows Explorer navigates to "Control Panel" after the drive is ejected, and so, requires an additional click to close the Explorer.
Re: Eject() - For CD/DVD and USB Mass Storage devices
Hi there,
sorry for the newbie question - how do i get it to work with a hotkey?
i added this code after the eject.ahk but nothing happened:
sorry for the newbie question - how do i get it to work with a hotkey?
i added this code after the eject.ahk but nothing happened:
Code: Select all
^!u::
DriveGet, List, List, REMOVABLE
StringReplace, List, List, A
Drv := SubStr( List,1,1 ) . ":"
Eject(Drv)
Return
Re: Eject() - For CD/DVD and USB Mass Storage devices
Insert MsgBox % Drv before Eject and see the drive letter it displays. Maybe you are trying to eject an external HDD, which is usually of type "FIXED".
Re: Eject() - For CD/DVD and USB Mass Storage devices
or before the solution of SKAN do:
DriveGet, Drv, Type, %Drv%
So you can have the Type of the drive
DriveGet, Drv, Type, %Drv%
So you can have the Type of the drive
Re: Eject() - For CD/DVD and USB Mass Storage devices
Thanks! Integrated it to my special AHK-Totalcmd interface
Re: Eject() - For CD/DVD and USB Mass Storage devices
Hi,
thanks for your software. Unfortunatelly I got an error. It is complaining about a "Member not found" on method _NewEnum() on line 029.
I am trying to remove a USB Stick on Windows 7 Enterprise SP1 x64.
Regards
JD
thanks for your software. Unfortunatelly I got an error. It is complaining about a "Member not found" on method _NewEnum() on line 029.
I am trying to remove a USB Stick on Windows 7 Enterprise SP1 x64.
Regards
JD
Re: Eject() - For CD/DVD and USB Mass Storage devices
Thanks, SKAN!
I have included the Eject() function into AutoHotFlow. There is now an action Eject drive.
I have included the Eject() function into AutoHotFlow. There is now an action Eject drive.
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
-
- Posts: 22
- Joined: 19 Aug 2015, 04:35
- Contact:
Re: Eject() - For CD/DVD and USB Mass Storage devices
Good work!
Probably you should add one Tray Tip indicating the successful ejection of a drive.
Probably you should add one Tray Tip indicating the successful ejection of a drive.
KamlaAwasthi-(http://kamalahktips.blogspot.in/)-Github-(https://github.com/KamalAwasthi)
Re: Eject() - For CD/DVD and USB Mass Storage devices
Hello. I'm trying to use the Eject function in my script, but I'm having a weird issue. The issue being that eject won't work when I compile the script. It works fine uncompiled. However, when the same script is compiled and run, the Eject function returns 1 for success, 0 for ErrorLevel, 0 for A_LastError, and the drive does not eject. Run it uncompiled and boom the device ejects. It's very odd.
My machine is running Windows 10 with AHK 1.1.23.05. The function has not been modified from its original state and "Eject(USBdrv)" is used to call it. USBdrv being "F", in this specific case. The script was originally compiled with the "Unicode 32-bit" bin, but I've also tried ANSI to no avail. Any thoughts? Thanks!
My machine is running Windows 10 with AHK 1.1.23.05. The function has not been modified from its original state and "Eject(USBdrv)" is used to call it. USBdrv being "F", in this specific case. The script was originally compiled with the "Unicode 32-bit" bin, but I've also tried ANSI to no avail. Any thoughts? Thanks!
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 135 guests