Hello,
I am writing some java code so that in the code, when an event happens, it opens Microsoft powerpoint from the program and then emulates some key presses which are defined in the code. My problem is that when I ask it to emulate a key press and pass in the decimal value of the key I want it to emulate, It does it wrong. The code is as follows:
public void test(String key) throws Exception{
int value = (int)key.charAt(0);
Controller c = new Controller();
Executer e = new Executer(c);
e.exec(c,"POWERPNT");
c.delay(5000);
c.emulateKeyTyped(97);
c.emulateKeyTyped(98);
The code above is meant to open Microsoft Powerpoint and emulate the keys 'a' and 'b' (whose ascii values are '97' and '98') but instead powerpoint prints '1' and '2' and I have no idea why this is. This is using powerpoint 2007. The odd thing is that if I replace the '97' by "KeyEvent.VK__A" (which is the same integer, ie. '97', since "KeyEvent.VK_A" returns an integer) then it prints the letter 'a' fine in powerpoint. The reason I want to use integers is because it is being passed in from another part of the program and also because I want to be able to emulate key presses other than just letters/numbers etc. (Also arrows etc.)
I'm not sure if the problem is in the code or if it something to do with the powerpoint 2007 but any help would be much appreciated.
Thanks in advance.
Thanks for the answes so far,
This works for a through to z but I still can't get it to work for other values such as ? etc.