Sign in to follow this  
Followers 0
nlhung

Help me with GETMESSAGE

9 posts in this topic

Help me, Please!

I do not know why, when this command crash.

$ msg = DllStructCreate ('HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam; DWORD time; ptr pt')

DllCall ('user32.dll', 'bool', 'GetMessageW', 'ptr', DllStructGetPtr ($ msg))

I want to get messages from the queue by an application, how? Please help me, I am very thankful!

Share this post


Link to post
Share on other sites



http://msdn.microsoft.com/en-us/library/windows/desktop/ms644936%28v=vs.85%29.aspx

When you use DllCall, your parameters need to match this.

Share this post


Link to post
Share on other sites

Yes, I know. But type "LPMSG" in Window to AutoIt is What?

I think it's "ptr". And tagMsg in Window is

typedef struct tagMSG {

HWND hwnd;

UINT message;

WPARAM wParam;

LPARAM lParam;

DWORD time;

POINT pt;

} MSG, *PMSG, *LPMSG;

To AutoIt I write "$msg = DllStructCreate('HWND hwnd;UINT message;WPARAM wParam;LPARAM lParam;DWORD time;ptr pt')".

It true or false?

Thank, Richard Robertson!

Share this post


Link to post
Share on other sites

Yes but you are missing parameters on GetMessage itself.

Share this post


Link to post
Share on other sites

Yes, I fix code into:

$msg = DllStructCreate('HWND hwnd;UINT message;WPARAM wParam;LPARAM lParam;DWORD time;ptr pt')

DllCall('user32.dll','bool','GetMessageW','ptr',DllStructGetPtr($msg),"HWND","0x000A0288","UINT","0x0100","UINT","0x0101")

It can not exit. What can I do to get the message?

Share this post


Link to post
Share on other sites

When you say it can not exit, do you mean that it sits there until you kill the program?

Wait a minute, are you trying to read the message of another program? GetMessage only reads messages on the calling thread's windows. It never returns because you don't own the other window.

Share this post


Link to post
Share on other sites

Hi,

as far as I know (and from my experiences) you can not create a message loop with GetMessage in AutoIt.

Because the main function of the AutoIt-Interpreter has already a message loop for the running thread.

If you still do it, AutoIt crashes or never stops running.

But you can call GetMessage sporadically, that's OK.

Regards

Greenhorn

Share this post


Link to post
Share on other sites

You missed the point entirely. The OP wasn't creating a message loop, he was attempting to get messages for a window that belonged to another program.

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