TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
emilio
NA
8
0
Sending key strokes to another application
Dec 13 2009 9:57 AM
hi i wanted to write a windows application that sends keyboard strokes to another application something like a virtual keyboard.
i researched the subject and read few articles.
i managed to find a code that partially works.
in the sample code above i'm trying to send strokes to a word file.
it workes partially in the first send and then it just stopps doing what it supposed to.
the code is:
// Get a handle to an application window.
[
DllImport
(
"USER32.DLL"
, CharSet =
CharSet
.Unicode)]
public
static
extern
IntPtr
FindWindow(
string
lpClassName,
string
lpWindowName);
// Activate an application window.
[
DllImport
(
"USER32.DLL"
)]
public
static
extern
bool
SetForegroundWindow(
IntPtr
hWnd);
IntPtr
wordHandle = FindWindow(
null
,
"New Microsoft Word Document.doc - Microsoft Word"
);
// Verify that
word
is a running process.
if
(wordHandle ==
IntPtr
.Zero)
{
MessageBox
.Show(
"
word
is not running."
);
return
;
}
SetForegroundWindow(wordHandle);
SendKeys
.SendWait(
"{a}"
);
any help will be appreciated.
Reply
Answers (
4
)
how to pass values between two user controls
About design pattern