2) please make your suggestions here for API calls using CallVack
to make try if it works also on other functions then only EnumWindows,
for example: ReadDirectoryChangesW (as somebody said in AHK forum),...

at least it works for me
but i have no practice on a level that low and i'm only 90% sure about what i'm doing here so
if someone with asm experience could take a look at it...
I would really appreciate that

To make it a safer UDF I think a discussion should be started on how multiple OnAutoItExit functions could be registered with the script engine. It would be so much simpler if a UDF's file could automatically clean up after it self. The discussion probably deserves it's own topic, but maybe you will keep it in mind and consider possible solutions?

I have wrapped it up a bit for my own understanding and added a simple EnumChildWindows sample.

i read some articles about the global heap and i think explicit deallocation isnt necessary.

Now you're probably wondering if there is any difference between the local and global functions themselves. Well, the answer is no, they are now the same. In fact, they are interchangeable. Memory allocated via a call to LocalAlloc can be reallocated with GlobalReAlloc and then locked by LocalLock. The following table lists the global and local functions now available in Win32.

Other memory management routines such as GlobalAlloc, GlobalLock, GlobalFree, malloc, free, new, and delete, have all been changed to use VirtualAlloc and VirtualFree at a low level.

... and so on.so if i get this right GloballAlloc is just short for Allocating executable memory on local heap and the name is just a win16 leftover

I would prefer an this as an built-in feature too but just because the detour over windows messaging could be avoided.But this is probably pretty tricky since the os fires callbacks whenever it wants to and might interrupt autoit in doing something...and there are only a few situations where the windows message detour variant doesn't work (like crt's atexit)It has been requested a couple of times and never happened so i guess it will stay that way.Probably because it isn't essential...