Move mouse cursor to next monitor

Hi,

It would be great to add a new action "Move Mouse Cursor to Next Monitor" under "Other Mouse Actions", similar to how we already have a "Move Window to Next Monitor".

Thanks!

Just checking.. Any updates here? I don't think it should be too difficult to implement. Otherwise I'd have to look for alternative options. Thanks!

1 Like

Move mouse to position.... should do what you're looking for.

Thanks for the reply @Caliguvara
Unfortunately that doesn't quite do what I want. What I need is an action that moves the mouse cursor like this:
Monitor 1 -> Monitor 2 -> Monitor 3 -> Monitor 1 -> etc.
I.e. not just a one-time movement to a specific position, but continuously cycling between monitors.

1 Like

Haven't used an external monitor in years, but with negative values in the position relative to the Botton right corner I think you should be able to achieve this :thinking: Then working with additional actions to get the other "jumps".

You can use the "Run Real Javascript action" and add some logic there to achieve this. Here is an example:

The example code (just very quickly hacked together, you'll need to adapt the coordinates)


(async() => {
let action =  {
    "BTTPredefinedActionType" : 153,
    "BTTMoveMouseToPosition" : undefined,
    "BTTMoveMouseRelative" : "0",
};


let currentMonitor = await callBTT('get_number_variable', {variable_name: 'currentMon'});

if(!currentMonitor) {
  currentMonitor = 0;

}

if(currentMonitor == 0) {
  action.BTTMoveMouseToPosition = "{100, 100}";
  await callBTT('trigger_action', {json: JSON.stringify(action)});
  currentMonitor = 1;
  returnToBTT('0');

}else
if(currentMonitor == 1) {
  action.BTTMoveMouseToPosition = "{200, 200}";
  await callBTT('trigger_action', {json: JSON.stringify(action)});
    currentMonitor = 2;
	returnToBTT('1');


}else
if(currentMonitor == 2) {
  action.BTTMoveMouseToPosition = "{300, 300}";
  await callBTT('trigger_action', {json: JSON.stringify(action)});
    currentMonitor = 0;
returnToBTT('2');

}
  await callBTT('set_number_variable', {variable_name: 'currentMon', to: currentMonitor});


})()



I'm here looking for the same exact thing—an action called "Move Mouse to Next Display and Center" and "Move Mouse to Previous Display and Center". Bonus points to BTT if they allow for wrapping too where continual presses of the shortcut key would cycle through the displays (e.g. on far right display would wrap to far left display).

@Andreas_Hegenberg I tried using your script but it just cycles the mouse position diagonally on my main display. Here's a GIF of what I'm seeing on my end: https://geigel.com/shares/Cdoc9i3

Further, my displays are setup this way in case that has any bearing on the script: https://geigel.com/shares/IlPcO7o

Any pointers and/or updates to the script achieve my desired functionality described above?

Thanks in advance!

AG3

Interested in this option too. For many of us, recording mouse position is not really viable because our monitor setup/arrangement will change between work and home.

I too would be interested in such an action.

Thanks.

There is no acceptable way to do this with current scripting capabilities.
"adapting the coordinates" will not work with monitors of different resolution or if the mouse changes monitor without using the script.

Example.

  • Monitor A is 2 times the resolution of monitor B.
  • Monitor B extends monitor A to the right (ie: A then B)
  • If mouse is in the center of monitor A or monitor B, we only need to move A/2 + B/2 horizontally to get to the center of the next monitor (our magic value).
  • If the mouse if on the left edge of monitor A, moving A/2 + B/2 to the right will keep us on the same monitor! Just more on the right side

There is also a problem if the mouse changes monitor without using the script.

Because of this limitations we need the ability to get the current active monitor and to get the current mouse position to be able to implement this with a scrip.
Getting the action to actually move the mouse would be better, though.

Here is another way to move the cursor. My monitors have different screen sizes so I used them.

(async() => {
let action =  {
    "BTTPredefinedActionType" : 153,
    "BTTMoveMouseToPosition" : undefined,
    "BTTMoveMouseRelative" : "0",
};

const focusedScreenHeight = await callBTT("get_number_variable", {
  variable_name: "mouse_screen_height"
});
const screens = {
  laptop: {
    height: 967,
    mousePosition: "{693.91, 490.40}",
  },
  monitorTwo: {
    height: 1080,
    mousePosition: "{2545.93, 570.86}",	
  },
};
let mousePosistion;

	
if (focusedScreenHeight === screens.laptop.height) {
  // focus on monitorTwo
  mousePosistion = screens.monitorTwo.mousePosition; 
} else if (focusedScreenHeight === screens.monitorTwo.height) {
  // focus on Laptop
  mousePosistion = screens.laptop.mousePosition; 
}

if (mousePosistion) {
  action.BTTMoveMouseToPosition = mousePosistion;
  await callBTT('trigger_action', {json: JSON.stringify(action)});
}  

})()
1 Like