Here are 2 standard programs on automating notepad & calculator applications that I found online. I am new to AutoIt and trying to learn this script and practice coding directly in eclipse (java) without using autoIt script editor and compiling etc.
Problem is while the Calculator code is running fine, the notepad application is not opening at all. In fact, notepad is showing as an application running in background in task manager, but is not displayed. I also tried the wordpad, it is also not opening.
In calculator code, winClose function is not working with window handle argument but accepting only window Title. Also the @SW_SHOW flag and other such arguments in winSetState function are not being recognized and stated as "cannot be resolved to a variable.
DO I need to import anything? The same problem is happening with Windows 8.1 (64 bit) and windows 7 (32 bit). I am using Eclipse Luna for Selenium WebDriver with TestNG.
Is the eclipse & java not compatible with all AutoItX functions?
package autoit_trial;
import java.io.File;
import org.testng.Assert;
import autoitx4java.AutoItX;
import com.jacob.com.LibraryLoader;
public class Calculator {
public static void main(String[] args) {
File file = new File("lib","jacob-1.18-M2-x64.dll");
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
/*
x.run("calc.exe");
x.winActivate("Calculator");
x.winWaitActive("Calculator");
x.controlClick("Calculator", "", "133");
x.sleep(1000);
x.controlClick("Calculator", "", "92");
x.sleep(1000);
x.controlClick("Calculator", "", "137");
x.sleep(1000);
x.controlClick("Calculator", "", "121");
x.sleep(1000);
String winhand = x.winGetHandle("Calculator","");
System.out.println(winhand);
x.winClose("Calculator","");
*/
x.run("notepad.exe");
String notepad = "Untitled - Notepad";
String testString = "this is a test.";
x.winActivate(notepad);
// x.winSetState(notepad, testString, @SW_SHOW);
x.winWaitActive(notepad,"",10);
x.send(testString);
Assert.assertTrue(x.winExists(notepad, testString));
x.winClose(notepad, testString);
x.winWaitActive("Notepad");
x.send("{ALT}n");
Assert.assertFalse(x.winExists(notepad, testString));
}
}
this is the error on running the code above
Exception in thread "main" java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:494)
at org.testng.Assert.assertTrue(Assert.java:42)
at org.testng.Assert.assertTrue(Assert.java:52)
at autoit_trial.Calculator.main(Calculator.java:39)