Sign in to follow this  
Followers 0
silvercover

What's the equivalent for A3LMemory.au3 library

2 posts in this topic

#1 ·  Posted (edited)

Hi,

I found below code somewhere on the net and it seems it's belong to 2007. so when I want to compile the code I get error message for UDFs. What's the equivalent for A3LMemory.au3 library and functions used in this code?

#include <A3LMemory.au3>

Global Const $WM_RUNSCRIPTCODE = 0x08C7
Global Const $RUNSCRIPTCODE_LOUD = 1
Global Const $RUNSCRIPTCODE_QUIET = 0
Local $iItem, $pMemory, $tMemMap, $pText

; get handle of MMB window (just insert MMB title as a parameter)
$hwnd = WinGetHandle("Welcome!")

; autoit variable containing MMB function/variable, which you want to run from AutoIt
; for example Message box
$stringToSend='Message("","OK")'
; or AutoIt variable send to MMB variable
; $AutoItVar = "This is an AutoIt variable"
; $stringToSend="test$='" & $AutoItVar & "'"

;and this is an example of passing AutoIt variable to MMB variable
;$stringToSend="test$='OK'"

; get length of passed string
$slen = stringlen($stringToSend) +1

$str = "char[" & $slen & "]"; structure item must be "char"
$struct= DllStructCreate($str); create a struct for the string so we can get a pointer to it
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error)
    exit
endif

$iItem   = DllStructGetSize($struct); get structure size
$pMemory = _Mem_CtrlInit($hwnd, $iItem, $tMemMap); init memory and return pointer to initialized memory in target app
DllStructSetData($struct, 1, $stringToSend); set string to structure
$pointer = DllStructGetPtr($struct,1); pointer to string in structure
_Mem_CtrlWrite($tMemMap, $pointer, $pMemory, $iItem); write string pointer to application memory
    
    
$result = DllCall("user32.dll","int","SendMessage","hWnd",$hwnd ,"int",$WM_RUNSCRIPTCODE,"int",$RUNSCRIPTCODE_LOUD,"ptr",$pMemory)
If @error Then
        MsgBox(0,"_ToggleMonitor", "_SendMessage Error: " & @error)
        Exit
    EndIf

_Mem_CtrlFree($tMemMap);release the memory

Thanks

Edited by silvercover

The more I learn the less I know!

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