Jump to content

Does any have tried this ....


Recommended Posts

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 by bert
Link to post
Share on other sites

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! :shocked: 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 post
Share on other sites

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 by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to post
Share on other sites

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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...