motormad Posted September 8, 2010 Share Posted September 8, 2010 Hello, I'm new at this . But i want to learn fast so if you ppl can spare a minute for me ... thanx a lot I want to make a form for copy a lot of files. This because i got to do this 1 a day and its boring. i made a form that count the xls files. But i like to get the amount of files in the label. Then i like to count again if the OK button is klikt and the label got to be updated. Whats the best/fastesd way of doing this? Thanx in advance expandcollapse popup#include<Date.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> dim $count dim $DaAatUm $DaAatUm = _NowDate() $count = 0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("COPY_FILES", 633, 447) $CODE1 = GUICtrlCreateInput("UT", 80, 56, 50, 21) $Label1 = GUICtrlCreateLabel("AANTAL FILES:" & $count, 70,100, 100, 17) $Progress1 = GUICtrlCreateProgress(40, 130, 100, 10) $OKButton = GUICtrlCreateButton("GO", 424, 205, 97, 30, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("*ISO_*.xls") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $count = $count + 1 ;MsgBox(4096, "File:", $count & $file) WEnd ; Close the search handle FileClose($search) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ;or $msg = $Exit Exit ; //Exit the Application Case $nMsg = $OKbutton Klik_Copy() EndSwitch WEnd func Klik_Copy() $Label1 = GUICtrlCreateLabel("AANTAL FILES:", 70,100, 100, 17) EndFunc Link to comment Share on other sites More sharing options...
AlmarM Posted September 8, 2010 Share Posted September 8, 2010 (edited) First of all, welcome to the forums! Second, about your problem.Try changing $Label1 = GUICtrlCreateLabel("AANTAL FILES:", 70,100, 100, 17) to GUICtrlSetData($Label1, "AANTAL FILES: " & $count). Edited September 8, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Tvern Posted September 8, 2010 Share Posted September 8, 2010 (edited) Actually you should replace that line with GuiCtrlSetData($Label1,"AANTAL FILES: " & $count) Otherwise you're constatly placing controls under controls, without deleting the old ones. (Making a stack of unused controls)But you have a bigger problem:According to the helpfile FileFindFirstFile only supports one wildcard per filename. You're using "*" twice for the first part. I'll see if I can make a workaround.edit: Either I don't understand the helpfile, or that limitation doesn't apply to the current version of AutoIt, or under windows7. Your filter works fine, wish I had tried before writing a regex function for it.Anyways there where a few other hickups in your script, like the "Go" button being spammed from the start, so I made a few changes to make it work as I expect you intend it to do.expandcollapse popup#include <Date.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> ;you can declare a variable and assign a value to it on one line. (Try to use Local, or Global instead of Dim. For clarity) ;The source and destination folders, change to the ones you want to use. Global $sSourcePath = "C:\OldFolder" Global $sDestPath = "C:\New Folder" ;~ Local $DaAatUm = _NowDate() ;This doesn't seem to be used? #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("COPY_FILES", 633, 447) Local $CODE1 = GUICtrlCreateInput("UT", 80, 56, 50, 21) Global $Label1 = GUICtrlCreateLabel("AANTAL FILES: Onbekend", 70,100, 200, 17) ;the count is not known here yet Global $Progress1 = GUICtrlCreateProgress(40, 130, 100, 10) Local $OKButton = GUICtrlCreateButton("GO", 424, 205, 97, 30, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $aFiles = _FileListToArray(@ScriptDir,"*ISO_*.xls", 1) ;Store the files that match the criteria in an array. If @error Then MsgBox(0,"_FileListToArray() failed","Errorcode: " & @error) Exit Else GUICtrlSetData($Label1,"AANTAL FILES:" & $aFiles[0]) ;update the label that already exists, don't create a new one. EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ;or $msg = $Exit Exit ; //Exit the Application Case $OKbutton ;You had a comparison here, which resulted in the button being spammed Klik_Copy() EndSwitch WEnd func Klik_Copy() DirCreate($sDestPath) ;makes sure the dir exists For $i = 1 To $aFiles[0] ;run once for each file in the array FileCopy($sSourcePath & "\" & $aFiles[$i], $sDestPath & "\" & $aFiles[$i]) ;move the file GUICtrlSetData($Progress1,100*$i/$aFiles[0]) ;update the progressbar Next EndFunc Edited September 8, 2010 by Tvern Link to comment Share on other sites More sharing options...
motormad Posted September 8, 2010 Author Share Posted September 8, 2010 woow Spammer are you clairvoyant ? this is great !! Link to comment Share on other sites More sharing options...
motormad Posted September 8, 2010 Author Share Posted September 8, 2010 And your dutch ? In that case. Hoop ik dat ik helderziende goed heb gespeld in het Engels Link to comment Share on other sites More sharing options...
Tvern Posted September 8, 2010 Share Posted September 8, 2010 woow Spammer are you clairvoyant ?And your dutch ?In that case.Hoop ik dat ik helderziende goed heb gespeld in het Engels Only on wednesdaysyesI think you didp.s. "Mass spammer" is just a title given to everyone with more than a certain number of posts. The forum name is just above that. Link to comment Share on other sites More sharing options...
motormad Posted October 30, 2010 Author Share Posted October 30, 2010 (edited) I made expandcollapse popupFunc KlikOK() Local $aCheckboxx[$iRows], $aAPV[$iRows], $aAPLV[$iRows], $aSTAV[$iRows], $aSTOV[$iRows] ;;read all input For $i = 0 To $iRows - 1 $aCheckboxx[$i] = GUICtrlRead($aCheckbox[$i]) $aAPV[$i] = GUICtrlRead($aAP[$i]) $aAPLV[$i] = GUICtrlRead($aAPL[$i]) $aSTAV[$i] = Stringleft(StringRegExpReplace(GUICtrlRead($aSTA[$i]), "-", ""), 4 ) & StringRight (StringRegExpReplace(GUICtrlRead($aSTA[$i]), "-", ""), 2 ) $aSTOV[$i] = Stringleft(StringRegExpReplace(GUICtrlRead($aSTO[$i]), "-", ""), 4 ) & StringRight (StringRegExpReplace(GUICtrlRead($aSTO[$i]), "-", ""), 2 ) Next For $i = 0 To $iRows - 1 If $aCheckboxx[$i] <> 1 Then ContinueLoop For $i0 = 1 To $aAPLV[$i] ;You want to do the exact same thing multiple times? ;try to replace this entire part with controlsends ;;msgbox (0," ",StringLeft ( StringRegExpReplace(GUICtrlRead($aSTA[$i]), "-", ""), 4 )&StringRight (StringRegExpReplace(GUICtrlRead($aSTA[$i]), "-", ""), 2 ) ) WinWaitActive("[CLASS:TFrmAskBV]") MouseClick("left", 568, 486, 1) WinWaitActive("[CLASS:TFrmBV]") ControlSend("[CLASS:TFrmBV]", "", "[CLASS:TDBMemo; INSTANCE:1]", $aAPV[$i]) ;;Send($aAPV[$i]) ;;Send("{TAB}") ControlSend("[CLASS:TFrmBV]", "", "[CLASS:TDBEdit; INSTANCE:6]", $aSTAV[$i]) ;;Send($aSTAV[$i]) ;;Send("{TAB}") ;;Send("{TAB}") ControlSend("[CLASS:TFrmBV]", "", "[CLASS:TDBEdit; INSTANCE:4]", $aSTOV[$i]) ;;Send($aSTOV[$i]) ;;Send("{TAB}") ;;Send("{TAB}") ControlSend("[CLASS:TFrmBV]", "", "[CLASS:TDBMemo; INSTANCE:2]", "ZIE BIJGEVOEGDE LIJST") ;;Send("ZIE BIJGEVOEGDE LIJST") MouseClick("left", 158, 90, 1) Next Next EndFunc but now the ControlSend sends 111110001111 ???? The variable is correct. Do i have to put in some "sleep" action . Maybe the program can not follow what the ControlSend puts in it? Edited October 30, 2010 by motormad 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