471,610 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

SendInput problem sending the letter Y

Hi

I've having a very strange problem using the SendInput API to send
text to other applications.
I've written the code and it seems to work well. I discovered a
strange problem: when I try to send the Y character to another
application, I got the following characters:

Y)

So a round bracket is added.
Here's the code I use. (I took inspiration from a post on MSDN by Paul
DiLascia)
Another thing I noticed: the problem happens only when I'm sending the
data to another application: if I'm sending text inside the same
application, it works fine.

If you like, I can send you a sample VS.NET solution.

Thanks.
Andrea

/// <summary>
/// Prepares the text to send
/// </summary>
/// <param name="data">The data.</param>
/// <param name="word">word to send</param>
public static void PrepareText (ref ArrayList data,
string word) {

INPUT inp;
inp = new INPUT();

inp.type = INPUT_KEYBOARD;
char[] character = word.ToCharArray();

for (int cont=0; cont < character.Length;
cont++) {

char c = character[cont];

//fixes double new line problem
ushort val = (ushort) c;

inp.ki.wScan = val;
inp.ki.dwFlags = KEYEVENTF_UNICODE; //
to avoid shift, etc.
data.Add(inp);
}
}
public static INPUT[] GetInputFromArray (ArrayList
data) {

INPUT[] keys =
(INPUT[])data.ToArray(typeof(INPUT));
return keys;
}

/// <summary>
/// Sends the keystrokes to the target applications.
/// </summary>
/// <param name="keys">The data.</param>
public static void SendKeystrokes (INPUT[] keys) {

if (keys==null) {
return;
}

int length = keys.Length;

if (length==0) {
return;
}

INPUT inp;
inp = new INPUT();

uint intReturn = SendInput((uint)length, ref
keys[0], Marshal.SizeOf(inp));

}
Dec 28 '06 #1
0 1504

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Matthew Kelly | last post: by
6 posts views Thread by Richard A. Lowe | last post: by
5 posts views Thread by Tim | last post: by
1 post views Thread by Tim | last post: by
2 posts views Thread by Gene Vital | last post: by
2 posts views Thread by kumar_subrahmanya | last post: by
1 post views Thread by kumar_subrahmanya | last post: by
7 posts views Thread by Sin Jeong-hun | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.