Sign in to follow this  
Followers 0
FMS

Radio button issue

6 posts in this topic

#1 ·  Posted (edited)

Dear reader,

At this point i m making a GUI whish moves file automaticly but it's a little glitshy and i don't know why.

If i just run the script on his own it works but when i put it in a GUI it stalls.

at this point is written to move around .txt .exe or .pdf files from location1 to location 2.

can somebody tell me why this script isn't working?

there are no known errors that autoit tells me :S

plz help

thnx in advanced

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form = GUICreate("ext grabber", 367, 234, 192, 114)

$Group1 = GUICtrlCreateGroup("Locations", 8, 8, 337, 89)
GUICtrlCreateGroup("wwww", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("original location :", 24, 32, 83, 17)
$Label2 = GUICtrlCreateLabel("Destenation :", 24, 56, 67, 17)
$location1 = GUICtrlCreateInput("C:TEST", 112, 32, 225, 21)
$Rwildinput = GUICtrlCreateInput("pdf", 208, 128, 129, 21)
$location2 = GUICtrlCreateInput("C:TEST2", 112, 56, 225, 21)

$Group2 = GUICtrlCreateGroup("Ext", 8, 104, 337, 65)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Rexe = GUICtrlCreateRadio("exe", 16, 128, 57, 17)
$Rtxt = GUICtrlCreateRadio("txt", 72, 128, 49, 17)
$Rpdf = GUICtrlCreateRadio("pdf", 128, 128, 57, 17)
$Rwild = GUICtrlCreateRadio("", 184, 128, 17, 17)

GUISetState(@SW_SHOW)

$Bcancel = GUICtrlCreateButton("Cancel", 8, 184, 75, 25, $WS_GROUP)
$Bstop= GUICtrlCreateButton("Stop", 140, 184, 75, 25, $WS_GROUP)
$Brun = GUICtrlCreateButton("Run", 272, 184, 75, 25, $WS_GROUP)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Brun
            If GUICtrlRead($Rexe) = $GUI_CHECKED Then
                $Sexe = FileFindFirstFile(GUICtrlRead($location1) & "*.exe")
                If $Sexe = -1 Then
                    sleep(5000)
                Else
                    $file = FileFindNextFile($Sexe)
                    filemove(GUICtrlRead($location1) & $file,GUICtrlRead($location2),8)
                    Sleep(2500)
                EndIf
            ElseIf GUICtrlRead($Rtxt) = $GUI_CHECKED Then
                $Stxt = FileFindFirstFile(GUICtrlRead($location1) & "*.txt")
                If $Stxt = -1 Then
                    sleep(5000)
                Else
                    $file = FileFindNextFile($Stxt)
                    filemove(GUICtrlRead($location1) & $file,GUICtrlRead($location2),8)
                    Sleep(2500)
                EndIf
            ElseIf GUICtrlRead($Rpdf) = $GUI_CHECKED Then
                $Spdf = FileFindFirstFile(GUICtrlRead($location1) & "*.pdf")
                If $Spdf = -1 Then
                    sleep(5000)
                Else
                    $file = FileFindNextFile($Spdf)
                    filemove(GUICtrlRead($location1) & $file,GUICtrlRead($location2),8)
                    Sleep(2500)
                EndIf
            ElseIf GUICtrlRead($Rwild) = $GUI_CHECKED Then
                $Swild = FileFindFirstFile(GUICtrlRead($location1) & "*."& (GUICtrlRead($Rwildinput)))
                If $Swild = -1 Then
                    sleep(5000)
                Else
                    $file = FileFindNextFile($Swild)
                    filemove(GUICtrlRead($location1) & $file,GUICtrlRead($location2),8)
                    Sleep(2500)
                EndIf
            Else
                MsgBox(4096, "Error", "There is no raio button chekked", 10)
                Sleep(2500)
            EndIf

        Case $Bcancel
            exit
    EndSwitch
WEnd
Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites



FMS,

You are missing a "" in the filepath. ;)

And there are a couple of other problems - you do not loop through the files and you do not close the file search handle. Try making the Switch structure look like this (I have just shown the "Wild" section):

ElseIf GUICtrlRead($Rwild) = $GUI_CHECKED Then
    $Swild = FileFindFirstFile(GUICtrlRead($location1) & "*." & (GUICtrlRead($Rwildinput)))
    If $Swild = -1 Then
        Sleep(5000)
    Else
        While 1 ; <<<<<<<<<<<<<<< Loop through the files
            $file = FileFindNextFile($Swild)
            If @error = 1 Then ; <<<<<<<<<<<<< When all files found
                ExitLoop
            EndIf
            FileMove(GUICtrlRead($location1) & "" & $file, GUICtrlRead($location2), 8) ; <<<<<<<<<<<< Add a ""
            Sleep(2500)
        WEnd
        FileClose($Swild) ; <<<<<<<<<<<<<<<< Close the search handle
    EndIf

Please ask if you have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thnx Melba,

It works like a charm :thumbsup:

Stupid of me that i din't see that i must add a "/"

I also learned a little bit more in looping treu files.

But on the closing handle isseu was on perpose because i wanted to close them whit the "stop" button.

The reason for this is because i wanted to let the computer keep on searching for that file on loaction1 till pushed stop in the GUI.

I thaught to closing the handel when pushed "stop". Or do you know a better way or have a better idea? :>

Afther takeling this isseu i was hoping to make multiple searches and stop them when selecting the searches in a listvieuw where the searches are comming in when created that i'm making at the moment in the GUI.

does this make any sense :ermm:


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

FMS,

I would do it this way:

; Set a Global flag at the beginning of your script
Global $fContinue = True

; And then in the Switch

ElseIf GUICtrlRead($Rwild) = $GUI_CHECKED Then
    $Swild = FileFindFirstFile(GUICtrlRead($location1) & "*." & (GUICtrlRead($Rwildinput)))
    If $Swild = -1 Then
        Sleep(5000)
    Else
        While 1
            $file = FileFindNextFile($Swild)
            If @error = 1 Then
                ExitLoop
            EndIf
            FileMove(GUICtrlRead($location1) & "" & $file, GUICtrlRead($location2), 8)

            ; Replace the Sleep with this code to look for the "Stop" button
            $iBegin = TimerInit()
            Do
                If GUIGetMsg() = $Bstop Then
                    $fContinue = False ; Clear flag
                    ExitLoop
                EndIf
            Until TimerDiff($iBegin) > 2500

            ; Now interrupt the loop if the "Stop" button was pressed
            If $fContinue = False Then ; Check if flag cleared
                $fContinue = True ; Reset flag
                ExitLoop
            EndIf
        WEnd
        FileClose($Swild)
    EndIf

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

:rolleyes: yesssssss you made it very clear for me...

thnx for that:)

now i can puzzle all weekend on how to made a list view on the running searches :lmao:

greetings a very greatfull FMS


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

FMS,

now i can puzzle all weekend on how to made a list view on the running searches

Well, you know where we are if you need a hint. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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