Jump to content

Dynamic mousemove


NiM
 Share

Recommended Posts

Hello, I am trying to figure out how to dynamically move the mouse to a certain spot in a window, no matter where the window is, and no matter the size of said window.

So far I have been able to get it to stay in the same spot but if you change the width of the window then it doesn't work any more.

This is what I have so far

$WW = 'AutoIt Help'
$WP = WinGetPos ($WW)
MouseMove ( 665 + $wp[0]  , 15 + $wp[1] )

Yes, I have looked on the forums, I found 1 thing, but it wasn't want I am looking for.

I want this (other then for the shear fact of knowing) for a little program I made at school that when ever you hit a predefined key, it pressed 'ctrl + u' (to underline) then moves the mouse to where the highlight button is, to underline and highlight.

If there is a better way to do highlight that wouldn't require the highlight button being pressed, then could I also be informed of that too?

Link to comment
Share on other sites

Maybe...

#include <GUIConstants.au3>

$WW = 'AutoIt Help'
$WPx = ""
$WPy = ""

$GUI = GUICreate($WW)
GUISetState()

While GUIGetMsg() <> -3
    
    $WP = WinGetPos ($WW)
    If $WP[0] <> $WPx Or $WP[1] <> $WPy Then
        MouseMove ( 50 + $wp[0]  , 15 + $wp[1] )
        $WPx = $WP[0]
        $WPy = $WP[1]
    EndIf
WEnd

8)

What does '<>' do?

Thank you for the help, but thats not exactly what I want it to do.

I need it to go with the width of the open window, (also I was just using the autoit help window just because)

There something in coding web pages where you use use a % for x y coords, so no matter where the window is on the screen, and the hight and width, it always goes for those same coords. (or at least thats what my friend told me) I am trying to do something like that

I am sorry I can't seem to be able to phrase my question very well =(

Edited by NiM
Link to comment
Share on other sites

> greater than

< Less than

<> different than

***********************

You need to set the mouse coordinates mode

MouseCoordMode <a href="http://" target="_blank"></a>Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window:

0 = relative coords to the active window

1 = absolute screen coordinates (default)

2 = relative coords to the client area of the active window

see help

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

MouseCoordMode. Thats what I have been using,

I can get the mouse to go to the same place when you move the window around, but if you resize it's width it stops going to the same place (well, it goes to the same place relative to the window, but not the place on the window I want it to go). How can I get the width into the equation?

Again, thank you for the help

Edited by NiM
Link to comment
Share on other sites

$pos = WinGetPos()

Then $pos[2] = Width and $pos[3] = Height

So if you want to click thirty pixels away from the right edge of a window it would look something like this:

$pos = WinGetPos('Firefox');Or whatever window...
MouseClick('left', $pos[2] - 30, $pos[2], $pos[1])

Is that sort of what you wanted?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Maybe...

#include <GUIConstants.au3>

Opt("MouseCoordMode", 0)        ;1=absolute, 0=relative, 2=client

$WW = 'AutoIt Help'
$WPx = ""
$WPy = ""

$GUI = GUICreate($WW, -1,-1,-1,-1, $WS_SIZEBOX  )
GUISetState()

While GUIGetMsg() <> -3
   
    $Wp = WinGetClientSize($WW)
    If $WP[0] <> $WPx Or $WP[1] <> $WPy Then
        MouseMove (  $wp[0] * .5  , $wp[1] * .5 )
        $WPx = $WP[0]
        $WPy = $WP[1]
    EndIf

WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

Maybe...

#include <GUIConstants.au3>

Opt("MouseCoordMode", 0)        ;1=absolute, 0=relative, 2=client

$WW = 'AutoIt Help'
$WPx = ""
$WPy = ""

$GUI = GUICreate($WW, -1,-1,-1,-1, $WS_SIZEBOX  )
GUISetState()

While GUIGetMsg() <> -3
   
    $Wp = WinGetClientSize($WW)
    If $WP[0] <> $WPx Or $WP[1] <> $WPy Then
        MouseMove (  $wp[0] * .5  , $wp[1] * .5 )
        $WPx = $WP[0]
        $WPy = $WP[1]
    EndIf

WEnd

8)

That is exactly what I want, Thank you so much
Link to comment
Share on other sites

Ok, not exactly what I am looking for because I can't seem to be able to fit it into mine, I will keep messing around with it, but is there a way to multiply it by a %? like if the window is 100% (maximized) then it goes to the point, but if its only like 30% then it still goes to the same place? (again, sorry I can't seem to word my question properly)

Link to comment
Share on other sites

could you use pixel colors to find the correct area?

do a pixel search on the whole screen? I could try that, Thanks for that idea. Currently thats what I am doing to see if its where I think it is, but the problem is it (it being the click not the pixel search) only works (where I want it to click) when the window is either maximized or in the top right of the screen and I want it so it can be anywhere on the screen of any size (really only the width is a problem)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...