Jump to content

Function as code to use more than one time

Recommended Posts

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}")
       Send ("{t}")
       Send ("{ALT}+{e}")
       Send ("{ALT}+{o}")
       $comparativo = ClipGet()

Local $i = 0
Local $times = 0
       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 ( $lprevio )
     Send ( $data1 )
     Send ( $data11 )
     Send ("{ENTER}")
      ; envio dni
      $i = 1
                       ;MsgBox(0, "test", "No Coincide")
     $times = $times + 1

   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")

Thanks in advanced

Share this post

Link to post
Share on other sites

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")   ??????


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.


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

  • Create New...