是否可以使AutoHotKey在(成功)卸载USB设备时显示消息?

时间:2016-02-26 01:43:23

标签: windows cmd autohotkey

所以,我正在使用AutoHotKey使用here中的脚本安全地删除我的USB设备。与单击任务栏中的项目相比,唯一的缺点是后者显示一条消息,或者像“你现在可以安全地删除你的设备”或“你的设备正忙,现在无法弹出”,而AHK脚本确实如此不

问题是:在通过AHK弹出时是否可能/如何显示此类消息?或者,分解任务,如何a)检查驱动器是否已成功卸载并且b)显示相应的消息?

(我知道,在帖子1中提问是合适的,但我在那里注册有问题,有些过滤器不允许使用我的邮件/ IP注册,不记得确切)

1 个答案:

答案 0 :(得分:2)

在帖子中说:

<强>的ErrorLevel
-1无效的驱动器号 -2既不是CD / DVD驱动器,也不是USB大容量存储设备 -3弹出失败。将A_LastError(范围1 - 13)引用到identify the reason。最常见的是A_LastError = 6,即为 PNP_VetoOutstandingOpen 请求的操作因未完成的打开句柄而被拒绝。

所以我想说,这应该做的工作:

USB_ERROR_LIST := [ "The specified operation was rejected for an unknown reason."
                  , "The device does not support the specified PnP operation."
                  , "The specified operation cannot be completed because of a pending close operation."
                  , "A Microsoft Win32 application vetoed the specified operation."
                  , "A Win32 service vetoed the specified operation."
                  , "The requested operation was rejected because of outstanding open handles."
                  , "The device supports the specified operation, but the device rejected the operation."
                  , "The driver supports the specified operation, but the driver rejected the operation."
                  , "The device does not support the specified operation."
                  , "There is insufficient power to perform the requested operation."
                  , "The device cannot be disabled."
                  , "The driver does not support the specified PnP operation."
                  , "The caller has insufficient privileges to complete the operation." ]

#vk4A::
    Eject( "D:" )
    If (ErrorLevel = -1)
        MsgBox, Invalid drive letter.
    Else If (ErrorLevel = -2)
        MsgBox, Neither a CD/DVD drive, nor a USB Mass Storage device.
    Else If (ErrorLevel = -3) {
        MsgBox, % "Eject failed:`n" USB_ERROR_LIST[A_LastError]
    } Else {
        MsgBox, The USB device can now be safely removed from the computer.
    }
Return