1
votes

I want to send these messages to an application:

<00010> 00830BB8 S WM_GETDLGCODE
<00011> 00830BB8 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS
<00012> 00830BB8 P WM_PAINT hdc:00000000
<00013> 00830BB8 S WM_ERASEBKGND hdc:DD012964
<00014> 00830BB8 R WM_ERASEBKGND fErased:True
<00015> 00830BB8 P WM_TIMER wTimerID:1 tmprc:00000000
<00016> 00830BB8 S WM_GETDLGCODE
<00017> 00830BB8 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS
<00018> 00830BB8 S WM_GETDLGCODE
<00019> 00830BB8 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS
<00020> 00830BB8 P WM_PAINT hdc:00000000
<00021> 00830BB8 S WM_ERASEBKGND hdc:7601294E
<00022> 00830BB8 R WM_ERASEBKGND fErased:True

These are from Spy++. How do I send using the SendMessage/PostMessage function, using C#?

Edit.. Thank you guys for your replies! I solved my problem, thanks again!

2
No, you don't want to send all those messages. Some of them are messages sent by windows, some of them are responses from the messages sent. Some of them only make sense in the context of a Dialog. For instance GETDLGCODE returns data to the caller, if you're posting them that doesn't do anything. - Erik Funkenbusch
What are you trying to accomplish? - 500 - Internal Server Error
Please post the answer to your problem as an answer to this question to aid the community. - Nick Heidke

2 Answers

1
votes

I tried to send keys to an application, and I used the Spy++ to see the messages goes to this. Specifically I wanted to send arrow keys to the application. From the Spy++, I saw that sent the above messages. After I had tried everything, I sent in the application, the below messages:

PostMessage(handle, WM_KEYDOWN, (int)Keys.Down, 0x00140001);
PostMessage(handle, WM_KEYUP, (int)Keys.Down, 0xC0140001);

Now works properly! Thanks guys!

0
votes

You cannot send the messages related to painting the window. Only the system can send them. If you need to force a re-paint then you simply call InvalidateRect.

Timer messages you could probably post successfully.

The WM_GETDLGCODE messages you probably don't need to send since they don't have side effects.