topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 1:30 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Adapt my script to create registers from a txt file  (Read 3317 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Adapt my script to create registers from a txt file
« on: February 11, 2017, 12:12 PM »
I use a database in dBASE IV format.
I have a script to add registers introducing three fields in the append main window of the database program.
The script is written in Autoit.
But I suppose is almost the same in AutoHotkey

I need help to modify the option when ask the user if he wants add a possible duplicate.
The script is mainly in spanish. I may try translate all if needed.

Agregar nuevo registro - Add a new register
Ya hay un registro - Register already exists.

If you search the above lines you will find the lines I wish to change.

What the program does ?

Add register from the clipboard into a dBASE database structure from the adding window.
If the register already exists ask the user to add or not.

What is supposed I want to program to do now ?

When the program halts because find a duplicate simply continue adding to the field NOTES.
Then continue the scanning of the lines of the txt file.

As I told befores the program only manage three fields and fills all with the same value .

By example :

"Registro nuevo" (is the last clip in the clipboard)

Add to the dBASE database in the field Company ( Registro Nuevo ) , in the field Contact ( Registro nuevo) and in the field Notes (Registro nuevo)

If the registry "Registro Nuevo" already exists then the program halts waiting for the user decision.

What I need is not wait for the user and is a duplicate registry is found add the value to the notes field . And continue the scanning.

If WinExists("GoldMine", "Ya hay un registro") = 1 Then
                $handle_VentanaGoldMineRegistroDuplicado = WinActivate("GoldMine", "Ya hay un registro")
                If $handle_VentanaGoldMineRegistroDuplicado = 0 Then
                    MsgBox(16, "LineToClip - Error", "Se ha producido un error al intentar activar la ventana de registro duplicado de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E049", 300)
                    FileClose($handle_ArchivoRegistrosBaseDatos)
                    $str_Archivo = ""
                    TraySetClick(8)
                    TraySetState(8)
                    Return
                EndIf
                $int_ResultadoWinWaitClose = WinWaitClose("GoldMine", "Ya hay un registro", 0)
                If $int_ResultadoWinWaitClose <> 1 Then
                    MsgBox(16, "LineToClip - Error", "Se ha obtenido una respuesta inesperada al esperar al cierre de la ventana de registro duplicado de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E050", 300)
                    FileClose($handle_ArchivoRegistrosBaseDatos)
                    $str_Archivo = ""
                    TraySetClick(8)
                    TraySetState(8)
                    Return
                EndIf
            EndIf
            Sleep($int_TiempoEsperaAbrirVentanaYDetectarTeclas)
            If WinExists("Agregar nuevo registro") = 1 Then
                $handle_VentanaGoldMineNuevoRegistro = WinActivate("Agregar nuevo registro")
                If $handle_VentanaGoldMineNuevoRegistro = 0 Then
                    MsgBox(16, "LineToClip - Error", "Se ha producido un error al intentar activar la ventana de nuevo registro de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E051", 300)
                    FileClose($handle_ArchivoRegistrosBaseDatos)
                    $str_Archivo = ""
                    TraySetClick(8)
                    TraySetState(8)
                    Return
                EndIf
                $int_IsPressedReintentos = 0
                $int_IsPressedResultado = 0
                _IsPressed("0D", $handle_shell32)
                _IsPressed("1B", $handle_shell32)
                While $int_IsPressedReintentos < 8
                    If _IsPressed("0D", $handle_shell32) = 1 Then
                        $int_IsPressedResultado = 6
                    ElseIf _IsPressed("1B", $handle_shell32) = 1 Then
                        $int_IsPressedResultado = 7
                    EndIf
                    If WinExists("Agregar nuevo registro") <> 1 Then
                        $int_IsPressedReintentos = $int_IsPressedReintentos + 1
                    EndIf
                WEnd
                If $int_IsPressedResultado <> 6 And $int_IsPressedResultado <> 7 Then
                    $int_IsPressedResultado = MsgBox(36, "LineToClip - Pregunta", "La ventana Agregar nuevo registro se ha cerrado. ¿Desea continuar añadiendo el registro actual?", 0)
                EndIf
                Sleep($int_TiempoEsperaAbrirVentana)
                If WinExists("GoldMine", "Ya hay un registro") = 1 Then
                    $handle_VentanaGoldMineRegistroDuplicado = WinActivate("GoldMine", "Ya hay un registro")
                    If $handle_VentanaGoldMineRegistroDuplicado = 0 Then
                        MsgBox(16, "LineToClip - Error", "Se ha producido un error al intentar activar la ventana de registro duplicado de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E052", 300)
                        FileClose($handle_ArchivoRegistrosBaseDatos)
                        $str_Archivo = ""
                        TraySetClick(8)
                        TraySetState(8)
                        Return
                    EndIf
                    $int_ResultadoWinWaitClose = WinWaitClose("GoldMine", "Ya hay un registro", 0)
                    If $int_ResultadoWinWaitClose <> 1 Then
                        MsgBox(16, "LineToClip - Error", "Se ha obtenido una respuesta inesperada al esperar al cierre de la ventana de registro duplicado de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E053", 300)
                        FileClose($handle_ArchivoRegistrosBaseDatos)
                        $str_Archivo = ""
                        TraySetClick(8)
                        TraySetState(8)
                        Return
                    EndIf
                EndIf
                Select
                Case $int_IsPressedResultado = 6
                    Send("!c", 0)
                    Send("i", 0)
                    Send("^i", 0)
                    Send("{TAB}", 0)
                    Send("^v", 0)
                    Send("{TAB}", 0)
                    Send("{TAB}", 0)
                    Send("{TAB}", 0)
                    Send("{TAB}", 0)
                    Sleep($int_TiempoEsperaAbrirVentana)
                    If WinExists("Bloqueo de registro multiusuario") = 1 Then
                        $handle_VentanaGoldMineBloqueoRegistroMultiusuario = WinActivate("Bloqueo de registro multiusuario")
                        If $handle_VentanaGoldMineBloqueoRegistroMultiusuario = 0 Then
                            MsgBox(16, "LineToClip - Error", "Se ha producido un error al intentar activar la ventana de bloqueo de registro multiusuario de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E054", 300)
                            FileClose($handle_ArchivoRegistrosBaseDatos)
                            $str_Archivo = ""
                            TraySetClick(8)
                            TraySetState(8)
                            Return
                        EndIf
                        $int_ResultadoWinClose = WinClose("Bloqueo de registro multiusuario")
                        If $int_ResultadoWinClose = 0 Then
                            MsgBox(16, "LineToClip - Error", "Se ha producido un error al intentar cerrar la ventana de bloqueo de registro multiusuario de GoldMine. Puede que el programa no esté ejecutándose o la ventana ya haya sido cerrada." & @CRLF & @CRLF & "Número de error del programa: E055", 300)
                        EndIf
                    EndIf
                    Send("{ESC}", 0)
                    If WinExists("GoldMine", "Guardar cambios en notas") = 1 Then
                        $handle_VentanaGoldMineGuardarNotas = WinActivate("GoldMine", "Guardar cambios en notas")
                        If $handle_VentanaGoldMineGuardarNotas = 0 Then
                            MsgBox(16, "LineToClip - Error", "Se ha producido un error al intentar activar la ventana de guardar notas de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E056", 300)
                            FileClose($handle_ArchivoRegistrosBaseDatos)
                            $str_Archivo = ""
                            TraySetClick(8)
                            TraySetState(8)
                            Return
                        EndIf
                        Send("s", 0)
                        $int_ResultadoWinWaitClose = WinWaitClose("GoldMine", "Guardar cambios en notas", 0)
                        If $int_ResultadoWinWaitClose <> 1 Then
                            MsgBox(16, "LineToClip - Error", "Se ha obtenido una respuesta inesperada al esperar al cierre de la ventana de guardar notas de GoldMine. Puede que el programa no esté ejecutándose o esté tardando demasiado en responder." & @CRLF & @CRLF & "Número de error del programa: E057", 300)
                            FileClose($handle_ArchivoRegistrosBaseDatos)
                            $str_Archivo = ""
                            TraySetClick(8)
                            TraySetState(8)
                            Return
                        EndIf
                    EndIf