The $onInit macro isn’t supposed to be assigned to a key; it just auto-runs when the keyboard power-cycles.
"setVar jigglerActive 0 disables the jiggler; setVar jigglerActive 1 enables it. So if you wanted it to be active when the UHK is power-cycled, you would set the $onInit variable to setVar jigglerActive 1."(pretend I didn’t say that)
BUT…
It’s probably not a good idea to have it run when the board starts, or to leave it running all the time. You’re kinda setting yourself up for all kinds of wacky issues if you do it that way. "That’s why the common $onInit usage is setVar jigglerActive 0;"(Derp again) you’d normally want to have the jiggler be stopped by power-cycling the UHK, in case it’s running when something goes wrong, or as a precaution if you just forgot it was running.
Manually starting the macro with a dedicated key is probably the best route. I’d also create another setVar stopJiggler 1 (I think?) macro to stop the jiggler when you don’t need it.
I’m terrible with macros though, so maybe someone will further help you with the proper way to set up the rest.
I use the below on my UHK60. It keeps Teams and my Mac alive.
The LED text only updates after the next iteration of the loop as there can be upto a minute delay to the LED text going back to your keymap (obviously if you don’t use QWM as your default or use more than one keymap you will need to tweak that)
JiggerOn mapped to FN2+N
setVar stopJiggler 0
if ($jigglerActive) break
setVar jigglerActive 1
setLedTxt 0 "JIG"
loop:
startMouse move left
delayUntil 50
stopMouse move left
startMouse move right
delayUntil 50
stopMouse move right
delayUntil 60000
if ($stopJiggler) {
setVar stopJiggler 0
setVar jigglerActive 0
ifKeymap QWM
setLedTxt 500 "QWM"
break
}
goTo loop
setVar jigglerActive 1 would only set the variable to 1 and would not start the loop. Putting this in $onInit would prevent the loop from starting when this macro is run because the version @breaker0tings wrote uses if ($jigglerActive) break to keep the loop from starting twice if the jiggler is already active.
$onInit would still need setVar jigglerActive 0, then you could add call jigglerActive to the end of $onInit to call the macro and start the loop.
Yes. All of this.
@Tunney’s script moves the mouse smoothly for a time, not a set number of pixels, which might be better for fooling Teams. I think I will update my version of the script to do it this way. 50 ms of mouse movement left, then right, would not be disruptive for most people.
Side note: It also might be worth noting here that MS Teams might not detect the jiggler script’s movement as computer use and might show you as inactive, even if this works to keep your screen awake. If that is the case, you would need to experiment with different ways to move the mouse using the script to find one that works for Teams. A quick google search for “mouse jiggler not working on teams” shows that a lot of people are actually reported as “away” while typing in and interacting with other MS products. Good luck!
Thanks for clearing that up. I don’t do a lot of stuff with smart macros because I can never remember how to structure it all.
I did mess with the mouse jiggler a while back with my UHK60s, but I don’t use it much. Taking a look at the macro I have, it’s pretty much the same as the one @breaker0tings is using, but I have the mouse movement tracing an “x” pattern in much shorter intervals.
As for fooling certain apps; I wonder if there’s a way to create multiple movement patterns and time intervals, and then set a way to cycle/randomize them? Idk if that’s something possible with smart macros or not.