News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

PostMessage Control

Started by bomz, July 02, 2011, 12:53:56 PM

Previous topic - Next topic

bomz

I send Message to alien window (not mine) with PostMessage is it possible to know this Message execute already or how many Message's in queue?

SendMessageCallBack don't work - the difference
Places (posts) a message in the message queue associated with the thread
calls the window procedure for the specified window

QuoteThere is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.

HKEY_LOCAL_MACHINE
   SOFTWARE
      Microsoft
         Windows NT
            CurrentVersion
               Windows
                  USERPostMessageLimit

The minimum acceptable value is 4000.

Using return value of POSTMESSAGE don't give result some messages lose
REATTEMPT:
invoke PostMessage, esi, WM_CHAR,edx,0
.if eax==0
add ATTEMPT, 1
.if ATTEMPT<=10
push edx
invoke Sleep, 1000
pop edx
jmp REATTEMPT
.else
mov ebx,1
.endif
.endif


this work but Sleep is not standby method
add MessCount,1
.if MessCount>=1024
invoke Sleep, 1024
mov MessCount, 0
.endif

dedndave

if you use SendMessage, you will know because the function does not return until the message has been processed
if you want to continue execution while the message is being processed, put the SendMessage in a seperate thread

Thrd    PROTO
;
;
        xor     eax,eax
        INVOKE  CreateThread,eax,eax,Thrd,eax,eax,eax
;
;
Thrd    PROC

        INVOKE  SendMessage,hRecWin,WM_SOMEMESSAGE,wParam,lParam
        INVOKE  ExitThread,0

Thrd    ENDP


you can use GetExitCodeThread to see if the thread has terminated
or you can set a semaphore flag after the SendMessage call

also, you can pass a parameter to the thread
it could be a pointer to a structure that contains the handle, message, wParam, and lParam

this method is also useful when sending messages that contain pointers as wParam or lParam
PostMessage does not work in these cases   :bg

bomz

sendmessage WM_CHAR don't work with WORD only postmessage. It's belong to SendMessageCallBack too

Places (posts) a message in the message queue associated with the thread
calls the window procedure for the specified window

dedndave

in that case, the only thing i can think of is using PeekMessage to see if the message you posted is still in the queue
that does not tell you that the message has been handled
it will tell you if it has been removed, though

bomz

PeekMessage work only with messages for YOURS window

QuoteA handle to the window whose messages are to be retrieved. The window must belong to the current thread.

bomz

May be try to send WM_CHAR post message for mine window too and wait it

dedndave

oh well   :P

QuoteMay be try to send WM_CHAR post message for mine window too and wait it

:dazzled:

bomz

No all windows have it's own queue 

bomz

queue overload may destroy system. my 8 year old computer lose about 60 message from 1 000 000. it's may be WM_CHAR but may be some system messages

qWord

what are you trying to do?  WM_CHAR won't work in all situations -you may need to change the method for simulation user input...
FPU in a trice: SmplMath
It's that simple!

hutch--

Sending messages to other applications in other threads is at best a risky business and there is no garrantee that it is supported by the operating system. If you want communication betqween two different applications, you need to write both of them yourself and use documented inter-process communication techniques.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

WM_CHAR work so - as application it execute.

supported. all work OK with different edit windows. accept cases when CHAR text bigger 5 000-6 000  symbols

dedndave

it sounds like you might be better off to put the data in the clipboard
and let the user paste it into the Word document

bomz


qWord

WM_CHAR is an internal message - there are several reason why you should not send it explicit. One is the fact, that all application assumes that they only will receive text, if they have the focus - this can cause unexpected behaviour of the target application.
FPU in a trice: SmplMath
It's that simple!