Sign in to follow this  
Followers 0
autosc

AU3_ClipGet(mydata,512);

4 posts in this topic

I was trying autoit with Delphi with some functions which are working .....

the clip get function crashes -- why ?

part of the code

setme := 'Delphi with Auoit ';

      .......

       AU3_ClipPut(setme);
      AU3_ClipGet(buf,1024);

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

havent read the x doc's for a long time but...

arent you supposed to call AU3_Init(); on startup ?

edit:

i have no idea how delphi works but 'setme' doesent look like its 1024 bytes long.

edit2:

Its probably the nBufSize parameter.

Looks like autoitx is filling the whole buffer even if the content is smaller.

like this:

char szClip[256] = "Test";

AU3_Init();
AU3_ClipPut(szClip);

AU3_ClipGet(szClip, sizeof(szClip)); // This Works
AU3_ClipGet(szClip, 1024); // This Crashes
Edited by piccaso

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites

havent read the x doc's for a long time but...

arent you supposed to call AU3_Init(); on startup ?

edit:

i have no idea how delphi works but 'setme' doesent look like its 1024 bytes long.

edit2:

Its probably the nBufSize parameter.

Looks like autoitx is filling the whole buffer even if the content is smaller.

like this:

char szClip[256] = "Test";

AU3_Init();
AU3_ClipPut(szClip);

AU3_ClipGet(szClip, sizeof(szClip)); // This Works
AU3_ClipGet(szClip, 1024); // This Crashes

this

AU3_ClipPut('szClip54355');

AU3_ClipGet(szClip,sizeof(szClip));
Showmessage(PChar( szClip ));

returns from clip only (szC) ..........

Share this post


Link to post
Share on other sites

You need to allocate memory in your Delphi program for the buffer variable. One way:

procedure AU3_ClipGet(szClip: PChar; nBufSize: integer); stdcall; external 'AutoItX3.dll';

procedure TForm1.Button1Click(Sender: TObject);

var st:string;

begin

SetLength(st,2000);

AU3_ClipGet(pchar(st),length(st));

memo1.text:=st;

end;

You also can change the external declaration and do it other ways. Here's one in which you don't need to specify the buffer size.

procedure AU3_ClipGet(var Clip: array of char); stdcall; external 'AutoItX3.dll';

procedure TForm1.Button1Click(Sender: TObject);

var buffer:array[0..10000] of char;

begin

AU3_ClipGet(buffer);

memo1.text:=buffer;

end;

Here's another example, in which the material copied to the clipboard was 25 megs, requiring extra memory to be reserved for the stack with a compiler directive: {$MAXSTACKSIZE 35000000}

procedure AU3_ClipGet(szClip: pointer; nBufSize: integer); stdcall; external 'AutoItX3.dll';

procedure TForm1.Button1Click(Sender: TObject);

type bufftype= array[0..30000000] of char;

var buffer:^bufftype;

begin

new(buffer);

AU3_ClipGet(buffer,sizeof(buffer^));

memo1.text:=buffer^;

dispose(buffer);

end;

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