PEscobar

Can I make coordinates relative to a window instead of a screen?

5 posts in this topic

Can I make it so that when I put MouseClick("left", 300, 200), it will click those coordinates on a window so if I run it on a different computer or move the window, it will still click on the same spot.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

AutoItSetOption("MouseCoordMode",2) for client

AutoItSetOption("MouseCoordMode",0) for window

But a Control based click will be more effective, and doesn't need an X/Y coord at all.  ControlClick.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Tysm! But I think I have to stick with mouseclick

Share this post


Link to post
Share on other sites

_WinAPI_ScreenToClient and _WinAPI_ClientToScreen

Convert the whole screen coordinates to the coordinates inside the client window and vise versa.

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

  • Similar Content

    • Fuzy
      By Fuzy
      #include<img/img.au3>
      #include <AutoItConstants.au3>
      Func Skype()
      $coords = imageSearch(0,0,-1,-1,"Skype.PNG")
      MouseMove($coords[0],$coords[1])
      [when it find the skype icon i want it to move from these coordinates, but of insted of moving to an expecific coordinate i want it to move down from these coordinates, (there is multiple images so i cant move to an specific image)] -- Kinda having trouble telling what i want cuz english isnt my first language, sorry about that. ;X
      MouseClick($MOUSE_CLICK_LEFT)
    • ags911
      By ags911
      I have a script that has to work on multiple resolutions but each resolution has slightly different co-ordinates due to automatic UI scaling. I have had to make separate files for each but would like to implement them all in one script. I have a similar program written for Java which uses else if statements to use different co-ordinates for each resolution after it has been detected. I'm not good with Java so I would like to implement this on AutoIt before later making a Java version.
       
      This is a snippet of the autoit code I have.
      ToolTip("1 - Search")
      MouseClick("Left", @DesktopWidth *0.823, @DesktopHeight *0.925, 1, 25)
      ToolTip("2 - Buy Now")
      MouseClick("Left", @DesktopWidth *0.83, @DesktopHeight *0.798, 1, 27)
      ToolTip("3 - OK")
      MouseClick("Left", @DesktopWidth *0.555, @DesktopHeight *0.596, 1, 15)
      ToolTip("4 - OK Clear Error")
      MouseClick("Left", @DesktopWidth *0.49, @DesktopHeight *0.597, 1, 30)
      ToolTip("5 - Back to Search")
      MouseClick("Left", @DesktopWidth *0.161, @DesktopHeight *0.108, 1, 15)
       
      This is a snippet of a java code I used.
      Thanks.
      private static void goToSearch(double maxX, double maxY, Robot bot) throws InterruptedException {     int currentX = 0;     int currentY = 0;     if (maxX == 2650 && maxY == 1440) {         currentX = 734;         currentY = 1316;     } else if (maxX == 1920 && maxY == 1200) {         currentX = 551;         currentY = 1096;     } else if (maxX == 1920 && maxY == 1080) {         currentX = 551;         currentY = 1042;     } else if (maxX == 1680 && maxY == 1050) {         currentX = 482;         currentY = 959;     } else if (maxX == 1440 && maxY == 900) {         currentX = 413;         currentY = 822;     } else if (maxX == 1366 && maxY == 768) {         currentX = 392;         currentY = 741;     } else if (maxX == 1280 && maxY == 800) {         currentX = 367;         currentY = 731;
    • Docfxit
      By Docfxit
      This script created by Varian is getting an error saying Obfuscator support has been discontinued and replaced by Au3Stripper.
      He said:
      To help you with the coordinates, use this script and browse over the button or area that you wish to be clicked. Exit the script by pressing the Escape key. The information displayed on the exiting message box will be copied to the clipboard for you to paste into a text editor so that you can use it. Just make sure that you use the correct MouseCoord option (window/client). you should also make sure that the window size remains constant...this can be handled using the WinMove() function.
      Has anyone converted it to Au3Stripper or can you convert it?
      #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=\\TEST-PC\D$\Icons\Intellipoint-010.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Created by Varian L.Styles #AutoIt3Wrapper_Run_AU3Check=n #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt('PixelCoordMode', 2) Opt('MouseCoordMode', 2) Opt('TrayIconDebug', 1) Opt('TrayAutoPause', 0) #include <Misc.au3> _Singleton(@ScriptName, 0) ProcessSetPriority(@AutoItPID, 0) Global $wPos, $mPos, $mClientPos, $mWindowPos, $Text, $wTitle, $Color HotKeySet('{ESC}', '_Quit') While 1 Mouse_Coords() ;Sleep(10) WEnd Func _Quit() ToolTip('') $Text &= 'Mouse Position/Desktop: ' & $$mPos[0] & ',' & $$mPos[1] & @CRLF $Text &= 'Mouse Position/Window: ' & $mWindowPos[0] & ',' & $mWindowPos[1] & @CRLF $Text &= 'Mouse Position/Client: ' & $mClientPos[0] & ',' & $mClientPos[1] & @CRLF $wPos = WinGetPos('[ACTIVE]', '') $wTitle = StringLeft(WinGetTitle('[ACTIVE]', ''), 15) $Text &= '"' & $wTitle & '" Top-Left Coords: ' & $wPos[0] & ',' & $wPos[1] & @CRLF $Text &= '"' & $wTitle & '" Window Size: ' & $wPos[2] & ',' & $wPos[3] & @CRLF $Text &= 'Color: ' & Hex(PixelGetColor($mClientPos[0], $mClientPos[1]), 6) ClipPut($Text) MsgBox(0, 'Mouse Position Results', $Text) Exit EndFunc ;==>_Quit Func Mouse_Coords() Local $String Opt('MouseCoordMode', 1) $mPos = MouseGetPos() Opt('MouseCoordMode', 0) $mWindowPos = MouseGetPos() Opt('MouseCoordMode', 2) $mClientPos = MouseGetPos() $Color = 'Hex Color: ' & Hex(PixelGetColor($mClientPos[0], $mClientPos[1]), 6) $String &= 'Window Title: ' & StringLeft(WinGetTiTle('[ACTIVE]'), 25) & @LF $String &= 'Desktop X: ' & $mPos[0] & ' Y: ' & $mPos[1] & @LF $String &= 'Window X: ' & $mWindowPos[0] & ' Y: ' & $mWindowPos[1] & @LF $String &= 'Client X: ' & $mClientPos[0] & ' Y: ' & $mClientPos[1] & @LF ToolTip($String & $Color) EndFunc ;==>Mouse_Coords Thanks,
      Docfxit
    • Sandy89
      By Sandy89
      I am trying to drag and drop an item from listview on one side to the parent element in workspace. From list view I selected the text which I want to drag, but  I need to get the coordinates of the selected text.
      I thought of using MouseClickDrag command. is there any other way to do this?
       
    • Mr_Was_geht_sie_das_an
      By Mr_Was_geht_sie_das_an
      Hi,
      i wanna creat an _Imagesearch / Mousemove script for an 3D/FPS Game and have Problems with the mousemove.
       
      In the game like Curveball(2D) its still works but in games like Battlefield (3D) are the absolute coordinates not really helpfull.
      Someone have an idea or an Example for me ?