Arrrghmatey Posted July 26, 2005 Posted July 26, 2005 Hello, I am writing a script to work in an environment with no real mouse coordinates. The real cursor is underneath and the visible cursor is above. When the real cursor hits the sides of the box, it is warped to the center, but the visible cursor is not. So, when I use autoit, I am faced with many problems. I have solved most with using only relative mouse movements, but not all. When I manually move the mouse, I have no problems whatsoever. So is there a way to have autoit move the mouse and have it act as if a person was physically moving the mouse?
GaryFrost Posted July 26, 2005 Posted July 26, 2005 Look in the Help for MouseClick SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
therks Posted July 26, 2005 Posted July 26, 2005 MouseClick? Don't you mean MouseMove? That should act just the same as if you move your mouse. My AutoIt Stuff | My Github
Arrrghmatey Posted July 26, 2005 Author Posted July 26, 2005 Look in the Help for MouseClick<{POST_SNAPBACK}> I'm not entirely sure how this is supposed to help me. I KNOW how to move the mouse. However, autoit moves the mouse in a different way than the actual physical plastic mouse does. When I manually move the mouse the visible cursor behaves as expected. It does not do so when I have auto it do it. because the window I am working in has no true coordinates, I get the mouse position, then move it currentPos + X pixels so the visible cursor moves that many pixels. However, it behaves strangely (flying to the corner) at a certain limit. Again, this does not happen with the Manuel movement of the mouse.
GaryFrost Posted July 26, 2005 Posted July 26, 2005 (edited) use MouseCoordMode option and MouseClickMouseCoordMode 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 window1 = absolute screen coordinates (default)2 = relative coords to the client area of the active window@SaundersMouseClick --------------------------------------------------------------------------------Perform a mouse click operation.MouseClick ( "button" [, x, y [, clicks [, speed ]]] ) Parametersbutton The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".x, y [optional] The x/y coordinates to move the mouse to. If no x and y coords are given, the current position is used.clicks [optional] The number of times to click the mouse. Default is 1.speed [optional] the speed to move the mouse in the range 1 (fastest) to 100(slowest). A speed of 0 will move the mouse instantly. Default speed is 10. Edited July 26, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Arrrghmatey Posted July 26, 2005 Author Posted July 26, 2005 (edited) use MouseCoordMode option and MouseClick@Saunders<{POST_SNAPBACK}>Tried that. Like I said, the actual mouse cursor (the hidden one) is warped to the center when it hits the edges, so a relative movement that hits the edge is messed up, because it is warped halfway through moving. The only solution I have is moving it ONE pixel at a time in a loop but that seems like it would be rather slower than I need it to be.....UPDATE: does the same thing with moving it a single (relative) pixel at a time. I'm stumped on this one.... Edited July 26, 2005 by Arrrghmatey
GaryFrost Posted July 26, 2005 Posted July 26, 2005 give this a try and see what you think. #include <GuiConstants.au3> $GUI_WIN = GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2) $Button_1 = GuiCtrlCreateButton("&OK", 70, 210, 90, 40) $Button_2 = GuiCtrlCreateButton("E&xit", 230, 210, 90, 40) $Button_3 = GuiCtrlCreateButton("Test Mouse Click", (392/2) - 45, (323/2) - 20, 90, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 ConsoleWrite("_MouseClick Button 1" & @CR) Case $msg = $Button_2 ConsoleWrite("_MouseClick Button 2" & @CR) ExitLoop Case $msg = $Button_3 _MouseClick($GUI_WIN,"","Button1") _MouseClick($GUI_WIN,"","Button2") EndSelect WEnd Exit Func _MouseClick($TITLE, $TEXT, $CONTROLID) Local $MouseCoordModeBAK = AutoItSetOption("MouseCoordMode", 2) Local $POS = ControlGetPos($TITLE, $TEXT, $CONTROLID) MouseMove($POS[0] + 10, $POS[1] + 10, 4) MouseDown("left") Sleep(500) MouseUp("left") AutoItSetOption("MouseCoordMode", $MouseCoordModeBAK) EndFunc ;==>_MouseClick SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Valuater Posted July 26, 2005 Posted July 26, 2005 When I manually move the mouse, I have no problems whatsoever. So is there a way to have autoit move the mouse and have it act as if a person was physically moving the mouse?<{POST_SNAPBACK}>You could try this automation program too.... just to see http://www.autoitscript.com/forum/index.ph...024&hl=xpedite#Hope it helps8)
therks Posted July 26, 2005 Posted July 26, 2005 Out of curiousity, what exactly are you doing/using that has such strange behaviour? Warping the mouse around and such, that is. My AutoIt Stuff | My Github
seandisanti Posted July 27, 2005 Posted July 27, 2005 (edited) Tried that. Like I said, the actual mouse cursor (the hidden one) is warped to the center when it hits the edges, so a relative movement that hits the edge is messed up, because it is warped halfway through moving. The only solution I have is moving it ONE pixel at a time in a loop but that seems like it would be rather slower than I need it to be.....UPDATE: does the same thing with moving it a single (relative) pixel at a time. I'm stumped on this one....<{POST_SNAPBACK}>if you're passing the end of the screen with a normal mouse move, causing the mouse to then become centered, it sounds like your other program is running in a diff resolution than you expect. what i would suggest is to find out allowable dimensions by making a debugging script that just puts the coords of the mouse...you could make a function that upon a hotkey puts the mouse position to a file, then check your edges and hit the hotkey with mouse at edge, or easier, you could just add a tooltip to the mouse in an infinite loop (hotkey to stop) that displays the mouse coords. i've had to do that a few times... once you have the limits of your viewable window it's just a matter of making sure that none of your mousemove()'s go outside of those limits... Edited July 27, 2005 by cameronsdad
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now