Jump to content

Hooking a Function


Recommended Posts

Is it possible to have one function know when another function is called for Plug-In Purposes?

Example:

#Region - Main Script
    #include <FirstPlugin.au3>
    #include <SecondPlugin.au3>
    
    LogMessage("Woot! I processed something!")
    
#EndRegion - Main ScriptoÝ÷ Ù«­¢+ØI¥½¸´¥ÉÍÑA±Õ¥¸¹ÔÌ($¥¹±Õµ½¹($(%Õ¹1½5ÍÍ ÀÌØí5Íͤ($$íQ=

In this example the expected result would be a Call to "Hooked_LogMessage" then "LogMessage". The the third parameter in the [HookFunction] Function would be a Boolean value used to indicate an override. Thus if true it would in essence just replace the original function. The $Override feature is more of a "WishList" item and I can live without it.

In a twisted way this would implement some rudimentary OOP features. Namely Inheritance and overriding.

I know this is possible, I just don't know how to do it.

--- TTFN

Link to comment
Share on other sites

UPDATE:

I've been digging around the windows API and SetWindowsHookEx with CallWndProc looked promising. That is until frustration set in.

  • Am I correct in assuming that SetWindowsHookEx(CallWndProc...) can hook functions executed within AutoIt?
  • Or is AutoIt Designed in a way that makes this impossible?
I've been hacking away trying to get this to work with no luck. Am I at least on the right path? Can someone through me a clue? This seams so simple! Why isn't there a simple hook for this?!?

:P

--- TTFN

Link to comment
Share on other sites

UPDATE:

I've been digging around the windows API and SetWindowsHookEx with CallWndProc looked promising. That is until frustration set in.

  • Am I correct in assuming that SetWindowsHookEx(CallWndProc...) can hook functions executed within AutoIt?
  • Or is AutoIt Designed in a way that makes this impossible?
I've been hacking away trying to get this to work with no luck. Am I at least on the right path? Can someone through me a clue? This seams so simple! Why isn't there a simple hook for this?!?

:P

No, you're not on the right way.

The windows hooks will not help you to hook autoit functions.

Unfortunately the functionality you're seeking is most likely not available in autoit.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Why would you want to hook functions inside the same script? That's just senseless. Write the code inside the script to set some kind of modifier or to call the "hook" inside the function.

Hooks are meant for things outside of your normal reach. If you can edit the code you have, you shouldn't need things like hooks to read what you have the code for.

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