im trying to make a automated tool for poulating textboxes with usernames for a dispatcher application at work.
Im having some problems trying to simultate key press, if the inputArrayX[i] array contains a,b,c
the keyboardsim will press abc, but if the Array contains a,b,b,c,c it still only types out abc, and not abbcc like i want it to do.
anyone have a clue what im doing wrong here?
private void MouseMacroChangeUser()
{
//move form to 0,0
this.Location = new Point(0, 0);
//set xy to mouse current pos
userMousePos();
//inputBlocker();
xX = int.Parse(this.Location.X.ToString());
yY = int.Parse(this.Location.Y.ToString());
defaultMousePos();
//Thread.Sleep(600);
Cursor.Position = new Point(Cursor.Position.X + 739, Cursor.Position.Y + 162);
//Thread.Sleep(100);
MouseSimulator.DoubleClick(MouseButton.Left);
for (int i = 0; i < inputArrayX.Length; i++)
{
string tempX = inputArrayX[i].ToString();
Keys keys = mapToKeyboardMacro(tempX);
KeyboardSimulator.KeyDown(keys);
}
KeyboardSimulator.KeyPress(Keys.Enter);
MouseSimulator.Click(MouseButton.Left);
//reset mouse to user pos.
Cursor.Position = new Point(x, y);
needUnblock = true;
//inputBlocker();
}
private Keys mapToKeyboardMacro(string key)
{
if (key == "space")
{
return Keys.Space;
}
else if (key == "a")
{
return Keys.A;
}
else if (key == "b")
{
return Keys.B;
}
else if (key == "c")
{
return Keys.C;
}
else if (key == "d")
{
return Keys.D;
}
}