Jump to content

Input saving wrong value


Recommended Posts

Hi guys, i'm beginner with autoit!

I'm trying copy and paste same files.

What i want to do: insert initial number and last number of the files, so copy & past them. but, if I put value 10 on last number, this looks like as if I inserted value 6.

 

can you help me?

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

;Text ="1", Left = 54, Top = 138, Width = 36, Height = 29

criaForm()

Func criaForm()
    Local $hGUI = GUICreate("MoveNotas")
    Local $idBtnDirOrigin = GUICtrlCreateButton("Selecionar Diretorio origem", 50, 50, 200, 25)
    Local $idBtnDirDestiny = GUICtrlCreateButton("Selecionar Diretorio origem", 300, 50, 200, 25)
    Local $idEdtInitialValue = GUICtrlCreateInput("", 50, 100, 50, 20)
    Local $idEdtEndValue = GUICtrlCreateInput("", 100, 100, 50, 20)
    Local $idOK = GUICtrlCreateButton("fechar", 310, 370, 85, 25)
    Local $idBtnCopyAll = GUICtrlCreateButton("Copiar notas", 50, 200, 70, 25)
    Local $dirOrigin = ""
    Local $dirDestiny = ""

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop
            Case $idBtnDirOrigin
                $dirOrigin = selectDir("Origem")
            Case $idBtnDirDestiny
                $dirDestiny = selectDir("Destino")
            Case $idBtnCopyAll
                copyNF($idEdtInitialValue, $idEdtEndValue, $dirOrigin, $dirDestiny)
        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
 EndFunc   ;==>Example

 Func selectDir($type_dir)
   ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Selecione a pasta " & $type_dir

    ; Display an open dialog to select a file.
    Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "Nenhuma pasta foi selecionada.")
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "você escolheu a pasta:" & @CRLF & $sFileSelectFolder)
     EndIf

     Return $sFileSelectFolder
  EndFunc

  Func copyNF($initVal, $endVal, $fromDir, $toDir)
     MsgBox($MB_SYSTEMMODAL, "", "init val: " & $initVal & @CRLF & " endVal: " & $endVal & @CRLF & " fromDir: " & $fromDir & @CRLF & " To dir: " & $toDir)
      For $i = $initVal To $endVal Step 1
         FileCopy($fromDir & "\" & $i & ".xml", $toDir & "\")
      Next
      MsgBox($MB_SYSTEMMODAL, "", "Copiado com sucesso")
  EndFunc

 

autoerror.PNG

Link to comment
Share on other sites

  • Moderators

DanielVibuso,

Welcome to the AutoIt forums.

You need to use GUICtrlRead to get the value of the controls - what you are getting currently is the internal index number of the control in AutoIt's internal array of controls.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

10 minutes ago, Melba23 said:

DanielVibuso,

Welcome to the AutoIt forums.

You need to use GUICtrlRead to get the value of the controls - what you are getting currently is the internal index number of the control in AutoIt's internal array of controls.

M23

Thank you!

This worked fine! God Bless you, my friend!

Link to comment
Share on other sites

  • Moderators

DanielVibuso,

Delighted I could help. But when you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...