MarioFernando Posted March 24, 2009 Share Posted March 24, 2009 I got hold of AutoIT v3 very recently and im using it very much. I stuck in a script where i want to copy a picture to all the hard drives and to the USB devices when they are connected. For this purpose i used the "DrivegetDrive". But becuse there is no floppy disk inserted into the floppy drive the script gives an error informing that to insert a drive tothe floppy disk drive continuesly. giving options of "retry", "cancel". So please helpin this so that i can select only removable drives and hard drives to copy the picture.(Excluding CDROMS and Floppy disks). If you hav a solution reply here or email meat mario_thilanga"yahoo.com Link to comment Share on other sites More sharing options...
KaFu Posted March 24, 2009 Share Posted March 24, 2009 To prevent this, check if a media is present in the drive... if DriveStatus('a:\') = 'READY' Then ;.... media present Else ;.... NO media present endif OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
MarioFernando Posted March 25, 2009 Author Share Posted March 25, 2009 Hey KaFu; Yhanx man for that reply. I tryed it out and it works fine. I hav one more question is there a way to include to that script if there is an error to perform the next instruction of the script.coz my script doesnt perorm the next instruction when it meets the error. but stays stuck on that specific erorr trying to oerform the same instruction again and again.... I'm hoping that you or anyone else will answr this. Thank you very much ones agin for thta perfect answer. you rule man!!!!! coz i was stuck on that script for months. now i can cmplrtr it for good. Link to comment Share on other sites More sharing options...
KaFu Posted March 26, 2009 Share Posted March 26, 2009 (edited) Something like this should do the trick. $var = DriveGetDrive( "all" ) If NOT @error Then ;MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] ;MsgBox(4096,"Drive " & $i, $var[$i]) if DriveGetType($var[$i] & '\') = 'Removable' OR DriveGetType($var[$i] & '\') = 'Fixed' OR DriveGetType($var[$i] & '\') = 'Network' Then if DriveStatus($var[$i] & '\') = 'READY' Then ConsoleWrite($var[$i] & '\' & @crlf) ; FileCopy ( "source", "dest" [, flag] ) endif EndIf Next EndIf If that doesn't fit your purpose, you'll have to provide some sample code ... Edited March 26, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
MarioFernando Posted March 28, 2009 Author Share Posted March 28, 2009 (edited) Hey Kafu the reply you kept again didnt work also. i modified my earlier script which was this: Do $drive = DriveGetDrive( "All" ) For $from = 1 to $drive[0] If FileExists ($drive[$from]&"\"&"My Picture.bmp") Then sleep (1000) Else FileCopy ("C:\Pictures\My Picture.bmp",$drive[$from]&"\") EndIf Next Until WinActive ("Stop") To this with your help: $drive = DriveGetDrive( "All" ) If NOT @error Then For $from = 1 to $drive[0] If DriveGetType($drive[$from] & '\') = 'Removable' OR DriveGetType($drive[$from] & '\') = 'Fixed' OR DriveGetType($drive[$from] & '\') = 'Network' Then If DriveStatus($drive[$from] & '\') = 'READY' Then If FileExists ($drive[$from]&"\"&"My Picture.bmp") Then sleep (1000) Else FileCopy ("C:\Pictures\My Picture.bmp",$drive[$from]&"\") EndIf EndIf EndIf Next EndIf Until WinActive ("Stop") But still it does not work please help i am in a desperate situation.!!!! IT stillgives the same error as "AUTOIT3-PIcture.exe - No disk" givig options of REtry Cancelo and Continue Edited March 28, 2009 by MarioFernando Link to comment Share on other sites More sharing options...
KaFu Posted March 28, 2009 Share Posted March 28, 2009 $drive = DriveGetDrive("All") If Not @error Then For $from = 1 To $drive[0] If DriveGetType($drive[$from] & '\') = 'Removable' Or DriveGetType($drive[$from] & '\') = 'Fixed' Or DriveGetType($drive[$from] & '\') = 'Network' Then If DriveStatus($drive[$from] & '\') = 'READY' Then If Not FileExists($drive[$from] & "\" & "My Picture.bmp") Then FileCopy("C:\Pictures\My Picture.bmp", $drive[$from] & "\") ConsoleWrite($drive[$from] & "\" & "My Picture.bmp" & @crlf) EndIf EndIf EndIf Next EndIf works fine for me... otherwise you'll have to provide more code (WinActive ("Stop")?), maybe the bug's not in this part... you may pm me... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
MarioFernando Posted March 31, 2009 Author Share Posted March 31, 2009 i thnk i solved it but not in the correct way i jst changed the "$from=1 to $drive[0]" to "$from=2 to $drive[0]" then always the floppy drives are excluded.but the thing is it excludes the C: drive also in a computer where their is no floppy drive.but i added a seperate script to copy the picture to C:.Anyway thanx for your utmost support. hey do you know the way to attach a file to the email which is sent bt "InetEamil" command. And the "Until WinActive ("Stop") was that i have a folder named as "stop" so when i open it the script should exit: thank you. please leave a reply: 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