Sign in to follow this  
Followers 0
khamis87

@error

5 posts in this topic

#1 ·  Posted (edited)

Hi everyone,

I'm an AutoIt beginner & I have a little background in programing.

My Q is: What does @error macro correspond to?

I bet it used like this situation:

WinActivate("[CLASS:Notepad]", "")

So now @error value = 1 or 0 depending on the success or failure of the previous command

What I want is getting the return value of any AutoIt function!

I know how to use WinActive. But with other ACTION functions like WinActivate or ControlDisable it just didn't work for me. In both success or failure I get @error = 0

I use the latest beta version v3.2.12.1 [took the version # from the help file]

Edited by khamis87

Share this post


Link to post
Share on other sites



It is only for the last function. Not for any function you so pick :P

Cheers,

Brett

yeah I know

but even when it follows a function, still it gives 0 in success or failure

e.g.

WinActivate("[CLASS:Notepad]", "")
If @error Then
    MsgBox("", "", @error)
Else
    MsgBox("", "", @error)
EndIf

In both cases, whether a Notepad window is activated or not I get a value of 0.

Case1: There's an inactive windows & it's been activated. This is a success. 0 value!! [as it should give 1 as the return value]

Case2: No such a window to activate. Failure. 0 value but it's ok.

It's quite impossible that this beta version has something wrong with the @error.

Share this post


Link to post
Share on other sites

Not all functions modify @error.

Look in the help file for return values.

In the case of WinActivate:

"Return Value

Success: Returns 1.

Failure: Returns 0 if window is not found or cannot be activated. "

...so WinActivate doesn't modify @error at all. You'd need to do this:

$return = WinActivate("[CLASS:Notepad]", "")
If $return Then
    MsgBox("", "", $return)
Else
    MsgBox("", "", $return)
EndIf

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Not all functions modify @error.

Look in the help file for return values.

In the case of WinActivate:

"Return Value

Success: Returns 1.

Failure: Returns 0 if window is not found or cannot be activated. "

...so WinActivate doesn't modify @error at all. You'd need to do this:

$return = WinActivate("[CLASS:Notepad]", "")
If $return Then
    MsgBox("", "", $return)
Else
    MsgBox("", "", $return)
EndIf
It came to my mind that this is what I should do but I didn't check it lol

anyways, thank you for your help

I'll try to be more serious next time!

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