Skip to content

Instantly share code, notes, and snippets.

@NazCodeland
Last active May 4, 2024 19:52
Show Gist options
  • Save NazCodeland/8f1ab8c0c08e5c85cc523e0c582ee502 to your computer and use it in GitHub Desktop.
Save NazCodeland/8f1ab8c0c08e5c85cc523e0c582ee502 to your computer and use it in GitHub Desktop.
Mouse Cursor Position Switcher: This AutoIt script is designed to switch the mouse cursor position between two locations.
; Mouse Cursor Position Switcher: This AutoIt script is designed to switch the
; mouse cursor position between two locations. It reads the previously stored
; coordinates from a text file, moves the mouse cursor to these coordinates,
; and then updates the file with the current coordinates. This allows the mouse
; cursor to effectively ‘switch’ between two positions.
#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