473,372 Members | 1,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 1566

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Kelly | last post by:
I have pulled together a VB.net project that hooks the keyboard (Ref. Paul Kimmel's hooking program) and allow the user to send "mouse right clicks" via the SendInpuut function (mouse emulation...
0
by: pclion | last post by:
i download a program: static void SendString(LPCTSTR str) { INPUT inp; memset(inp,0,sizeof(INPUT)); inp.type = INPUT_KEYBOARD; inp.ki.dwFlags = KEYEVENTF_UNICODE; // to avoid shift, etc....
6
by: Richard A. Lowe | last post by:
I'm using P/Invoke to call SendInput (using code culled from these newsgroups!) to send mouse events to a window. But I'm unsure how to send double-clicks. A VB6 article I saw on SendInput...
5
by: Tim | last post by:
Hello All, I am writing a program that checks for the NumLock status and turns the NumLock on if it is off. I'm not sure what I'm overlooking at this point, but the code will compile and run, but...
1
by: Tim | last post by:
Hello All, I am writing a program that checks for the NumLock status and turns the NumLock on if it is off. I'm not sure what I'm overlooking at this point, but the code will compile and run, but...
2
by: Gene Vital | last post by:
Hi All, I am trying to use the SendInput API call in C# to put a keypress in the keyboard buffer and have beeting my head against the wall all morning. Could someone help me out with this, I...
2
by: kumar_subrahmanya | last post by:
Hi, I am facing problems in sending mouse clicks via SendInput API. Mouse clicks are being sent but at the X,Y co-ordinates. I am mapping my monitor to the (0,0,65535,65535) virtual monitor as...
1
by: kumar_subrahmanya | last post by:
Hi, I am facing problems in sending mouse clicks via SendInput API. Mouse clicks are being sent but at the X,Y co-ordinates. I am mapping my monitor to the (0,0,65535,65535) virtual monitor as...
7
by: Sin Jeong-hun | last post by:
Hi. I need to simulate keyboard and mouse events. For the first step, I tried to move mouse using SendInput. But it didn't work. I searched all over the internet for an example, but only questions...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.