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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synthesizing KeyStrokes

Status
Not open for further replies.

abhijit123

Programmer
Sep 26, 2002
17
US
I am developed a dialog as a MFC DLL which i am invoking through a another application viz. Unigraphics. For the event of one of button clicks I want to open a sub-menu from parent window(unigraphics). The key short cut for it is Ctl + M or Alt + N + M.
The first option is not working through SendMessage.

However in second case if I use SendMessage with message as WM_SYSCOMMAND type,wParam as SC_KEYMENU and lParam as 'N', the Alt + N functionality is executed. But M keystroke is not getting synthesized.

Code: -

SendMessage(hWndUG,WM_SYSCOMMAND ,SC_KEYMENU,'n');
SendMessage(hWndUG,WM_KEYDOWN,0x4D,0);
SendMessage(hWndUG,WM_KEYUP,0x4D,0);

On non-mfc applications do only WM_SYSCOMMAND messages work? How do I sysnthesize non-system keys(without alt).
I tried keybd_event too without success. Currently for temporary purpose I am using a exe generated from Visual Basic. It works fine but it is a very crude way of performing this task. The VB code is:

Private Sub Form_Load()
AppActivate "Unigraphics"
SendKeys "%"
SendKeys "{N}"
SendKeys "{M}
Unload Me
End Sub

In VB too Ctl + M doesn't work. can anyone suggest a good solution!
 
MSDN : "If the wParam is SC_KEYMENU, lParam contains the character code of the key that is used with the ALT key to display the popup menu. For example, pressing ALT+F to display the File popup will cause a WM_SYSCOMMAND with wParam equal to SC_KEYMENU and lParam equal to 'f'."

So I think that WM_SYSCOMMAND is only used with Alt key, not with CTRL.
Couldn't you use another message, like WM_COMMAND, or WM_CONTEXTMENU or WM_RBUTTONDOWN?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top