Sign in to follow this  
Followers 0
copyleft

Finding specific removable drives

17 posts in this topic

I know the DriveGetDrive command can be used to identify removable drives, but how can I find the drive letter of a removable drive that contains a specific file, for file copying purposes?

Share this post


Link to post
Share on other sites



There is no other way, you've to search into the drive, either using _FileListToArray or using Melba's UDF or AZJIO's UDF or the others.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

copyleft,

If the device is READY use fileexists('myfile') for each REMOVABLE device.

kylomas

edit: a small example...

local $aDRV = DriveGetDrive('REMOVABLE')
for $1 = 0 to ubound($aDRV) - 1
    if DriveStatus($aDRV[$1]) = 'READY' then
        if fileexists($aDRV[$1] & '\test.txt') then
            ConsoleWrite('File found on Drive = ' & $aDRV[$1] & @LF)
            Exit
        EndIf
    endif
next
Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

or just run the filecopy command.  If it returns 1, that drive had the file


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Thank you all for your input. I'm testing kyloma's suggestion but I'm not getting any output. I've got a batch file that can do this but just can't figure out how to do it with AutoIt.

Share this post


Link to post
Share on other sites

How do you do it in the batch file?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The batch file would be:

@echo off
FOR %%d IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%d:\TESTFILE.TXT SET CFDrv=%%d:
del %CFDrv%\TESTFILE.TXT
Edited by copyleft

Share this post


Link to post
Share on other sites

#include <MsgBoxConstants.au3>

Local $sDrive = ''
For $i = 65 To 90
    $sDrive = Chr($i) & ':'
    If FileExists($sDrive & '\TEST.txt') Then
        ExitLoop ; Exit loop if file is found.
    EndIf
    $sDrive = '' ; Reset to blank string.
Next

If $sDrive Then
    MsgBox($MB_SYSTEMMODAL, '', $sDrive)
EndIf


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Or the batch file directly translated.

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Local $sDrive = ''
For $i = 67 To 90
    $sDrive = Chr($i) & ':'
    If FileExists($sDrive & '\TESTFILE.txt') Then
        EnvSet('CFDrv', $sDrive) ; Set environment variable CFDrv.
        ExitLoop ; Exit loop if file is found.
    EndIf
    $sDrive = '' ; Reset to blank string.
Next

MsgBox($MB_SYSTEMMODAL, '', _WinAPI_ExpandEnvironmentStrings('%CFDrv%\TESTFILE.txt'))

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

This is another way. A drive has a label that may be set.

; script on removable drive
$sScriptDrive = StringLeft(@ScriptDir, 2)
MsgBox(0, @ScriptName, $sScriptDrive)

; or search drives
Global $myDrive
Global $aDrives = DriveGetDrive('ALL')
If IsArray($aDrives) Then
    For $sDrive In $aDrives
        If DriveStatus($sDrive) = 'READY' Then
            ; filter out drive types not wanted
            Switch DriveGetType($sDrive)
                Case 'Network', 'CDROM', 'RAMDISK'
                    ContinueLoop
            EndSwitch
            ; check drive label
            If DriveGetLabel($sDrive) = 'MyLabelHere' Then
                ; set myDrive to chosen drive letter
                $myDrive = $sDrive
                ; copy the file
                If Not FileCopy($sDrive & '\testfile.txt', @TempDir & '\') Then
                    MsgBox(0x30, @ScriptName, 'Failed to copy ' & $sDrive & '\testfile.txt')
                EndIf
                ExitLoop
            EndIf
        EndIf
    Next
EndIf

MsgBox(0, @ScriptName, $myDrive)

The 1st couple of lines is if your script is on the drive of interest. My removable HDDs are recognized as FIXED so REMOVABLE is not a good option for me. Memory sticksflash drives can be seen as REMOVABLE. That is why I chose ALL and filter by type.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

so you are only detecting them to then delete them?

my recommendation is the same, just loop through filedelete for all potential drives. it will either work or provide an ignored return.  and you get away with 4 lines, something like.

Global $Adrives[...]
for $i = 0 to ubound($Adrives) - 1
filedelete($Adrives[$i] & "\testfile.txt")
next
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Many thanks MHz., you are exactly on my frequency! Drive label search is much simpler than looking for a file and seems faster to execute.  :sorcerer:

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

@Mhz. I'm finding your script potentially very useful for some other things I want to do. I don't know if this should be in the GUI forum or not but I have another question: I want to build a GUI menu around the copy file function so a user could decide which file or files to automatically delete on a removable drive. Could I just save your script AS "removabledrive.au3" in the Autoit "Include" folder to execute the find-the-removable-drive command and then just create commands for the radio buttons to copy files, like this:

#include <removabledrive.au3>
; GUI CODE
; THEN RADIO BUTTON COMMAND
If GUICtrlRead($iRadio_1) = $GUI_CHECKED Then
EndIf
If Not FileCopy($sDrive & '\Dir\laptop\pid.txt', $sDrive & '\sources') Then
FileCopy($sDrive & '\Dir\laptop\Autounattend.xml', $sDrive & '\')
ElseIf GUICtrlRead($iRadio_2) = $GUI_CHECKED Then

 

Edited by copyleft

Share this post


Link to post
Share on other sites

You could use the code in an include file but then you have Global code in a include file to maintain with the variables also being Global. A more preferred idea is to create a User Defined Function that uses Local variables so that the code is self contained and private. Thus, the only Global variable of interest is what stores the return value.

This UDF uses a whitelist of drive types rather then a blacklist. A whitelist seemed more suitable when I created it. By default, just using the parameter alone will find a drive with that label. The 2nd optional parameter sets the whitelist of drive types to allow which is all drives as default. The 3rd optional parameter sets label (default), file or folder as the find option. Sets 4 @error values if something fails.

Here you go

#region Parameters
; $sName is the drive label string unless $sOption is 'FILE' or 'FOLDER' in
; which $sName is a path relative to the root of the found drive. 'FILE'
; and 'FOLDER' are both tested as being 'FILE'.
; i.e. $sName can be 'Windows\System32' when $sOption is 'FILE' or 'FOLDER'.
;
; $sTypes  is an optional parameter and can be any of types that DriveGetLabel
; type 1 supports including 'ALL'. Multiple types are delimited by |.
; i.e. 'ALL' or 'REMOVABLE|FIXED' or 'CDROM' etc.
;
; $sOption is an optional parameter and is 'LABEL', 'FILE' or 'FOLDER'.
; 'LABEL' is default if the parameter is not used in the function call.
#endregion

#region Return Value
; Success: String containing drive letter followed by colon.
; Failure: '' and set @error
;          1 No drives found to match parameters. @extended drive count
;          2 $sTypes empty string
;          3 $sName empty string
;          4 $sOption not valid
#endregion

#region Example
; look in all drives for a drive with the label of 'system'
$sDrive = _DriveFindDrive('system')
MsgBox(0, 'system, ALL, LABEL', $sDrive)
;
; look in removable and fixed drives for a drive with a file named 'Dir\laptop\Autounattend.xml'
$sDrive = _DriveFindDrive('Dir\laptop\Autounattend.xml', 'REMOVABLE|FIXED', 'FILE')
MsgBox(0, 'Dir\laptop\Autounattend.xml, REMOVABLE|FIXED, FILE', $sDrive)
;
; look in removable and fixed drives for a drive with a folder named 'Dir\laptop'
$sDrive = _DriveFindDrive('Dir\laptop', 'REMOVABLE|FIXED', 'FOLDER')
MsgBox(0, 'Dir\laptop, REMOVABLE|FIXED, FOLDER', $sDrive)
#endregion

Func _DriveFindDrive($sName, $sTypes = 'ALL', $sOption = 'LABEL')
    Local $aDrives, $bDriveOK, $sDrive, $sType
    ; validate parameters
    If $sTypes == '' Then Return SetError(2, 0, '')
    If $sName == '' Then Return SetError(3, 0, '')
    If $sOption <> 'LABEL' And $sOption <> 'FILE' And $sOption <> 'FOLDER' Then Return SetError(4, 0, '')
    If $sOption = 'FOLDER' Then $sOption = 'FILE'
    ; search drives
    $aDrives = DriveGetDrive('ALL')
    If IsArray($aDrives) Then
        For $sDrive In $aDrives
            ; filter out drive types not wanted by using a whitelist
            If $sTypes <> 'ALL' Then
                For $sType In StringSplit($sTypes, '|', 2); no count
                    If DriveGetType($sDrive) <> $sType Then ContinueLoop
                    $bDriveOK = True
                    ExitLoop
                Next
                If Not $bDriveOK Then ContinueLoop
                $bDriveOK = False
            EndIf
            ;
            If DriveStatus($sDrive) = 'READY' Then
                ; check drive label
                If $sOption = 'LABEL' And DriveGetLabel($sDrive) = $sName Then
                    Return $sDrive
                ; check if file exists
                ElseIf $sOption = 'FILE' And FileExists($sDrive & '\' & $sName) Then
                    Return $sDrive
                EndIf
            EndIf
        Next
    EndIf
    ; failed to find drive. Return '', @error 1 and @extended number of drives
    Return SetError(1, UBound($aDrives), '')
EndFunc

So your example could be like this

#include <removabledrive.au3>
; GUI CODE
; THEN RADIO BUTTON COMMAND

If GUICtrlRead($iRadio_1) = $GUI_CHECKED Then
    ; ...
EndIf

$sDrive = _DriveFindDrive('Dir\laptop\Autounattend.xml', 'REMOVABLE|FIXED', 'FILE')
If Not FileCopy($sDrive & '\Dir\laptop\pid.txt', $sDrive & '\sources') Then
    FileCopy($sDrive & '\Dir\laptop\Autounattend.xml', $sDrive & '\')
ElseIf GUICtrlRead($iRadio_2) = $GUI_CHECKED Then
    ; ...

:)

Share this post


Link to post
Share on other sites

Thanks so much for your help. But now, I'm lost again.

I cribbed a radio button GUI example from the help file, as a template.

I want to have each radio button select a file copy function and then have the "install" button execute the selected choice. Does your code go in the places indicate, below? I'm getting errors in the script checker.

#include <GUIConstantsEx.au3>
Example()
Func Example()
    Local $button_1, $radio_1, $radio_2
    Local $radioval1, $msg
    Opt("GUICoordMode", 1)
    GUICreate("Select File Copy Setup", 400, 280)
    ; GUI controls
    $button_1 = GUICtrlCreateButton("Install", 30, 20, 120, 40)
    GUICtrlCreateGroup("Setups", 30, 90, 340, 160)
    GUIStartGroup()
    $radio_1 = GUICtrlCreateRadio("File Copy &0", 50, 120, 90, 20)
    $radio_2 = GUICtrlCreateRadio("File Copy &1", 50, 150, 90, 20)
    ; Set default radio button
    GUICtrlSetState($radio_1, $GUI_CHECKED)
    GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)
    $radioval1 = 0
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $button_1
                Exit
            ;GUIDelete($Form1)
            Exit
            ; Execute Radio Button one command
        Case $msg = $radio_1
        ; DOES FILE COPY COMMAND GO HERE FOR BUTTON ONE?
            Exit
           ; Execute Radio Button two command
            Case $msg = $radio_2
           ; DOES FILE COPY COMMAND GO HERE FOR BUTTON ONE?
            Exit
        EndSelect
    WEnd
EndFunc

Thanks again.

Share this post


Link to post
Share on other sites

Read the radio ctrls for being checked when the button is clicked.

#include <GUIConstantsEx.au3>
;~ #include <removabledrive.au3>

$sDrive = _DriveFindDrive('system')
Example()

Func Example()
    Local $button_1, $radio_1, $radio_2
    Local $radioval1, $msg
    Opt("GUICoordMode", 1)
    GUICreate("Select File Copy Setup", 400, 280)
    ; GUI controls
    $button_1 = GUICtrlCreateButton("Install", 30, 20, 120, 40)
    GUICtrlCreateGroup("Setups", 30, 90, 340, 160)
    GUIStartGroup()
    $radio_1 = GUICtrlCreateRadio("File Copy &0", 50, 120, 90, 20)
    $radio_2 = GUICtrlCreateRadio("File Copy &1", 50, 150, 90, 20)
    ; Set default radio button
    GUICtrlSetState($radio_1, $GUI_CHECKED)
    GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)
    $radioval1 = 0
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $button_1
                If GUICtrlRead($radio_1) = $GUI_CHECKED Then
                    MsgBox(0, 'File Copy 0 Here', 'FileCopy("' & $sDrive & '\some\file.txt", "c:\here\")')
                ElseIf GUICtrlRead($radio_2) = $GUI_CHECKED Then
                    MsgBox(0, 'File Copy 1 Here', 'FileCopy("' & $sDrive & '\some\file.txt", "c:\there\")')
                Else
                    ContinueLoop
                EndIf
        EndSelect
    WEnd
EndFunc

There are a number of options you can do to design your GUI so I would not know what you are planning. Think about how the GUI is going to operate and once you know that then you can do that. Doing a file copy on a click of a radio button is not a usual concept. You may even want to put drive select in a combo box ctrl. It is all in fun. :)

Share this post


Link to post
Share on other sites

Thanks so much.

I probably wasn't clear: I didn't like the execute-on-radio-button-choice code either. But I didn't know how to change it from the example and make the select button execute the command after the radio button is chosen.

In any even, I'll give your code a try.

Share this post


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
Sign in to follow this  
Followers 0