
wangzhengbo
Active Members-
Posts
30 -
Joined
-
Last visited
Everything posted by wangzhengbo
-
Dose AU3_PixelSearch has bug in AutoItX 3.3.14.0?
wangzhengbo replied to wangzhengbo's topic in AutoItX Help and Support
See my post below. Thanks. -
Dose AU3_PixelSearch has bug in AutoItX 3.3.14.0?
wangzhengbo replied to wangzhengbo's topic in AutoItX Help and Support
package cn.com.jautoitx; import java.io.File; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinDef.POINT; import com.sun.jna.platform.win32.WinDef.RECT; /** * * * @author zhengbo.wang */ public class AutoItX { public static void main(String[] args) { File libFile = new File("lib/AutoItX3.dll"); System.load(libFile.getAbsolutePath()); AutoItXLibrary autoItX = (AutoItXLibrary) Native.loadLibrary(libFile.getName(), AutoItXLibrary.class); RECT rect = new RECT(); rect.left = 0; rect.top = 0; rect.right = 100; rect.bottom = 100; POINT point = new POINT(); autoItX.AU3_PixelSearch(rect, 0xFFFFFF, 0, 1, point); System.out.println("point.x = " + point.x + ", point.y = " + point.y); } protected static interface AutoItXLibrary extends Library { /** * Searches a rectangle of pixels for the pixel color provided. * * @param rect * position and size of rectangle. * @param color * Colour value of pixel to find (in decimal or hex). * @param shadeVariation * A number between 0 and 255 to indicate the allowed number * of shades of variation of the red, green, and blue * components of the colour. Default is 0 (exact match). * @param step * Instead of searching each pixel use a value larger than 1 * to skip pixels (for speed). E.g. A value of 2 will only * check every other pixel. Default is 1. * @param point * Return the pixel's coordinates if success, sets * oAutoIt.error to 1 if color is not found. */ public void AU3_PixelSearch(RECT rect, int color, Integer shadeVariation, Integer step, POINT point); } } I write a simple java program。You can download AutoItXDemo.zip and import it into eclipse and run it. The AutoItX contained in AutoItXDemo.zip is 3.3.12.0, and the output of the code is something like: point.x = 0, point.y = 45 but when i use AutoItX 3.3.14.0, invalid memory access error happened. AutoItXDemo.zip -
ControlClick not working when using AutoItX3
wangzhengbo replied to keys24's topic in AutoItX Help and Support
use AU3_MouseClick(), and it works well. I test it in java. Below is the java code: import cn.com.jautoitx.Misc; import cn.com.jautoitx.Mouse; import cn.com.jautoitx.Opt; import cn.com.jautoitx.Opt.CoordMode; import cn.com.jautoitx.Win; public class Test { public static void main(String[] args) { Misc.sleep(2000); Opt.setMouseCoordMode(CoordMode.RELATIVE_TO_ACTIVE_WINDOW); Win.activate("Untitled - Paint", ""); Mouse.click("LEFT", 200, 200, 1); } } The autoitx java library downloaded from http://sourceforge.net/projects/jautoitx/files/ -
ControlClick not working when using AutoItX3
wangzhengbo replied to keys24's topic in AutoItX Help and Support
Change "LEFT" param to "left" and have a try. The third param pass to ControlClick() is "", which control do you want to click? -
AutoIt loops/if-else/MsgBox etc in Python or Java
wangzhengbo replied to akshaypi22's topic in AutoItX Help and Support
use http://code.google.com/p/jautoitx/ -
There is no problem with AU3_WinGetPos function. I'm using java, see https://code.google.com/p/jautoitx
-
Au3_controlgettext returning memory address.
wangzhengbo replied to Sreeja's topic in AutoItX Help and Support
No neccessary. Just add the downloaded jar to your classpath. -
Au3_controlgettext returning memory address.
wangzhengbo replied to Sreeja's topic in AutoItX Help and Support
You can use jautoitx. Download it from http://code.google.com/p/jautoitx/downloads/list With jautoitx, you can get control text by call Control.getText(final String title, final String text, final String controlId) static method. -
ControlSend works from SciTE, not from C# ?!
wangzhengbo replied to Apostelman's topic in AutoItX Help and Support
Maybe you used wrong controlId in AutoItX.ControlSetText("My Window Title", "", "[NAME:MyTextBox]", "TEST"); -
Crash on using Au3_Controlgettext
wangzhengbo replied to SreeJayakumar's topic in AutoItX Help and Support
/** * Retrieves text from a control. * * When using a control name in the Control functions, you need to add a * number to the end of the name to indicate which control. For example, if * there two controls listed called "MDIClient", you would refer to these as * "MDIClient1" and "MDIClient2". * * @param title * The title of the window to access. * @param text * The text of the window to access. * @param controlId * The control to interact with. * @return Returns text from a control if success, returns null if failed. */ public static String getText(final String title, final String text, final String controlId) { final int bufSize = CONTROL_GET_TEXT_BUF_ZIZE; final CharBuffer controlText = CharBuffer.allocate(bufSize); getAutoItX() .AU3_ControlGetText(stringToWString(defaultString(title)), stringToWString(text), stringToWString(defaultString(controlId)), controlText, bufSize); return hasError() ? Win32.getControlText(Control.getHandle_(title, text, controlId)) : Native.toString(controlText.array()); } -
Crash on using Au3_Controlgettext
wangzhengbo replied to SreeJayakumar's topic in AutoItX Help and Support
You can use JAutoItX, download it from http://code.google.com/p/jautoitx/downloads/list -
Non Optional Params in AutoItx dll calls
wangzhengbo replied to bshoenhair's topic in AutoItX Help and Support
If you use java, you can use http://code.google.com/p/jautoitx/downloads/list -
What is the meaning of MouseClickDownDelay option?
wangzhengbo replied to wangzhengbo's topic in AutoItX Help and Support
I think this is a bug in AutoItX. Because i changed the MouseClickDownDelay to 2000 milliseconds, and there is no delay in AU3_MouseDown too. -
What is the meaning of MouseClickDownDelay option?
wangzhengbo replied to wangzhengbo's topic in AutoItX Help and Support
See example below: import java.io.File; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.WString; public class MouseDownDemo { public static void main(String[] args) { System.load(new File("AutoItX3.dll").getAbsolutePath()); AutoItX autoItX = (AutoItX) Native.loadLibrary("AutoItX3", AutoItX.class); System.out.println("Default value for MouseClickDownDelay is: " + autoItX.AU3_Opt(new WString("MouseClickDownDelay"), 10)); long start = System.currentTimeMillis(); autoItX.AU3_MouseDown(new WString("left")); long end = System.currentTimeMillis(); autoItX.AU3_MouseUp(new WString("left")); System.out.println("end - start = " + (end - start)); System.out.println(); // Change MouseClickDownDelay to 1 second System.out.println("Previous value for MouseClickDownDelay is: " + autoItX.AU3_Opt(new WString("MouseClickDownDelay"), 1000)); start = System.currentTimeMillis(); autoItX.AU3_MouseDown(new WString("left")); end = System.currentTimeMillis(); autoItX.AU3_MouseUp(new WString("left")); System.out.println("end - start = " + (end - start)); System.out.println(); // Change MouseClickDownDelay to 2 seconds System.out.println("Previous value for MouseClickDownDelay is: " + autoItX.AU3_Opt(new WString("MouseClickDownDelay"), 2000)); start = System.currentTimeMillis(); autoItX.AU3_MouseDown(new WString("left")); end = System.currentTimeMillis(); autoItX.AU3_MouseUp(new WString("left")); System.out.println("end - start = " + (end - start)); System.out.println(); } protected static interface AutoItX extends Library { public void AU3_MouseDown(WString button); public void AU3_MouseUp(WString button); public int AU3_Opt(WString option, int value); } } The output is: Default value for MouseClickDownDelay is: 10 end - start = 0 Previous value for MouseClickDownDelay is: 10 end - start = 0 Previous value for MouseClickDownDelay is: 1000 end - start = 0 The AU3_MouseDown dose not delayed. You can download MouseDownDemo.zip, it's contains all libs and src to run MouseDownDemo, it can be imported to eclise.MouseDownDemo.zip -
What is the meaning of MouseClickDownDelay option?
wangzhengbo replied to wangzhengbo's topic in AutoItX Help and Support
I can't understand the note "Alters the length a click is held down before release." in the help file. Is it means when i run something like below: var startTime = getTime(); AU3_MouseDown(); var endTime = getTime(); then (endTime - startTime) >= 10? -
Test steps: 1. Call AU3_Run("notepad.exe"), this will open notepad. 2. Call AU3_RunAsSet("username", "domain", "password") and then call AU3_Run("notepad.exe"), this will open notepad too. 3. Call AU3_RunAsSet("username", "domain", "wrong password") with wrong password, and then call AU3_Run("notepad.exe"), this time notepad cannot opened. 4. Call AU3_RunAsSet() to unset the RunAs details, and then call AU3_Run("notepad.exe"), this time notepad cannot opened. I even use AU3_RunAsSet("", "", "") to unset the RunAs details, but it also can not unset the RunAs details.
-
I add a simple demo, see below: import java.io.File; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.WString; public class WinWaitActiveTest { public static void main(String[] args) { int SW_SHOWNORMAL = 1; System.load(new File("AutoItX3.dll").getAbsolutePath()); AutoItX autoItX = (AutoItX) Native.loadLibrary("AutoItX3", AutoItX.class); /* Display and hide tooltip in one thread */ autoItX.AU3_ToolTip(new WString("Hello 2014."), 400, 200); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } autoItX.AU3_ToolTip(null, 400, 200); /* Call WinWaitActive in another thread */ Thread t = new Thread(new Runnable() { @Override public void run() { AutoItX autoItX = (AutoItX) Native.loadLibrary("AutoItX3", AutoItX.class); System.out.println("#1"); autoItX.AU3_WinWaitActive(new WString("[CLASS:Notepad]"), new WString("")); System.out.println("#2"); autoItX.AU3_WinWaitActive(new WString("无标题 - 记事本"), new WString("")); System.out.println("#3"); } }); t.start(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } autoItX.AU3_Run(new WString("notepad.exe"), null, SW_SHOWNORMAL); } protected static interface AutoItX extends Library { public int AU3_Run(final WString fileName, final WString workingDir, final Integer showFlag); public void AU3_ToolTip(final WString text, final Integer x, final Integer y); public int AU3_WinWaitActive(final WString title, final WString text); } } You can download WinWaitActiveBug.zip, and import it into eclipse. In the main thread, i called tooltip, and in another thread i called winWaitActive("[CLASS:Notepad]") and winWaitActive("无标题 - 记事本"). The first call of winWaitActive will return but the second is not. If I remove the tooltip call, winWaitActive("无标题 - 记事本") will return too. If you want to run the example, you must change the notepad title from "无标题 - 记事本" to "Untitled - Notepad" in the WinWaitActiveTest class. WinWaitActiveBug.zip
-
package cn.com.test; import cn.com.jautoitx.AutoItX; import cn.com.jautoitx.Misc; import cn.com.jautoitx.Win; public class TooltipBug { public static void main(String[] args) { // display tooltip at position (200, 100) AutoItX.tooltip("Hello, AutoIt.", 200, 100); Misc.sleep(2000); // hide tooltip AutoItX.tooltip(); Thread t = new Thread(new Runnable() { @Override public void run() { System.out.println("#1"); Win.waitActive("[CLASS:Notepad]"); System.out.println("#2"); System.out.println("'" + Win.getActiveTitle() + "'"); Win.setTitle("[CLASS:Notepad]", "Untitled - Notepad"); Win.waitActive("Untitled - Notepad"); System.out.println("#3"); } }); t.start(); } } AU3_WinWaitActive has bug in AutoItX 3.3.8.1 and 3.3.10.2. See java example above. Steps: 1. display tooltip in main thread. 2. hide tooltip. 3. start another thread, in this thread call AU3_WinWaitActive("[CLASS:Notepad]") and AU3_WinWaitActive("Untitled - Notepad") 4. Run "notepad.exe" in the windows command line. Results: AU3_WinWaitActive("[CLASS:Notepad]") will return, but AU3_WinWaitActive("Untitled - Notepad") is blocked. I think this is AU3_WinWaitActive's bug. If you run AU3_Tooltip and AU3_WinWaitActive in the same thread, there will no problem. You can download the required jars for the above java code from http://code.google.com/p/jautoitx/downloads/list JAutoItX-3.3.10.2-1.0.0-alpha.jar, commons-lang3-3.1.jar, jna-4.0.0.jar, and jna-platform-4.0.0.jar are required.