Hi, I am a totally newbie to KM but have been reading through the forums trying to familiarize myself with how this works. I was hoping someone with more advanced knowledge could help me understand the right questions to ask or how to build the macro I need.
I am running an audio app on Mac OS12.6 which has windows that i've spread across 3 monitors. One of the monitors is my iPad, which is running Duet to function like a touchscreen monitor. I use the touchscreen to trigger changes on the fly when I'm working. The only problem that i haven't been able to fix is how to get my mouse cursor to go back to it's prior location on the main screen after I touch the touchscreen.
Currently, I hit the touchscreen to trigger the change i need and then i have to manually move the mouse cursor back to where I am working. the Touchscreen is currently only doing this one function so my goal would be to have a macro that knows an absolute location, say in the middle of my main monitor, and anytime i touch the touchscreen monitor, the cursor immediately jumps back to where it was before and focuses the program to that main window again. Hopefully this would mean that touching the touchscreen itself would trigger the macro to move the mouse back to it's prior location.
Please let me know if i'm not explaining that well. Again, I don't quite know the correct questions to ask yet.
Thanks!
Hey there! When you touch the iPad screen, is it always the same app window you’re interacting with? Because if it’s the same window (and therefore the same window name) in the same app, then you could use a combination of “when application activated” trigger and “if front window of X application title is/contains”, and then have it move the mouse to wherever you wanted it.
Hi @cdthomer, thank you very much for the response. I think what you're describing makes sense. I am only using the iPad to run one particular window that is within the main application i'm using. For example, the application is Reaper and the window is Reaticulate. Ideally, when i touch the touchscreen to select a new articulation in Reaticulate, the mouse would immediately return to the main Reaper window and activate the main window. i need to activate the main window again because basic functions like Play/Record don't trigger from within the Reaticulate window.
Hi Ryan,
I don’t have Reaper (nor Duet) to test anything on... but the sample macro below gives you an idea of how you might be able to accomplish this. Just adjust the things outlined in the yellow comment action and then test it. Let me know how it goes, whether it works or not, and we can go from there.
-Chris
Return mouse to original position after touching iPad screen.kmmacros (6.2 KB)
Macro Screenshot (click to expand/collapse)
Thanks Chris!
I can't post screen shots here can I? It'd be much easier to show than describe.
I am not 100% sure i implemented your macro correctly, but i imported it and checked the top checkbox "triggered by any of the following..." but left that as default This Application: Keybaord Maestro, Activates.
In the section below "If All Conditions Met Execute Actions". The ront window of Reaper, title contains Reaticulate, execute the following. Bring to front, the window with the index 1 in Reaper.
With those parameters i did not see any change in behavior.
No problem Ryan!
To post screenshots you can either use the share option from the menu bar (File > Share > Keyboard Maestro Forum
) or just drag and drop an image file in the text field of your replies here.
Either way, you’ll need to change the trigger from Keyboard Maestro to your application in question, Reaper.
Hi Chris, Thank you so much. sorry for my slow response. I've been in and out of town a bit. Here is a screenshot. I am sure i'm doing something wrong, but here is what the script looks like. Also, i captured my main Reaper screen and the Reaticulate screen so you can see what they look like. Reaticulate is the window that exists on my touchscreen/iPad. Thanks!
No worries Ryan, I to am slow to respond sometimes for that same reason haha.
It looks like the “main” window’s title contains the string “Registered to Ryan Franks”... if that’s always the case, then you could likely change the Bring window
action from window index
to windows with title containing
and put in that string (see screenshot below).
Action Screenshot (click to expand/collapse)
Hi Chris, i think there is some progress here! The mouse is not yet moving back to its original location, but the focus is shifting back to the main window, so commands like "record" work after using the touchscreen. Thank you! Can you tell me how to add commands that would put the mouse back where it was previously or simply to a fixed point on the main window? i tried to make a video to show how it's working but looks like i can't upload video here. When i touch the iPad, focus goes to Reaticulate the new articulation is chosen and/or written, then focus shifts back to the main window, but the mouse stays on the touchscreen. Thank you again for all your help!
Moving the mouse back to a set location is easy enough. For instance, the action in the screenshot below will move it back to the center of the main screen.
Action Screenshot (click to expand/collapse)
But in this case, to move it back to it’s original location is more complex because the macro is being triggered by you touching the iPad screen, which presumably moves the mouse as well. So there’s no way for this same macro to capture the original location of the mouse because by the time it’s triggered, the mouse has moved.
In other cases, where the macro is triggered through other methods, the following can be used to set and restore the mouse location.
Actions Screenshot (click to expand/collapse)
(I’ve renamed those actions since they’re part of my favorites actions library, but their original action names are “Set variable” and “Use variable”).
Hi Chris, i was out of town again and just got to test this. I'm not entirely sure what is happening. It's not working when I use Reaticulate. It does work, however, when i just hit "go" or "run" from the KM screen. I tried moving Reaticulate off of my touchscreen and on to the monitor where I have KM open and i get the same result. It seems to just get stuck on that Reaticulate screen. I am wondering if i need to insert a pause or something. I tried Main Screen Center, Front Window Center and Absolute Position. All 3 work when i hit "go" from KM. none work from Reaticulate oddly.
AH, and i'm just noticing a potential problem with the way I was shifting focus back to the main window. When I was testing this i was just looking at the touchscreen and the main window. I forgot that a lot of times when i'm using the touchscreen I'm actually in the MIDI editor which changes, but does have the words "MIDI take" in the name at all times. However, in my ideal application of this, the mouse would go back to whichever screen it had been on prior to touching the touchscreen. For now, i can change "Registered to Ryan Franks" to "MIDI Take:". That shifts the focus back to the MIDI editor window. But the mouse still stays on the last clicked position on the touchscreen.
Hi Chris, just wanted to check in and see if you had any thoughts on my questions. I'm a bit stuck still. Also, sorry, i think i forgot to respond to you so i'm not sure if you got my prior two posts.
Hey Ryan, sorry I’ve been tied up for several days. I don’t know that you’ll be able to move the mouse back to it’s original location in this case, because your method of triggering this macro is essentially the equivalent of moving the mouse (touching the iPad screen). So by the time the macro is triggered, the mouse has already moved. However, moving it back to a set point is very easy. You mentioned that was an option in an earlier post, is that still the case?
If you’re dead set on moving the mouse back to it’s original location before triggering this macro, then you could have another macro that saves the mouse position to a variable every so often, and then when this maro is triggered use that variable to move it back. But for this to be viable, that other macro would need to execute fairly frequently, which might be less than desirable.
![Screen Shot 2023-07-27 at 6.24.26 PM](https://forum.keyboardmaestro.com/uploads/default/original/3X/6/8/68f160450d0df4a8e6b345f3a5123a75eaf5a130.png)
Thanks Chris! That makes sense. For right now i think it would be fine to just pick a set point and return the mouse to that 1 location. Perhaps if we can get that to work, I could later add a manual trigger that would just the mouse location. Do you think that would work? For example, I know i'm going to be working in the MIDI editor on monitor #2, so i hit F6 to set the mouse cursor that location. I may occasionally also use the touchscreen when working from the Arrange window on monitor #1. in which case i could hit F7 so that the mouse would jump back to that location. However, at this point, i can't seem to get the mouse to jump back to any location. In 90% of the cases I'll be using the touchscreen while editing MIDI in the MIDI editor window which always has "MIDI Take" written at the top. I'd be happy if we could get the mouse to go back to that window after triggering the touchscreen. As of this moment, the focus will shift back to the MIDI window, but the mouse stays on the touchscreen, even though I added the command to move the mouse as you see in the attached image.
Moving the mouse to a specific location is simple. If it’s not working for you, it may be you need a pause between the if
and move
actions, or you may need to use a different scope in the move
action, such as relative to the absolute position
, or relative to the main screen
etc. I would recommend not using relative to the front window
because that front window might be changing during the macro’s execution. I recommend using absolute coordinates, or screen coordinates.
Hi Chris, I have it working intermittently, which is something. but it fails more than it works. I changed the "bring to front" to "last engine window" which seems to have the benefit of shifting focus back to whatever window i was working in, rather than to a window with a fixed title. about 1 time in 10 the mouse will jump back to the set location. i can't seem to find a pattern to when or why it moves versus the times when it doesn't. do you have any ideas?
PS, i wasn't sure if the actions should be broken up or all fit into a single action. I put the various commands into one action. though the result seems to be the same.
Hi, just wanted to follow up on this and see if there are any options. Thanks!
Hi Chris, I'm writing to follow up again. Unfortunately I haven't had a lot of luck, though it feels like i should be able to accomplish what i'm trying to do with this software. What if I try to simplify or break the actions into 2 at first? like a macro to shift focus, and a hotkey to move the mouse back to an absolute position? would you give me a head's up on how to just make a hotkey to move the mouse? i just made this little macro but it doesn't seem to do anything.