思路就是通过监测设备变化WM_DEVICECHANGE(0x219)来监测驱动器的变化,来实现监测USB的插拔。
#Persistent
OnMessage(0x219, "notify_change")
notify_change(wParam, lParam, msg, hwnd)
{
SetTimer,checkDrive,2000
}
return
checkdrive:
i=0
allDrives:=""
DriveGet, A, List,
StringSplit,D, A,
loop,%d0%
{
DRV:= % d%a_index% . ":\"
i++
DriveGet , type1 , type , %DRV% ;- removable / fixed
DriveGet , cap1 , capacity , %DRV%
DriveSpaceFree , free1 , %DRV%
DriveGet , fs1 , fs , %DRV% ;- FAT
DriveGet , label1 , label , %DRV% ;- volume label >\\server1
DriveGet , serial1 , serial , %DRV% ;- volume serial number
DriveGet , status1 , status , %DRV%
allDrives .= drv . " " . type1 . " " . free1 . "-MB`n"
}
VT:=D0 ;- totalDrives
last = %drv%
DriveGet , serial2 , serial , %last% ;- volume serial number
if (serial2="3772709444")
{
SetTimer,checkDrive,off
try
Run,charmap
}
else
{
SetTimer,checkDrive,off
Run,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
MsgBox, 262208,Info ,AllDrives=`n%allDrives%`n
}
return
esc::ExitApp
;================================================================================
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
正在学习大佬教程