1

AutoIt seems to stop working when focus is given to a java application.

For this code:

MouseMove(61, 121, 10);
WinActivate("Main @ paperMoney [build 1800.20]");
MsgBox(0, "got it", "got it");

Results are --> Mouse moves, java application gets focus and message appears

For this code:

WinActivate("Main @ paperMoney [build 1800.20]");
MouseMove(61, 121, 10);
MsgBox(0, "got it", "got it");

Results are --> java application gets focus, mouse DOES NOT move and message appears.

Is there anything I can do to make the mouse and keyboard commands work after the java application has focus?

7
  • My guess it's because AutoIt doesn't allow for multiple threads, but I'm not 100% sure on this. Do you get any error messages? I've mainly used AutoIt the other way around: I create small AutoIt scripts that are called from within my Java Swing GUI to allow Java to interact more closely with the Windows OS -- mainly to drive another 3rd party application, a computerized medical records app. Consider creating a very small AutoIt script and a very small Java program that interact, that compile and run without other code or dependencies and that I can test, and I'll be able to better help you. Commented Mar 13, 2011 at 16:10
  • Also, do you check what WinActivate returns? It should be 1 for success and 0 for failure. And nevermind what I said about multithreading being an issue since the other window is run in a different process. Also is there anything else that your AutoIt program is doing? Is it a GUI or is it a simple script? Does it communicate with the Java application, perhaps via standard in and out or via sockets? Commented Mar 13, 2011 at 16:14
  • 2
    Also, should be using WinWaitActive to allow your script to wait for the Java application to be active before contining? Commented Mar 13, 2011 at 16:27
  • Thank you Hovercraft. You can see the entire script above ... three lines :). WinActivate returns a handle to the window: 0x0016045C. I tried using WinWaitActive as well as Sleep(3000) with no success. Commented Mar 14, 2011 at 2:19
  • I need to see a small Java program that this script is working with. When I did the equivalent of your script, it worked just fine with my Java app. So I don't see us coming up with a solution just based on the AutoIt script. Commented Mar 14, 2011 at 2:26

3 Answers 3

3

Considering what paperMoney does, it is probably purposely resisting automation. Especially when the Window is activated, it will hook into low-level mouse events and check all hardware mouse movement with actual movement. Using that it will prevent any simulated mouse movement. Can you use Send to type keys in the Window?

Sign up to request clarification or add additional context in comments.

3 Comments

agreed. we don't know what lengths their programmers will go to prevent automation. I tried "Send". It also doesn't work.
If send does not work, then I highly suspect that they're purposely resisting automation. You will have to dig very deep into their application by decompiling, reverse engineering and other forms of cracking. Make sure the license allows you to do this. This goes well beyond the scope of AutoIt though. Question answered?
By the way, you can eliminate WinActivate as the cause by starting your script with Sleep(5000) and then activating the window manually.
0

I looked to do the same thing. Mandanar is probably right. I also tried Autohotkey with no success. Perhaps TOS is prohibititng it deep in their application. :( Boo!

EDIT:
Some playing around I've discovered that TOS on Mac OSX can be controlled via scripting with Keyboard Maestro. It's a ugly, hacked solution, but it works. You can edit text boxes and click stuff if you know the X,Y position of elements.

Keyboard Maestro can be run via scrips (AppleScript, Python, etc.) so maybe you can build some elaborate rube goldberg.

Happy trading!

Comments

0

My solution was tested for AutoHotkey, but I believe this should work for AutoIt also. I ran the script with administrator privileges since TOS is ran as an administrator and my scripts work fine after that.

1 Comment

Where is your solution ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.