473,587 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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">wor d to send</param>
public static void PrepareText (ref ArrayList data,
string word) {

INPUT inp;
inp = new INPUT();

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

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

char c = character[cont];

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

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

INPUT[] keys =
(INPUT[])data.ToArray(t ypeof(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 1583

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

Similar topics

1
5355
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 works fine). I am also trying to make this project capable of "Rearrange the keyboard" (example type "e" and "K" is sent to the application) by using...
0
2268
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. inp = inp; inp.ki.dwFlags |= KEYEVENTF_KEYUP;
6
15636
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 suggested simply queueing two click events, but this is not working for me, regardless of the delay I put between clicks. So give this as a click (where...
5
5099
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 the SendInput call always returns "0". Here is some of the code: Beginning of Code... static extern uint SendInput(uint nInputs, ref INPUT ...
1
1962
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 the SendInput call always returns "0". Here is some of the code: Beginning of Code... static extern uint SendInput(uint nInputs, ref INPUT ...
2
6415
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 keep getting a WIN32 errorcode of 6. I am simply trying to simulate the TAB key being pressed when the user presses the ENTER key in a custom control.
2
2136
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 needed by the SendInput. But the mouse clicks are always reported at the "current cursor location" (I am testing it with the notepad) irrespective...
1
2317
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 needed by the SendInput. But the mouse clicks are always reported at the "current cursor location" (I am testing it with the notepad) irrespective...
7
12986
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 were there. Please give me what was wrong in the following code. I simplified the code so that you can just copy it to a console app project, and...
0
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.