Mast3rpyr0 Posted August 22, 2007 Share Posted August 22, 2007 (edited) Today at school I learned that we have an underground Quake tournament in the middle of the year and the game is being passed around on flash drives. Some kid was caught today trying to copy the files and had his drive taken away. So i made this program. The reason it works the way it does(copies files to computer when drive is plugged in and then once a new drive is plugged in it will copy the files to the new drive)is because my school limits the amount of removable/network drives per computer and 2 removable drives is not allowed. I really need people to test this with USB devices that are NOT u3 enabled. expandcollapse popup;; Set $howCopy to 1 to Select Certain Files from Source Drive ;; Set $howCopy to 2 to Select a Certain Dircetory from Source Drive ;; Set $howCopy to 3 to Copy the entire Source Drive. ;; To set $howCopy to a value, either change it in this script or for more secrecy save a txt file on the desktop ;; Called howCopy.txt with nothing more than the value of how you wish to copy files(See Above). If FileExists(@DesktopDir & "\howCopy.txt") Then $howCopy = FileRead(@DesktopDir & "\howCopy.txt", 1) Else $howCopy = 1 EndIf $xCopy = 1 ; Modified version of Ptrex's USB Monitoring Example $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" If $xCopy = 1 Then If $howCopy = 1 Then $xCopyFiles = FileOpenDialog("Select Files to Copy", $objEvent.TargetInstance.DeviceId, "All(*.*)", 5) FileCopy($xCopyFiles, @HomeDrive & "\TEMPUSB\", 8) ElseIf $howCopy = 2 Then $xCopyFiles = FileSelectFolder("Select Folder to Copy", $objEvent.TargetInstance.DeviceId, 2, $objEvent.TargetInstance.DeviceId) $folderName = _GetSelected($xCopyFiles) DirCopy($xCopyFiles, @HomeDrive & "\TEMPUSB") Else DirCopy($objEvent.TargetInstance.DeviceId, @HomeDrive & "\TEMPUSB") EndIf Else If $howCopy = 1 Then FileCopy(@HomeDrive & "\TEMPUSB\*.*", $objEvent.TargetInstance.DeviceId, 8) ElseIf $howCopy = 2 Then DirCopy(@HomeDrive & "\TEMPUSB\" & $folderName, $objEvent.TargetInstance.DeviceId) Else DirCopy(@HomeDrive & "\TEMPUSB", $objEvent.TargetInstance.DeviceId) EndIf FileDelete(@HomeDrive & "\TEMPUSB\*.*") Exit EndIf Case $objEvent.Path_.Class()="__InstanceDeletionEvent" $xCopy = 0 EndSelect EndIf WEnd ; End ; Written By MsCreatoR Func _GetSelected($String) Local $RetArr[1] If StringInStr($String, "|") Then Local $SplitArr = StringSplit($String, "|"), $InitPath = StringRegExpReplace($SplitArr[1], '([^\\])\\*$', '\1') For $i = 2 To UBound($SplitArr)-1 ReDim $RetArr[UBound($RetArr) + 1] $RetArr[UBound($RetArr) - 1] = $InitPath & "\" & $SplitArr[$i] Next $RetArr[0] = UBound($RetArr) - 1 Else Local $RetArr[2] = [1, $String] EndIf Return $RetArr EndFunc ; End Edited August 22, 2007 by Mast3rpyr0 My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 23, 2007 Author Share Posted August 23, 2007 It doesnt do anything bad... can i get at least 1 tester... just run the script, plug in your drive, choose a file, remove and put in a new drive(or delete the file from the flashdrive and plug it back in. Check C:\TEMPUSB for your file before deleting just incase it didnt work). My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
GreenHouse Posted August 23, 2007 Share Posted August 23, 2007 It doesnt do anything bad... can i get at least 1 tester... just run the script, plug in your drive, choose a file, remove and put in a new drive(or delete the file from the flashdrive and plug it back in. Check C:\TEMPUSB for your file before deleting just incase it didnt work).Ok, I can get it to pull up a copy dialog for me when I stick in my USB drive. Then it copies whatever I select to the TEMPUSB folder.However, when I delete the file from my USB drive and then remove it and re-insert it it doesn't copy the file from the tempusb dir to my USB drive.If you need to modify and need me to test again I will... Just let me know...GreenHouse Link to comment Share on other sites More sharing options...
slayerz Posted August 23, 2007 Share Posted August 23, 2007 hm..sound cool. I'll try it first, and let u know the result, later AUTOIT[sup] I'm lovin' it![/sup] Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 23, 2007 Author Share Posted August 23, 2007 (edited) Ok thanks guys. I think i know the problem GreenHouse. EDIT: does it exit after you plug it back in? New code: expandcollapse popup;; Set $howCopy to 1 to Select Certain Files from Source Drive ;; Set $howCopy to 2 to Select a Certain Dircetory from Source Drive ;; Set $howCopy to 3 to Copy the entire Source Drive. ;; To set $howCopy to a value, either change it in this script or for more secrecy save a txt file on the desktop ;; Called howCopy.txt with nothing more than the value of how you wish to copy files(See Above). If FileExists(@DesktopDir & "\howCopy.txt") Then $howCopy = FileRead(@DesktopDir & "\howCopy.txt", 1) Else $howCopy = 1 EndIf $xCopy = 1 ; Modified version of Ptrex's USB Monitoring Example $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" If $xCopy = 1 Then If $howCopy = 1 Then $xCopyFiles = FileOpenDialog("Select Files to Copy", $objEvent.TargetInstance.DeviceId, "All(*.*)", 5) FileCopy($xCopyFiles, @HomeDrive & "\TEMPUSB\", 8) ElseIf $howCopy = 2 Then $xCopyFiles = FileSelectFolder("Select Folder to Copy", $objEvent.TargetInstance.DeviceId, 2, $objEvent.TargetInstance.DeviceId) $folderName = _GetSelected($xCopyFiles) DirCopy($xCopyFiles, @HomeDrive & "\TEMPUSB") Else DirCopy($objEvent.TargetInstance.DeviceId, @HomeDrive & "\TEMPUSB") EndIf Else If $howCopy = 1 Then FileCopy(@HomeDrive & "\TEMPUSB\*.*", $objEvent.TargetInstance.DeviceId & "\", 8) ElseIf $howCopy = 2 Then DirCopy(@HomeDrive & "\TEMPUSB\" & $folderName, $objEvent.TargetInstance.DeviceId) Else DirCopy(@HomeDrive & "\TEMPUSB", $objEvent.TargetInstance.DeviceId) EndIf FileDelete(@HomeDrive & "\TEMPUSB\*.*") Sleep(1000) Exit EndIf Case $objEvent.Path_.Class()="__InstanceDeletionEvent" $xCopy = 0 EndSelect EndIf WEnd ; End ; Written By MsCreatoR Func _GetSelected($String) Local $RetArr[1] If StringInStr($String, "|") Then Local $SplitArr = StringSplit($String, "|"), $InitPath = StringRegExpReplace($SplitArr[1], '([^\\])\\*$', '\1') For $i = 2 To UBound($SplitArr)-1 ReDim $RetArr[UBound($RetArr) + 1] $RetArr[UBound($RetArr) - 1] = $InitPath & "\" & $SplitArr[$i] Next $RetArr[0] = UBound($RetArr) - 1 Else Local $RetArr[2] = [1, $String] EndIf Return $RetArr EndFunc ; End Edited August 23, 2007 by Mast3rpyr0 My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
GreenHouse Posted August 23, 2007 Share Posted August 23, 2007 (edited) Ok, it works like a champ... when you do a beta run... sorry I was running it as a go. Nice program! Would you be willing to help me understand why my script is calling a function and then when it gets done with it the original GUI can only be minimized. (I can only close it by stopping the script alltogether). Also I can't get it to close the main GUI OR run the function again it just sits there... I know this might be elementry but I am very new at programming and scripting. Thanks, - Pas expandcollapse popup#include <GUIConstants.au3> #include "WINXP.au3" #include "WIN2003.au3" #include "WIN2000.au3" Opt("GUIOnEventMode", 1) Global $mainwindow = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 522, 434, 235, 153) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUISetIcon("Allscripts.ico") GUISetFont(8, 400, 0, "Arial") Global $Group1 = GUICtrlCreateGroup(" SQL Backup ", 0, 0, 257, 217) GUICtrlSetFont(-1, 8, 800, 2, "Arial") Global $Label1 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart database:", 16, 24, 232, 36) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "ALabel1Click") Global $Button1 = GUICtrlCreateButton("Start", 88, 144, 75, 25, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "AButton1Click") GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Group2 = GUICtrlCreateGroup(" TouchChart Backup ", 0, 216, 257, 217) GUICtrlSetFont(-1, 8, 800, 2, "Arial") Global $Label2 = GUICtrlCreateLabel("Click start to create a backup of the TouchChart folder:", 16, 240, 224, 36) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "ALabel2Click") Global $Button2 = GUICtrlCreateButton("Start", 88, 360, 75, 25, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "AButton2Click") GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Group3 = GUICtrlCreateGroup(" Download Service Pack ", 264, 0, 257, 217) GUICtrlSetFont(-1, 8, 800, 2, "Arial") Global $Label3 = GUICtrlCreateLabel("Click start to download the service pack upgrade:", 280, 24, 224, 36) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "ALabel3Click") Global $Button3 = GUICtrlCreateButton("Start", 352, 144, 75, 25, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetOnEvent(-1, "Start3Button") GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Group4 = GUICtrlCreateGroup(" Run Service Pack Upgrade ", 264, 216, 257, 217) GUICtrlSetFont(-1, 8, 800, 2, "Arial") Global $Label4 = GUICtrlCreateLabel("Click start to run the service pack upgrade (No user input required):", 280, 240, 224, 36) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "ALabel4Click") Global $Button4 = GUICtrlCreateButton("Start", 352, 360, 75, 25, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;GUICtrlSetOnEvent(-1, "AButton4Click") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW, $mainwindow) $CloseDialog = GUICreate("Allscripts Healthcare Solutions SP Blaster V1.0", 350,80, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUISetIcon("Allscripts.ico") GUISetFont(8, 400, 0, "Arial") $OkButton = GUICtrlCreateButton("OK", 133, 40, 75, 25, 0) GUICtrlSetOnEvent(-1, "CDOkButton") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $EndTextCD = GUICtrlCreateLabel("Service pack has already been downloaded.", 82, 10, 232, 20) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUISetState(@SW_HIDE, $CloseDialog) While 1 Sleep(1000) ; Idle around WEnd Func Start3Button() ;Note: at this point @GUI_CTRLID would equal $okbutton If FileExists("ImpactMD 3.31 Service Pack 38 Install.exe") Then GUISetState(@SW_SHOW, $CloseDialog) GUISetState(@SW_SHOW, $mainwindow) Else ;find out the O/S Version and act accordingly $OSVersion = @OSVersion ClipPut($OSVersion) If $OSVersion = "WIN_VISTA" Then MsgBox(0, "Sorry...", "This program will not work on windows Vista... Ending program") Exit ; _VISTA () EndIf If $OSVersion = "WIN_2000" Then _WIN2000 () EndIf If $OSVersion = "WIN_XP" Then _WINXP () EndIf If $OSVersion = "WIN_2003" Then _WIN2003 () EndIf EndIf EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE Case @GUI_CTRLID = $GUI_EVENT_RESTORE EndSelect EndFunc func CDOkButton() GuiSetState(@SW_HIDE, $CloseDialog) GuiSetState(@SW_SHOW, $mainwindow) EndfuncoÝ÷ Ø ÝêÞËayû§rبV®¶sdgVæ2õtã#2 £²'VâWÆ÷&W# ¥6VÆÄWV7WFRgV÷C¶WÆ÷&RæWRgV÷C²ÂgV÷C¶gG¢òõtBUdU"U$RgV÷C² £µ6VÆV7B6fRfÆRg&öÒFR6V7W&Gv&æær&ö×C ¥våvD7FfRgV÷C´fÆRF÷væÆöBgV÷C²¥6VæBgV÷C·´ÅDDõtç×7´ÅEUÒgV÷C²¥våvBgV÷Cµ6fR2gV÷C²ÂgV÷Cµ6fR2f×·GS¢gV÷C² £µ6fRFòFW7F÷æBÖæÖ¦RvæF÷s ¥våvD7FfRgV÷Cµ6fR2gV÷C²ÂgV÷Cµ6fRf׶ã¢gV÷C²¤6öçG&öÅ6VæBgV÷Cµ6fR2gV÷C²ÂgV÷Cµ6fRf׶ã¢gV÷C²ÂgV÷C´6öÖ&ö&÷gV÷C²ÂFW6·F÷F"¥6VæBgV÷C·´ÅDDõtç×7´ÅEUÒgV÷C² £µvåvD7FfRgV÷C´×7DÔBgV÷C²ÂgV÷C´F÷væÆöBFó¢gV÷C²£µvå6WE7FFRgV÷C´×7DÔBgV÷C²ÂgV÷C´F÷væÆöBFó¢gV÷C²Â5uôTä$ÄR£µvå6WE7FFRgV÷C´×7DÔBgV÷C²ÂgV÷C´F÷væÆöBFó¢gV÷C²Â5uôÔäÔ¤R £µW6W267&BVçFÂFRF÷væÆöBvæF÷r26Æ÷6VC £µvåvD6Æ÷6RgV÷C´×7DÔBgV÷C²ÂgV÷C´F÷væÆöBFó¢gV÷C² ¤VæDgVæ0 Thanks a bunch mate. Edited August 23, 2007 by GreenHouse Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 23, 2007 Author Share Posted August 23, 2007 well you dont do anythign in the while loop, I usually have a switch in there. try this: While 1 $gMsg = GUIGetMsg() Switch $gMsg Case $GUI_EVENT_CLOSE Exit EndSwitch Wend My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! 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