FMS Posted August 17, 2012 Share Posted August 17, 2012 (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 expandcollapse popup#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 August 17, 2012 by FMS as finishing touch god created the dutch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 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 EndIfPlease 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FMS Posted August 17, 2012 Author Share Posted August 17, 2012 Thnx Melba, It works like a charm 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 as finishing touch god created the dutch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FMS Posted August 17, 2012 Author Share Posted August 17, 2012 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 greetings a very greatfull FMS as finishing touch god created the dutch Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 FMS,now i can puzzle all weekend on how to made a list view on the running searchesWell, 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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