Jump to content


 

Help me with GETMESSAGE


8 replies to this topic

#1 nlhung

    Newbie

  • Members
  • 4 posts
  • Gender:Male

Posted 25 January 2012 - 07:14 AM

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!



#2 Richard Robertson

    uʍop-ǝpısdn

  • Full Members
  • PipPipPipPipPipPipPipPipPip
  • 9,223 posts
  • Gender:Male
  • Location:Kentucky, USA, Earth, Sol, Milky Way

Posted 25 January 2012 - 03:15 PM

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.

#3 nlhung

    Newbie

  • Members
  • 4 posts
  • Gender:Male

Posted 26 January 2012 - 03:11 AM

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!

#4 Richard Robertson

    uʍop-ǝpısdn

  • Full Members
  • PipPipPipPipPipPipPipPipPip
  • 9,223 posts
  • Gender:Male
  • Location:Kentucky, USA, Earth, Sol, Milky Way

Posted 26 January 2012 - 05:20 AM

Yes but you are missing parameters on GetMessage itself.

#5 nlhung

    Newbie

  • Members
  • 4 posts
  • Gender:Male

Posted 26 January 2012 - 05:34 AM

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?

#6 Richard Robertson

    uʍop-ǝpısdn

  • Full Members
  • PipPipPipPipPipPipPipPipPip
  • 9,223 posts
  • Gender:Male
  • Location:Kentucky, USA, Earth, Sol, Milky Way

Posted 26 January 2012 - 04:09 PM

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.

#7 nlhung

    Newbie

  • Members
  • 4 posts
  • Gender:Male

Posted 27 January 2012 - 02:04 AM

oh. I don't know it. thank Richard Robertson!

#8 Greenhorn

    Spammer!

  • Full Members
  • PipPipPip
  • 226 posts

Posted 01 February 2012 - 09:46 PM

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

#9 Richard Robertson

    uʍop-ǝpısdn

  • Full Members
  • PipPipPipPipPipPipPipPipPip
  • 9,223 posts
  • Gender:Male
  • Location:Kentucky, USA, Earth, Sol, Milky Way

Posted 02 February 2012 - 12:20 AM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users