Jump to content

Detection of an event in a library routine


 Share

Recommended Posts

I have a common library function in which I need to detect whether it has been triggered by an event, or simply called directly in a script.

So far, any testing of the macros set during an event, error out the program if used.

For instance, an equivalent to IsDeclared(@GUI_WINHANDLE) used for testing variables does not work for testing macros. Nor can you test for @error, since any reference to an event macro will error the program out entirely, causing it to stop.

So in summary, I need this functionality:

func some_library_routine()
    if some_test(@GUI_WINHANDLE) then
        blah
    else
        blah
    endif
endfunc

where my question is, what test can I use to determine whether this function was triggered via an event, or called directly?

Link to comment
Share on other sites

I have a common library function in which I need to detect whether it has been triggered by an event, or simply called directly in a script.

<{POST_SNAPBACK}>

As my question slips onto page 3 of this forum without an answer, do I assume this cannot be done?
Link to comment
Share on other sites

You could give it a paramater that you set differently based on how you are calling it:

ie

Calling it in the script:

some_library_routine(0)

Calling it from a windows event:

$msg = GUIGetMsg()

if $msg = $hbutton then some_library_routine(1)

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

You could give it a paramater that you set differently based on how you are calling it:

ie

Calling it in the script:

some_library_routine(0)

Calling it from a windows event:

$msg = GUIGetMsg()

if $msg = $hbutton then some_library_routine(1)

<{POST_SNAPBACK}>

Indeed. I'd thought about that, but I was hoping that my library function could be truly polymorphic, by which I can only achieve that transparency if the function can internally check who called it.

Still, if I have no full solutions, then I'll do precisely that, and pass a parameter in manually.

Thanks for the input.

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