Sign in to follow this  
Followers 0
Rraney

Signals from AutoItX?

5 posts in this topic

#1 ·  Posted (edited)

Is it possible to recieve signals from AutoItX when it has finnished a command like MouseMove, MouseUp, or other command to move or toggle the mouse? the example shows my problem. While python is running, it tosses the MouseMove commands to AutoItX and continues on. Never knowing when the command has finnished.

What Im currently running into this problem in python scripts, see example script.

import win32com.client
o = win32com.client.Dispatch( "AutoItX3.Control" )

# ----------- Configure defaults for AutoItX -----------------

o.AutoItSetOption("PixelCoordMode",1) #make sure we are in absolute screen Coord mode


#========================
# MOUSE stuff
#========================

#   MoveMouse to location on screen
#   a check for negitives should be built to return an error
# -----------------------------------------------------------------------------
def MouseMove(x,y, speed = 10):

    print("Moving mouse to : " + str(x) + "," +str(y))
    o.MouseMove(x, y, speed)


#   MouseBox move mouse in box
# -----------------------------------------------------------------------------
def MouseBox(top_x, top_y, bottom_x, bottom_y, speed = 10):

    # a bit of debugging
    print ("Boxing mouse")

    MouseMove(top_x, top_y, speed)
    MouseMove(bottom_x, top_y, speed)
    MouseMove(bottom_x, bottom_y, speed)
    MouseMove(top_x, bottom_y, speed)
    MouseMove(top_x, top_y, speed)

    return


#  Move the mouse in boxes. 
for t in range(10, 300, 50) :
    MouseBox(t, t, t, t, 100)[/font]
Edited by Rraney

Share this post


Link to post
Share on other sites



Rraney,

Admittedly, I am not schooled in the vernacular of Python so I apologize if this post is not helpful.

When I ran the MouseMove command in VBA, I tested for any return value. Without fail, it returned a value of "1". That said, would it be possible to test for the value of "1" within your code like:

If (o.MouseMove(x, y, speed)) = 1 then

...continue code here

I've had problems with synchronicity using the AutoIt object in some of my programs as well. But these were due to limitations in the language, not because of AutoIt... and certainly not pilot error... I think???

Let me know if this works/helps or not!

Share this post


Link to post
Share on other sites

The problem as I see it, is that AutoItX returns a 1(True) when it receives the command to move the mouse, not after it has completed moving the mouse.

So in the example script i listed in post , script attempts to move the mouse in ever growing boxes, but as it runs, it just moves the mouse diagonally across the screen.

Admittedly I wouldn't have problems with this if I could somehow work out a timing system to let me know just how long it will take AutoItX to move the mouse from a point A to point B. But currently I can not figure out how to do it with out calling AutoItX to get the current Cursor location.

- Rraney

Rraney,

Admittedly, I am not schooled in the vernacular of Python so I apologize if this post is not helpful.

When I ran the MouseMove command in VBA, I tested for any return value. Without fail, it returned a value of "1". That said, would it be possible to test for the value of "1" within your code like:

If (o.MouseMove(x, y, speed)) = 1 then

...continue code here

I've had problems with synchronicity using the AutoIt object in some of my programs as well. But these were due to limitations in the language, not because of AutoIt... and certainly not pilot error... I think???

Let me know if this works/helps or not!

Share this post


Link to post
Share on other sites

Ignor me, I took the word of a coworker who and I just passed the error on to the board here with out reviewing it for errors. I found a slight error with it. All it does is draw a line. Duh.. Bad person I be' B)

# Move the mouse in boxes.

for t in range(10, 300, 50) :

MouseBox(t, t, t, t, 100)

should be:

# Move the mouse in boxes.

for t in range(10, 300, 50) :

MouseBox(1, 1, t, t, 100)

Works now. Sorry about the spam.

Share this post


Link to post
Share on other sites

Don't worry, it wasn't spam. Spam is pointless, you had an actual question.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0