自动运行在 Windows 中被禁用。我正在寻找替代方案。我得到了这个 AutoIt 脚本:
$DBT_DEVICEARRIVAL = "0x00008000"
$WM_DEVICECHANGE = 0x0219
GUICreate("")
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")
Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
If $WParam == $DBT_DEVICEARRIVAL Then
MsgBox(4096, "Info", "My Drive has been Inserted, Backup My Files!")
EndIf
EndFunc
While 1
$GuiMsg = GUIGetMsg()
WEnd
刚插上电源,就出现了消息框。现在,运行我替换的文件
MsgBox(4096, "Info", "My Drive has been Inserted, Backup My Files!")
by
Run ("F:\path\to\my\file.cmd")
但要改变什么file.cmd
可以在指定不同驱动器号的计算机上运行F:
?
我使用以下代码在可移动设备(SD 卡)上搜索了一些 WAVE 文件:
#include <Array.au3>
; Register search function
Global $DBT_DEVICEARRIVAL = "0x00008000"
Global $WM_DEVICECHANGE = 0x0219
Global $drives = DriveGetDrive("REMOVABLE")
GUIRegisterMsg($WM_DEVICECHANGE, "searchOnSD")
; check all already known removable devices
If UBound($drives) > 0 Then
For $drive In $drives
If StringRegExp($drive, "^[[:alpha:]]:$") Then check($drive)
Next
EndIf
; search for WAV-file on SD-Card
Func searchOnSD($hWndGUI, $MsgID, $WParam, $LParam)
If $WParam == $DBT_DEVICEARRIVAL Then
$newDrives = DriveGetDrive("REMOVABLE")
$drive = $newDrives
For $i = 0 To UBound($drives) - 2
_ArrayDelete($drive, 0)
Next
If UBound($drive) > 0 Then
$drive = $drive[0]
If StringRegExp($drive, "^[[:alpha:]]:$") Then
ConsoleWrite("new removable (" & $drive & ") found." & @CR)
check($drive)
EndIf
EndIf
EndIf
$drives = DriveGetDrive("REMOVABLE")
EndFunc ;==>searchOnSD
In the check($drive)
然后我在评估后对 WAVE 文件执行了一些操作DriveStatus($drive) == "READY" And FileExists($wavFile)
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)