No internet connection
  1. Home
  2. How to

How move the Mouse to a position in an active Window

By Reuven Amiel @Reuven_Amiel
    2022-07-08 05:00:37.606Z2022-07-08 05:08:38.961Z

    Hi,

    I am trying to move the mouse to a Position Relative to an "active "Window" in Pro Tools using "Set Mouse Position" but goes relative to the Pro Tools window, what i have to add to indicate that is relative to the active window? .
    .I want something like "Mouse click relative to a UI Element" but moving the mouse there(no click needed).

    Thanks:)

    • 15 replies
    1. samuel henriques @samuel_henriques
        2022-07-08 11:52:02.826Z2022-07-08 14:33:34.623Z

        Hello Reuven,
        This should get you the first focused plugin for example.
        Then you can move the mouse focusedPluginPos.x and focusedPluginPos.y + the amount you need relative to the window.

        const focusedPlugin = sf.ui.proTools.windows.whoseTitle.startsWith("Plug-in").first
        
        const focusedPluginPos = focusedPlugin.frame
        

        Let me know if you get stuck

        1. Exactly - here it is including the mouse setposition action:

          const focusedPlugin = sf.ui.proTools.windows.whoseTitle.startsWith("Plug-in").first;
          
          const focusedPluginFrame = focusedPlugin.frame;
          
          sf.mouse.setPosition({
              position: {
                  x: focusedPluginFrame.x + 100,
                  y: focusedPluginFrame.y + 100,
              },
          });
          
        2. In reply toReuven_Amiel:
          Reuven Amiel @Reuven_Amiel
            2022-07-08 16:13:30.824Z

            Thank you Samuel and Christian,

            The Second script works,

            but if I use these 2 scripts as different 2 actions together in a macro do not...why? I just wondered as I believe the first script is to get or focused on the active window and the second script for moving the mouse to the position in the active window...

            const focusedPlugin = sf.ui.proTools.windows.whoseTitle.startsWith("Plug-in").first

            const focusedPluginPos = focusedPlugin.frame

            and

            sf.mouse.setPosition({
            position: {
            x: focusedPluginFrame.x + 100,
            y: focusedPluginFrame.y + 100,
            },
            });


            Now can I have it all in one Script or one single macro? lets say where I want to get and assign a trigger for 6 different positions in the active window without creating a folder with 6 independent macros for each position?

            Thank you guys for the help

            1. You can't break up the script into 2 different parts - and there's no need to do that either. See my comment below on templates if you wish to reuse code and to be able to insert values into the code.

            2. In reply toReuven_Amiel:
              Reuven Amiel @Reuven_Amiel
                2022-07-08 17:01:57.322Z

                Also I have a question I want to know, it is possible for us, and if yes the answer how to do it or how can I learn to do this:

                when you have a script where for example you can add different values or options and you want to see it when you add a value
                like this:

                But if you have this script like this where you could add X,Y values:

                sf.mouse.setPosition({
                position: {
                x: focusedPluginFrame.x + 100,
                y: focusedPluginFrame.y + 100,
                },
                });

                and then you add it as an action on a macro, you will have the action with the fixed values but not the options to type in any value

                What can I do to have my scripts showing up in action with options to add values and drop-down menus?

                1. Hi Reuven,

                  You'd need to look into creating templates - see:

                  https://www.facebook.com/watch/live/?ref=watch_permalink&v=633065107406660

                  1. Reuven Amiel @Reuven_Amiel
                      2022-07-08 17:46:49.969Z

                      Thanks, will check that.

                      now Now can I have it all in one Script or one single macro? let's say where I want to get and assign a different trigger for 6 different positions in the active window without creating a folder with 6 independent macros for each position?

                      will check the video of templates and presets...is the answer to this question there?

                      1. Yes I believe this is the answer to that question. A template is essentially a script that can have different variants of itself - each variant is called a preset. This means you only write the script once but can have many different presets with different input to the script, each preset can have its own triggers.
                        It's all explained in the video :)

                        1. Reuven Amiel @Reuven_Amiel
                            2022-07-08 18:16:18.842Z

                            Thank you, will watch the video and experiment with this.

                    • In reply toReuven_Amiel:
                      Reuven Amiel @Reuven_Amiel
                        2022-07-09 18:13:40.475Z2022-07-09 19:14:39.329Z

                        Hi,
                        Watched the video and could to the template and presets but when ad X and Y the values always go to the 100, 100, so I imagine the idea is to change that "100" where Idid to locationValue ...was in green so I do not know if that is even something deepr or a bit more complex that replacing it by a name and then at top of the script adding :

                        const locationValue = event.props.locationValue;

                        I did this using the script Christain gave us

                        const locationValue = event.props.locationValue;

                        const focusedPlugin = sf.ui.proTools.windows.whoseTitle.startsWith("Plug-in").first;

                        const focusedPluginFrame = focusedPlugin.frame;

                        sf.mouse.setPosition({
                        position: {
                        x: focusedPluginFrame.x + locationValue,
                        y: focusedPluginFrame.y + locationValue,
                        },
                        });

                        if I can get the right "source" script would help me a lot to understand this, i got the idea on the example of the video...but only had one data input, when this one has two and that may be very different... I do not know

                        I tried to check the Script on "mouse click relative to a UI Element" but the scrpt conversion is not good, or des not allowed me to see it fully...must be protected I guess

                        Thanksbold text****bold text

                        1. Almost there :)

                          sf.mouse.setPosition({
                              position: {
                                  x: focusedPluginFrame.x + locationValue.x,
                                  y: focusedPluginFrame.y + locationValue.y,
                              },
                          });
                          

                          Please see here how to quote code in the forum:

                          1. Reuven Amiel @Reuven_Amiel
                              2022-07-09 19:35:14.536Z

                              Awesome! checking now and will check that link too!

                          2. In reply toReuven_Amiel:
                            Reuven Amiel @Reuven_Amiel
                              2022-07-09 20:09:56.663Z

                              Great it worked!

                              thanks!

                              there is something I have in my mind... but want to ask you if this is possible first before even try to to this.

                              It is possible that Soundflow when I make a window active can read/catch or know which window is and automatically shows on a specific tablet a specific surface ?

                              1. Great! Yes you can use window triggers for this. It's better to ask that in a separate thread if you need help.
                                I'd also highly recommend checking out our learning SoundFlow playlist here if you haven't already:

                                https://www.youtube.com/playlist?list=PLKWpZOwx5Z3jxnpNo_dQPhDQNRwp7DCNj

                                1. Reuven Amiel @Reuven_Amiel
                                    2022-07-09 21:05:37.212Z

                                    Thank you..I will
                                    But this is super cool, save time and is way more neat