Jump to content

Who wants a callback function capability ?


Recommended Posts

well ppl, after several requests to share my secret to ... ( you know ) ...

im willing to do that ... BUT ... for a price ...

my request :lmao: is very simple ... GIVE ME THE WORLD :):king:

no ? ok, i'll sattle for a cent by paypal account.

no too ? fine. :P:P:P

as some of us know, in autoit there is no direct method to get address of variables or functions

what a shame, VERY VERY LIMITING. :lmao::(

there are several ways to bypass this limit, i worked it out. heres one, it involves writing the CALLBACK

in a different DLL and then using autoits DLLCALL to do ... another ... DLL CALL ( LoadLibrary() )

then, using DLLCALL and GetProcAddress() to get the function address

y, i know, VERY :) ... but it works

for my own testing i chose Win API - EnumChildWindows()

the dll i wrote is atteched so download and place it in the SAME dir where you save the script

otherwise, point $CallbackDLL to the right folder

enjoy

Opt( "TrayIconDebug", 1 )


#include <array.au3>


Global $WinHandle, $CallbackDLL, $FuncName, $ControlID

Global $DLL[ 2 ], $FuncAddr[ 3 ], $WinHandle[ 3 ], $Result[ 4 ]



$WinTitle = 'Calculator';

$CallbackDLL = 'Callback.dll'; this DLL has the CALLBACK function for THIS script

$FuncName = 'EnumProc'

$ControlID = 'Sta'; $ControlID is the control text ( for this progy ),  Calculator MUST be in scientific mode



$WinHandle = DllCall( 'user32.dll', 'hwnd', 'FindWindow', 'int', 0, 'str', $WinTitle ); Get Window Handle

_ArrayDisplay( $WinHandle, '1' )

If $WinHandle[ 0 ] == '0x00000000' Then; DLLCALL Failed for whatever reason, no valid handle
    
    MsgBox( 0, 'Error', 'DLLCALL Failed' )
    
Else

    $DLL = DllCall( 'kernel32.dll', 'hwnd', 'LoadLibrary', 'str', $CallbackDLL ); Load DLL

    _ArrayDisplay( $DLL, '2' )

    If $DLL[ 0 ] == '0x00000000' Then; DLLCALL Failed for whatever reason, no valid handle
    
        MsgBox( 0, 'Error', 'DLLCALL Failed' )
    
    Else

        $FuncAddr = DllCall( 'kernel32.dll', 'ptr', 'GetProcAddress', 'hwnd', $DLL[ 0 ], 'str', $FuncName ); Get Function Address

        _ArrayDisplay( $FuncAddr, '3' )
    
        If $FuncAddr[ 0 ] == 0 Then; DLLCALL Failed for whatever reason or Function NOT Found
        
            MsgBox( 0, 'Error', 'DLLCALL Failed or Function NOT Found' )
        
        Else
    
            $Result = DllCall( 'user32.dll', 'int', 'EnumChildWindows', 'hwnd', $WinHandle[ 0 ], 'ptr', $FuncAddr[ 0 ], 'str', $ControlID ); GO

            _ArrayDisplay( $Result, '4' ); EnumProc returns FALSE ( 0 ) if it finds $ControlID so dont be alarmed

            $DLL = DllCall( 'kernel32.dll', 'int', 'FreeLibrary', 'hwnd', $DLL[ 0 ] ); Free DLL

            _ArrayDisplay( $DLL, '5' )

        EndIf
    
    EndIf

EndIf

Callback.dll

Link to post
Share on other sites

well ppl, after several requests to share my secret to ... ( you know ) ...

im willing to do that ... BUT ... for a price ...

my request :lmao: is very simple ... GIVE ME THE WORLD :):king:

no ? ok, i'll sattle for a cent by paypal account.

no too ? fine. :P:P:P

as some of us know, in autoit there is no direct method to get address of variables or functions

what a shame, VERY VERY LIMITING. :lmao::(

there are several ways to bypass this limit, i worked it out. heres one, it involves writing the CALLBACK

in a different DLL and then using autoits DLLCALL to do ... another ... DLL CALL ( LoadLibrary() )

then, using DLLCALL and GetProcAddress() to get the function address

y, i know, VERY :) ... but it works

for my own testing i chose Win API - EnumChildWindows()

the dll i wrote is atteched so download and place it in the SAME dir where you save the script

otherwise, point $CallbackDLL to the right folder

enjoy

Opt( "TrayIconDebug", 1 )
#include <array.au3>
Global $WinHandle, $CallbackDLL, $FuncName, $ControlID

Global $DLL[ 2 ], $FuncAddr[ 3 ], $WinHandle[ 3 ], $Result[ 4 ]
$WinTitle = 'Calculator';

$CallbackDLL = 'Callback.dll'; this DLL has the CALLBACK function for THIS script

$FuncName = 'EnumProc'

$ControlID = 'Sta'; $ControlID is the control text ( for this progy ),  Calculator MUST be in scientific mode
$WinHandle = DllCall( 'user32.dll', 'hwnd', 'FindWindow', 'int', 0, 'str', $WinTitle ); Get Window Handle

_ArrayDisplay( $WinHandle, '1' )

If $WinHandle[ 0 ] == '0x00000000' Then; DLLCALL Failed for whatever reason, no valid handle
    
    MsgBox( 0, 'Error', 'DLLCALL Failed' )
    
Else

    $DLL = DllCall( 'kernel32.dll', 'hwnd', 'LoadLibrary', 'str', $CallbackDLL ); Load DLL

    _ArrayDisplay( $DLL, '2' )

    If $DLL[ 0 ] == '0x00000000' Then; DLLCALL Failed for whatever reason, no valid handle
    
        MsgBox( 0, 'Error', 'DLLCALL Failed' )
    
    Else

        $FuncAddr = DllCall( 'kernel32.dll', 'ptr', 'GetProcAddress', 'hwnd', $DLL[ 0 ], 'str', $FuncName ); Get Function Address

        _ArrayDisplay( $FuncAddr, '3' )
    
        If $FuncAddr[ 0 ] == 0 Then; DLLCALL Failed for whatever reason or Function NOT Found
        
            MsgBox( 0, 'Error', 'DLLCALL Failed or Function NOT Found' )
        
        Else
    
            $Result = DllCall( 'user32.dll', 'int', 'EnumChildWindows', 'hwnd', $WinHandle[ 0 ], 'ptr', $FuncAddr[ 0 ], 'str', $ControlID ); GO

            _ArrayDisplay( $Result, '4' ); EnumProc returns FALSE ( 0 ) if it finds $ControlID so dont be alarmed

            $DLL = DllCall( 'kernel32.dll', 'int', 'FreeLibrary', 'hwnd', $DLL[ 0 ] ); Free DLL

            _ArrayDisplay( $DLL, '5' )

        EndIf
    
    EndIf

EndIf
haven't tried it myself yet, but thanks for posting, this is a need that alot of people have been looking for...
Link to post
Share on other sites
  • 2 weeks later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...