Created
April 15, 2024 14:19
-
-
Save NazCodeland/5a9400258b5408714e0f37905478dfef to your computer and use it in GitHub Desktop.
Captures the current mouse position, reads a target position from a file, moves the mouse to the target position without delay.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <File.au3> | |
; Get the current coordinates | |
$currentCoords = MouseGetPos() | |
; The x and y coordinates should be saved on one line separated by a comma. Example: 200,400 | |
$newCoordsString = FileRead("./coordinates.txt") | |
; Close the file after reading | |
FileClose("./coordinates.txt") | |
; Split the string into an array using comma as the delimiter | |
$newCoords = StringSplit($newCoordsString, ",") | |
; Move the mouse to the new coordinates | |
MouseMove($newCoords[1], $newCoords[2], 0) | |
; Open the file for writing and overwrite the original coordinates | |
$file = FileOpen("./coordinates.txt", 2) | |
; Check if the file opened for writing OK | |
If $file = -1 Then | |
MsgBox(0, "Error", "Unable to open file.") | |
Exit | |
EndIf | |
FileWrite($file, $currentCoords[0] & "," & $currentCoords[1]) | |
; Close the file | |
FileClose($file) | |
Exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment