Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to calculate lParam for SendMessage?

Status
Not open for further replies.

JustinEzequiel

Programmer
Jul 30, 2001
1,192
0
0
PH
Greetings helpful people,

We use a console (DOS) program that we can only access via Remote Desktop.

Since we already have (database) the data to input into the said remote console program, I was asked if I could automate the data entry.
(database is appended to daily)

I can get at the 'IHWindowClass' child window of the 'TSSHELLWND' parent window via FindWindow/FindWindowEx.

But PostMessage(cw, WM_CHAR, 65, 0), which works for local windows, is ignored by the IHWindowClass window.
What I found that works is

SendMessage(cw, WM_KEYDOWN, 0x00000041, 0x001E0001)
SendMessage(cw, WM_CHAR, 0x00000061, 0x001E0001)
SendMessage(cw, WM_KEYUP, 0x00000041, 0xC01E0001)

This works if I want to send the letter 'a'

My question is, how do I calculate lParam for any other character I wish to enter?

Currently, I'll be spying on messages and putting these into a lookup table.

Is there a simpler method?

WM_KEYDOWN nVirtKey:'A' cRepeat:1 ScanCode:1E fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000041 lParam:001E0001]
WM_CHAR chCharCode:'0061' (97) cRepeat:1 ScanCode:1E fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000061 lParam:001E0001]
WM_KEYUP nVirtKey:'A' cRepeat:1 ScanCode:1E fExtended:0 fAltDown:0 fRepeat:1 fUp:1 [wParam:00000041 lParam:C01E0001]

WM_KEYDOWN nVirtKey:'B' cRepeat:1 ScanCode:30 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000042 lParam:00300001]
WM_CHAR chCharCode:'0062' (98) cRepeat:1 ScanCode:30 fExtended:0 fAltDown:0 fRepeat:0 fUp:0 [wParam:00000062 lParam:00300001]
WM_KEYUP nVirtKey:'B' cRepeat:1 ScanCode:30 fExtended:0 fAltDown:0 fRepeat:1 fUp:1 [wParam:00000042 lParam:C0300001]
 
Thanks strongm

Looks like I'll have to use SendInput or keyb_event instead as I cannot get uppercase characters (among others) to work for the Remote Desktop application.
(works just fine when to a local app though)
 
You might also want to look at the Microsoft Terminal Services Control library (although the SendKeys method buried in that basically requires a parameter that is the same as WM_KEYDOWN's lParam, so you'd be back to figurin g out how to construct that (hint: I often use UDTs and LSet for this sort of thing ...)
 
Thanks strongm,

This is the first time I've heard of
"Microsoft Terminal Services Control library"
so I'll surely give it a look.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top