1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.jameleon.plugin.jiffie.util;
21
22 import com.jacob.com.Dispatch;
23 import com.jacob.com.Variant;
24
25 public class IEUtility {
26
27
28 public static boolean sendKeys(String title, String keys, int maxWaitTimeInHundrendths) {
29 Variant[] argv = new Variant[1];
30 Dispatch wsh = new Dispatch("WScript.Shell");
31 argv[0] = new Variant(title);
32 int count = 0;
33 boolean windowFound = false;
34 while (!windowFound && count < maxWaitTimeInHundrendths) {
35 if (Dispatch.callN(wsh, "AppActivate", argv).toBoolean() == true) {
36 windowFound = true;
37 break;
38 }
39
40 try {
41 Thread.sleep(100);
42 } catch (InterruptedException ex) {
43
44 }
45 ++count;
46 }
47 if (windowFound) {
48 argv[0] = new Variant(keys);
49 Dispatch.callN(wsh, "SendKeys", argv);
50 wsh.safeRelease();
51 }
52 return windowFound;
53 }
54
55 }