Sign in to follow this  
Followers 0
indigoblue

how to move the mouse in a certain window

9 posts in this topic

Can someone tell me how i move the mouse in a given window (ideally using the hwnd of the window.) I can't find a way to do this, I need to to do this because the window my macro is running in doesn't always have focus.

Thanks.

Share this post


Link to post
Share on other sites



Look at MouseMove ( x, y [, speed] ) function and Opt('MouseCoordMode') and WinGetPos()

If your window is active then use Opt('MouseCoordMode') = 0 --> relative coords to the active window

You may get pos oof your window and use MouseMove with position of window + relative position

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Look at MouseMove ( x, y [, speed] ) function and Opt('MouseCoordMode') and WinGetPos()

If your window is active then use Opt('MouseCoordMode') = 0 --> relative coords to the active window

You may get pos oof your window and use MouseMove with position of window + relative position

Unless i've misunderstood it that function is no good to me because it does not allow me to specify which window I want to send mouse movement to. I have tried using mousemove but when i click off the window and it looses focus the mouse movements are disrupted.

Please advise.

TIA.

Edited by indigoblue

Share this post


Link to post
Share on other sites

Otherwise use WinSetOnTop...

Share this post


Link to post
Share on other sites

Sorry.

I'll try to explain fuller - please accept apologies if i have been too vague.

I run five instances of the same program. The programs run on the desktop and are arranged so i can see them all at the same time, but obviously only one of them can have focus.

I have a seperate macro for each of the five instances which i need to run at the same time. So the problem isn't that I don't know how to make a window have focus. It is that at any one time there will be at least four windows that don't have focus that I want a macro to be running in.

I hope that has made it clearer.

TIA for any further advice.

Share this post


Link to post
Share on other sites

Well your mouse cant be in 5 places at the same time....


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

You need a single script to act as a dispatcher, timesharing between the instances of the application.

A faint hope for what you are trying to do might be something like _MouseMovePlus(). I've never used it, but I believe it was described as being able to do mouse movement and clicks inside minimized windows. So maybe that would work...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Yes, you need to only be running one script, but are you sure that you must use the mouse? Take a look at the Control functions like xcal mentioned. If you must use the mouse, then consider changing the title of each window as they startup so that you can control them individually.

WinSetTitle ()


[size="1"][font="Arial"].[u].[/u][/font][/size]

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