Jump to content

How can i make my script go to a function?


Dgameman1
 Share

Recommended Posts

Let's say this is my code

Now how can i make it so that when i press my button,

It does the code in the function typelawl

and then it continues with the rest of what is in the function

Func typelawl()
 
WinActivate("[TITLE:lawlwindow]", "")
$talker1=PixelSearch ( 454, 438, 455, 439, 0x6D84B4, 0 , 1, "[TITLE:lawlwindow]"  )
  if not @error Then
   $talker2=PixelSearch ( 561, 435, 562, 436, 0xD3DAE9, 0 , 1, "[TITLE:lawlwindow]"  )
    if not @error Then
     $talker3=PixelSearch ( 420, 695, 421, 696, 0xFFFFFF, 0 , 1, "[TITLE:lawlwindow]"  )
     Mouseclick("left" , $talker3[0], $talker3[1] , 2 , 1)
     send("Hi.")
     send("{ENTER}")
     Mouseclick("left" , $talker3[0], $talker3[1] , 2 , 1)
     send("Whatcha doing?")
     send("{ENTER}")
     Mouseclick("left" , $talker3[0], $talker3[1] , 2 , 1)
     send("good")
     send("{ENTER}")
     send("(Do Not Reply, This is an Automated Message)")
     send("{ENTER}")
     $talker4=PixelSearch ( 563, 438, 564, 439, 0xD3DAE9, 0 , 1, "[TITLE:lawlwindow]"  )
      if not @error Then
       Mouseclick("left" , $talker4[0], $talker4[1] , 1 , 1)
      EndIf
    EndIf
  EndIf
EndFunc
Link to comment
Share on other sites

Do you mean like a HotKey?

so i already have a function for button1

When i press button1, a whole of code happens.

how can i make it so that before the whole code happens

it does what is in function typelawl and then when it's done, it finishes up the code in button1?

Link to comment
Share on other sites

so i already have a function for button1

When i press button1, a whole of code happens.

how can i make it so that before the whole code happens

it does what is in function typelawl and then when it's done, it finishes up the code in button1?

If you are calling a function by pressing button1 then put a call to the typelawl function inside that function.

Link to comment
Share on other sites

  • Moderators

MrMitchell was pretty explicit. If you can create a function, you should understand what it means to put another call into one.

pseudo:

For $i = 1 To 10 ; loop 10 times to see if you get diff msgbox
    ; Action Below
    _MyActionFunc()
    If @error Then
        ; this means that my check func returned false
        MsgBox(16 + 262144, "Error", "_CheckSomethingFirst() returned False")
    EndIf
Next

Func _MyActionFunc()
    ; now I want to go to another func first
    If _CheckSomethingFirst() = False Then
        ; Here I've created a condition to do something in case my checking function fails
        ; don't do anything else, just return
        Return SetError(1, 0, 0)
    EndIf

    MsgBox(64, "Success", "See you made it here")

    Return 1
EndFunc

Func _CheckSomethingFirst()
    Local $a_arr[2] = [False, True]
    Return $a_arr[Random(0, 1, 1)]
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...