Alright, I know in the past I started to look into how to make an autohotkey script that would automatically eject the drive you have the PA menu on (when you click the eject button on PA menu). Well I began to write the script, and I made a basic one that works. Here it is.....
DriveGet, list,List, REMOVABLE ;Only gets Removable Drives. DriveGet, cap, capacity, %list%: ;Gets total usb size DrivespaceFree, free, %list%: ;Tells you available space on drive DriveGet, fs, fs, %list%: ;Tells you what format the drive is in, eg: Fat32, Fat DriveGet, label, label, %list%: ;Tells you what the usb Label name is, such as Nathan's Drive. DriveGet, serial, serial, %list%: ;Tells you drives serial number DriveGet, type, type, %list%: ;Tells you what type of drive it is, Removable, Fixed DriveGet, status, status, %list%: ;Tells you if the drive is able to be removed by telling you its ready If list = ExitApp else MsgBox, 4, Eject, %list%:, Total Size:%cap%MB, Free Space:%free%MB, %fs%, %label%, %serial%, %type%, %status%, Is this information correct for your removable device? If so Click yes to Eject Drive %list%: IfMsgBox No ExitApp else Driveletter = %list%: DrivePath = \\.\%Driveletter% hVolume := DllCall("CreateFile" , str, DrivePath , UInt, 0x80000000 | 0x40000000 ;GENERIC_READ | GENERIC_WRITE , UInt, 0x0 ;Tries to get exclusiv rights to the drive +++(see below) , UInt, Null , UInt, 0x3 ;OPEN_EXISTING , UInt, 0x0 , UInt, NULL) if A_LastError = 32 ;Another application has read or write-access to the drive (In this case no handle was retreived to release) { hVolume := DllCall("CreateFile" ;Get handle even if another application reads the drive , str, DrivePath , UInt, 0x80000000 | 0x40000000 ;GENERIC_READ | GENERIC_WRITE , UInt, 0x1 ;FILE_SHARE_READ , UInt, Null , UInt, 0x3 ;OPEN_EXISTING , UInt, 0x0 , UInt, NULL) if hVolume != -1 { msgbox, 4164, Warning, An application is accessing this device.`nEject it anyway? IfMsgbox, No { DllCall("CloseHandle", UInt, hVolume) ;Release handle here return } } if A_LastError = 32 ;No read access was possible also { msgbox, 4164, Warning!, Another application is writing to this device!`nEject it anyway? IfMsgbox, No return else { hVolume := DllCall("CreateFile" ;Get handle even if another application reads or writes to the drive , str, DrivePath , UInt, 0x80000000 | 0x40000000 ;GENERIC_READ | GENERIC_WRITE , UInt, 0x1 | 0x2 ;FILE_SHARE_READ | FILE_SHARE_WRITE , UInt, Null , UInt, 0x3 ;OPEN_EXISTING , UInt, 0x0 , UInt, NULL) } } } if hVolume != -1 ;Drive is Ejected { DllCall("DeviceIoControl" , UInt, hVolume , UInt, 0x2D4808 ;IOCTL_STORAGE_EJECT_MEDIA , UInt, NULL , UInt, 0 , UInt, NULL , UInt, 0 , UInt, &dwBytesReturned ;Not used , UInt, NULL) DllCall("CloseHandle", UInt, hVolume) } return
Now I also have other variables that are listed that can be used to ensure the drive you are ejecting is yours and I could also add the ability to search the drive for the PA menu, and if it is present then it will continue to run the script, this is just an outline, and if you wish to add on to it then feel free to. I think this would be great for the PA menu's eject feature and hopefully people take some interest into this.
You can get this script in exe form from here