Sign in to follow this  
Followers 0
grasshopper

How To Show Return Value?

5 posts in this topic

what is the syntax for reading and displaying the return value from AutoIT functions.

Share this post


Link to post
Share on other sites



and then msgbox with the $var in it :(

Share this post


Link to post
Share on other sites

and then msgbox with the $var in it :(

<{POST_SNAPBACK}>

thanks for the assistance SteveR and MARKMARKMARK.

here is an example of the code that i worked on that used return codes:

Run("notepad.exe") ;launches notepad editor

WinWait ("Untitled - Notepad", "", 10) ;Pauses execution of the script until the requested window exists.

$rtn00 = WinExists ("Untitled - Notepad", "") ;feeds result code of WinWait into var "$rtn00"

If $rtn00 = 1 Then

WinActivate ("Untitled - Notepad", "") ;Activates (gives focus to) a window.

$rtn01 = WinActivate ("Untitled - Notepad") ;feeds result code of WinActivate into var "$rtn01"

If $rtn01 = 1 Then ;if result = 1 goto next line of code, otherwise exit or display error message.

MsgBox(0, "Status", "Window Has Been Activated. Notepad Editor Will Now Be Closed.") ;for testing purposes only.

WinClose("Untitled - Notepad") ;close notepad editor

Else

MsgBox(0, "Status", "Unable To Activate window. This Script Will Now Exit.") ;for testing purposes only.

Exit

EndIf

Else

MsgBox(0, "Status", "Window Does Not Exist. This Script Will Now Exit.") ;for testing purposes only.

Exit ;Window does not exist, exiting script.

EndIf

Share this post


Link to post
Share on other sites

thanks for the assistance SteveR and MARKMARKMARK.

here is an example of the code that i worked on that used return codes:

Run("notepad.exe");launches notepad editor
WinWait ("Untitled - Notepad", "", 10);Pauses execution of the script until the requested window exists.
$rtn00 = WinExists ("Untitled - Notepad", "");feeds result code of WinWait into var "$rtn00" 
If $rtn00 = 1 Then
    WinActivate ("Untitled - Notepad", "");Activates (gives focus to) a window.
    $rtn01 = WinActivate ("Untitled - Notepad");feeds result code of WinActivate into var "$rtn01" 
    If $rtn01 = 1 Then;if result = 1 goto next line of code, otherwise exit or display error message.
    MsgBox(0, "Status", "Window Has Been Activated. Notepad Editor Will Now Be Closed.");for testing purposes only.
    WinClose("Untitled - Notepad");close notepad editor
    Else
        MsgBox(0, "Status", "Unable To Activate window. This Script Will Now Exit.");for testing purposes only.
        Exit
    EndIf
Else
    MsgBox(0, "Status", "Window Does Not Exist. This Script Will Now Exit.");for testing purposes only.
    Exit;Window does not exist, exiting script.
EndIf

<{POST_SNAPBACK}>

While technically correct, assigning the value to a variable is not required.

your If statement could be accomplished by:

If WinActivate ("Untitled - Notepad") = 1 then

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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
Sign in to follow this  
Followers 0