How to run a macro when someone connects a USB stick to PC ?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
reimon9
Newbie
Posts: 14
Joined: Mon Oct 01, 2007 9:15 pm

How to run a macro when someone connects a USB stick to PC ?

Post by reimon9 » Wed Sep 01, 2010 2:48 pm

Please, how to run a macro when someone connects a USB stick to PC ?

Greetings,

Reimon.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Sep 01, 2010 3:40 pm

Try This:

Code: Select all

VBSTART
Function CountUSBDrive()
  on error resume next
  Dim USBCount
  USBCount = 0
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set oDrive = fso.Drives

  For Each curDrive In oDrive
    if curDrive.DriveType = 1 Then
	   USBCount = USBCount + 1
    End if
  Next
  CountUSBDrive = USBCount
End Function
VBEND

VBEval>CountUSBDrive,OldUSBCount

Label>CheckAgain
VBEval>CountUSBDrive,USBCount
//MessageModal>USBCount
If>USBCount>OldUSBCount
   MessageModal>New Drive Detected
   //A new removable drive has been detected
   //Do more code here
Else
   Wait>0.01
   Goto>CheckAgain
Endif


idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Fri Sep 03, 2010 2:37 am

or you could have it detect when the bubble pops up using getpixel or image recognition that the new drive is plugged in his way is already coded thopugh
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts