Passing coordinates to another script and moving mouse only at specific axis


First of all thank you for this great tool, I was glad to find more convenient AHK alternative on macOS!

I have a few questions/requests:

  1. How to pass mouse coordinates to another script?

I'd want to have a script that saves current mouse position and moves mouse to different place. Then I'd want to trigger another script to return mouse to initial position, but the initial position is stored in another script.

Is there a way to pass variables like coordinate to another script?

  1. Move mouse only on X axis

I need a script, that only moves mouse to a specific X coordinate, so Y value stays the same, how can I achieve it?

Thanks in advance!


first trigger a "Save Mouse Position" action (in order to set/update the BTT variable "saved_mouse_position") , and then run a script (see example screen)
to save the BTT variable "saved_mouse_position" to your own variable

tell application "BetterTouchTool"
	set mouse_xy to get_string_variable "saved_mouse_position"
	set_string_variable "mouse_xy" to mouse_xy
end tell

Thank you I'll give it a try!

Thank you for your help! And how do I access this variable in another Trigger to move(drag) my mouse to that position?


you can use a Java script to set the BTT variable ("saved_mouse_position") and then call the trigger to restore the mouse position. This will move the mouse to that position.

// get saved mouse position and store to saved_mouse_position
// and call trigger: Restore Mouse Position
(async ()=> {

let varName = 'mouse_xy';
let mouse_pos = await callBTT('get_string_variable', {variable_name:varName})

let savedVarName = 'saved_mouse_position';
let result = await callBTT("set_string_variable", {
      variable_name: savedVarName,
      to: mouse_pos


1 Like