Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
Hi,

We are performing office automation(opening .doc,.wpd files and saving them as .html) in console application using Microsoft.Office.Interop.Word in C#.
When WPD file with graphic content is processed using the application,“WordPerfect 6.x - 7.0 Conversion" window is getting displayed and that window expects "Return" Key as input.Tried to send Return Key input automatically from application using the following methods:

Sendmessage
WinAPI.SendMessage(hWnd,WinAPI.WM_SYSCOMMAND, VK_RETURN, 0); //sending return key
WinAPI.SendMessage(hWnd,WinAPI.WM_SYSCOMMAND,SC_KEYMENU,'y') //sending Y key
WinAPI.SendMessage(hWnd,WinAPI.WM_SYSCOMMAND, VK_SPACE, 0) //sending space
//sending return key with WM_SYSKEYDOWN and WS_SYSKEYUP
SendMessage(hWnd, WM_SYSKEYDOWN, VK_RETURN , 0);
SendMessage(hWnd, WM_SYSKEYUP, VK_RETURN , 0);
WinAPI.SendMessage(hWnd,WinAPI.WM_SYSCOMMAND,WinAPI.SC_CLOSE,0);//to close the window

PostMessage
PostMessage(hWnd, WM_KEYDOWN, VK_RETURN, 0);
PostMessage(hWnd, WM_KEYUP, VK_RETURN, 0);

SendKeys
SetForegroundWindow(hWnd);
SendKeys.SendWait("Y");


Keybd_event
keybd_event(134, 0x45, KEYEVENTF_KEYDOWN | KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(13, 0x45, KEYEVENTF_KEYDOWN | KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(13, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(134, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0)

The above solutions are not working.However,we have similar implementation in the application to close "Show Repairs" and "Microsoft Office Word" (WinAPI.SendMessage(hWnd,WinAPI.WM_SYSCOMMAND,WinAPI.SC_CLOSE,0)) which works perfectly fine.
Can anyone help me in sending Return Key input to "WordPerfect 6.x -7.0 Conversion" window from C# code?

Thanks in advance,
Sivakumar
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900