ScriptUSER Posted April 12, 2007 Share Posted April 12, 2007 Does Any one tried this script ? It makes a Noise on My floopy drive ... the script works ... and supposed to trigger just a usb flash drive . $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecNotificationQuery _ ("Select * From __InstanceOperationEvent Within 5 Where " _ & "TargetInstance isa 'Win32_LogicalDisk'") While 1 $objEvent = $colEvents.NextEvent If $objEvent.TargetInstance.DriveType = 2 Then Select Case $objEvent.Path_.Class()="__InstanceCreationEvent" Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR) MsgBox(16, "drive", $objEvent.TargetInstance.DeviceId) ) Case $objEvent.Path_.Class()="" Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR) MsgBox(16, "drive", $objEvent.TargetInstance.DeviceId & " Removed " ) EndSelect EndIf WEnd Link to comment Share on other sites More sharing options...
BillLuvsU Posted April 12, 2007 Share Posted April 12, 2007 Is there a "help me" question in there? [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
ScriptUSER Posted April 12, 2007 Author Share Posted April 12, 2007 Is there a "help me" question in there?i tested this script on five computers , and stills makes noise on the floopy drive .my question is if any one experiencing the same and if there is a way to surpressthis problem ?thanks .... Link to comment Share on other sites More sharing options...
someone Posted April 12, 2007 Share Posted April 12, 2007 I might be waaay off but I'm guessing your trouble is $objEvent.TargetInstance.DriveType = 2 ... I'm guessing both the floppy drive and the USB drive are reported as removable or, 2. In fact using autoit's drivegettype on a usb drive and my floppy drive both return "removable". While not perfect can you get the drive letter and exclude them from your function if the letter is a: or b: for example? I don't know how to accomplish this off the top of my head but hopefully this sheds some light on things.... While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
ScriptUSER Posted April 12, 2007 Author Share Posted April 12, 2007 I might be waaay off but I'm guessing your trouble is $objEvent.TargetInstance.DriveType = 2 ... I'm guessing both the floppy drive and the USB drive are reported as removable or, 2. In fact using autoit's drivegettype on a usb drive and my floppy drive both return "removable". While not perfect can you get the drive letter and exclude them from your function if the letter is a: or b: for example? I don't know how to accomplish this off the top of my head but hopefully this sheds some light on things.... Yes, the floopy drive is Recognized as Removable and belongs to $objEvent.TargetInstance.DriveType = 2 There seems no way to pass by as autoit categorizes the floopy and Usb as same : for ex .. the following code gives usb hubs and floopy as removable ... $var = DriveGetDrive( "Removable " ) If NOT @error Then MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] MsgBox(4096,"Drive " & $i, $var[$i]) Next EndIf Still banging my head ! Link to comment Share on other sites More sharing options...
BrettF Posted April 12, 2007 Share Posted April 12, 2007 (edited) I'm not sure if this will work, but maybe adding a DriveGetFileSystem? I don't have a floppy to test on I'm afraid.... $var = DriveGetDrive( "Removable " ) If NOT @error Then MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] If Not DriveGetFileSystem ($var[$i]) = "FAT" Then MsgBox(4096,"Drive " & $i, $var[$i]) Next EndIf EDIT: OR GET THE SIZE OF IT? Edited April 12, 2007 by bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
SadBunny Posted April 12, 2007 Share Posted April 12, 2007 Don't have a 'floopy' drive to test on either, but the getsize is probably still going to make a sound since it must still access the 'floopy' I guess... And I can't help it, but I find 'floopy' an incredibly funny word! I need to keep that in my vocabulary... Sorry for the not-so-useful post, just had to thank you for a beautiful word. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
someone Posted April 13, 2007 Share Posted April 13, 2007 (edited) I guess I think the best method for weeding out the floppy drive would be to rely on drive letters... try this. While 1 Sleep(20) $var = DriveGetDrive( "REMOVABLE" ) For $i = 1 to $var[0] If $var[$i] <> "a:" Then MsgBox(4096,"Drive " & $i, $var[$i]) EndIf Next WEnd This isn't the best test because you'll get continuous msgboxes but it does the trick enough for you to get my point... when I run the script it does nothing until a removable drive is connected that isn't a:. It doesn't make any noise on my floppy drive either. PS: I didn't read bert's post/code enough but its basically the same as mine (sorry bert didn't mean to kinda step on your toes). Just use whatever method works best for you I guess. I lean a little towards using what I suggested - I know there was a time when I had my USB drive formatted in FAT because I was trying to get it to work as a bootable device. Let us know what you think. edit: bert is spelled with a lower case b... edit 2: ( I think its time for sleep...) Can't you just take the DriveGetWhatever out of the loop so it will only make noise once? Is that good enough? Edited April 13, 2007 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
ScriptUSER Posted April 14, 2007 Author Share Posted April 14, 2007 I guess I think the best method for weeding out the floppy drive would be to rely on drive letters... try this. While 1 Sleep(20) $var = DriveGetDrive( "REMOVABLE" ) For $i = 1 to $var[0] If $var[$i] <> "a:" Then MsgBox(4096,"Drive " & $i, $var[$i]) EndIf Next WEnd This isn't the best test because you'll get continuous msgboxes but it does the trick enough for you to get my point... when I run the script it does nothing until a removable drive is connected that isn't a:. It doesn't make any noise on my floppy drive either. PS: I didn't read bert's post/code enough but its basically the same as mine (sorry bert didn't mean to kinda step on your toes). Just use whatever method works best for you I guess. I lean a little towards using what I suggested - I know there was a time when I had my USB drive formatted in FAT because I was trying to get it to work as a bootable device. Let us know what you think. edit: bert is spelled with a lower case b... edit 2: ( I think its time for sleep...) Can't you just take the DriveGetWhatever out of the loop so it will only make noise once? Is that good enough? Someone ! you wrote ... " when I run the script it does nothing until a removable drive is connected that isn't a:. It doesn't make any noise on my floppy drive either " are you refering to the first script or your own modified script . I think the solution is : before select to eValuate : the following conditions fulfilled If $objEvent.TargetInstance.DriveType = 2 and $objEvent.TargetInstance.DeviceId <> "a" then If + and is not working in autoit . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now