getExtendedKeyCodeForChar is wrongly typed:
Using this test class:
package test;
import iRobot.iRobot_Functions;
public class Test {
public static void main(String[] args) {
String admUsr = "HOMP\adm03!@";
iRobot_Functions irf = new iRobot_Functions();
irf.Wait(3000);
irf.Send(admUsr);
System.out.println(admUsr);
}
}
Using these functions:
package iRobot;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import java.io.IOException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class iRobot_Functions {
Robot r;
public void Wait(int i)
{
Robot r;
try {
r = new Robot();
r.delay(i);
} catch (AWTException ex) {
Logger.getLogger(iRobot_Functions.class.getName()).log(Level.SEVERE, null, ex);
}
}
// pressionar teclas
public void Press(int keyCode) {
try {
r = new Robot();
r.keyPress(keyCode);
r.delay(200);
r.keyRelease(keyCode);
r.delay(200);
} catch (AWTException ex) {
Logger.getLogger(iRobot_Functions.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Send(String s) {
if (null == s) return;
Robot r = null;
char[] chars = s.toCharArray();
try {
for (char c : chars) {
int code = c;
int keyCode = KeyEvent.getExtendedKeyCodeForChar(code);
r = new Robot();
r.delay(40);
r.keyPress(keyCode);
r.keyRelease(keyCode);
}
} catch (AWTException ex) {
System.err.println(ex.getMessage());
}
}
}
In system.out.println you are printing some HOMP \ adm03! @
But in Send is wrong wrong homp \ adm0312
Ignoring shifts and using HOMP instead of HOMP 1 instead of! 2 instead of @
Does anyone know how to fix this?