jonai

Function as code to use more than one time

4 posts in this topic

Hello, it's posible to use a function as piece of autoit code to use it more than one time. And if it's posible, how can i call the function is the above code ok ???

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <IE.au3>


       WinSetState ( "pruebas.txt: Bloc de notas", "", @SW_MAXIMIZE ) ; SOLO PARA PRUEBAS EN CASA
       WinActivate ( "pruebas.txt: Bloc de notas" ) ; SOLO PARA PRUEBAS EN CASA


Func copiocomparo() ; txtprueba
          Send ("{ALT}+{e}")
       ;Sleep(10)
       Send ("{t}")
       ;Sleep(10)
       Send ("{ALT}+{e}")
       ;Sleep(10)
       Send ("{ALT}+{o}")
       ;Sleep(10)
       $comparativo = ClipGet()
EndFunc



Local $i = 0
Local $times = 0
Do
       Call ("copiocomparo")



; Hemos copiado la pantalla y comparamos si existe Si es asi estamos en la pantalla correcta y seguimos enviando el dni
; Lo intentara 10 veces para ver si es la pantalla correcta pero tambien por si el sistema está muy lento

   If StringRegExp($comparativo, "texto que debe existir para lanzar los comandos") Then

     Send("{TAB}")
     Send("{TAB}")
     Send ( $lprevio )
     Send ( $data1 )
     Send("{TAB}")
     Send ( $data11 )
     Send ("{ENTER}")
      ; envio dni
      $i = 1
   Else
                       ;MsgBox(0, "test", "No Coincide")
     Sleep(100)
     $times = $times + 1
   EndIf

   Until $i = 1  Or $times = 10; Increase the value of $i until it equals the value of 10.


If $times = 10 Then
   MsgBox(0, "INFO", "No estás en la pantalla adecuada o el Sistema está muy lento")
   Continueloop
   EndIf

Thanks in advanced

Share this post


Link to post
Share on other sites



I don't understand :S (No entiendo :S)

Saludos

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I try to explain better.
Imagine my need to copy the contents of a window that is continuously changing.
To copy I have to use a particular sequence (always the same). But that is not the typical control c. And the content is copied converted into variable to compare it with some text and do something.

Function copiocomparo()  ?????


My question is: Can I convert this sequence into a function and call it when I need it? (Code reuse)
And if so, how do I do?

Call ("copiocomparo")   ??????

Thanks

Edited by jonai

Share this post


Link to post
Share on other sites

Yes you can. you can create a funtion and assign to a hotkey using HotKeySet then you can call that funtion when you need it simple pressing you hot key.

Saludos

Share this post


Link to post
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