AutoPepe Posted February 13, 2017 Posted February 13, 2017 Adapt the script to create registers from a txt file 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. expandcollapse popupIf 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 LineToClip.au3 LineToClip.au3 Traducción AutoIt al Español. http://autoitespa.espanaforo.com/forum.htm . Visita el foro de AutoIt en español http://www.emesn.com/autoitforum/. I am a simple user, not a programmer.
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