Mouse jiggler macro

I have a heavilly locked down Windows machine which is set to sleep after 1 minute of inactivity which is impossible to work on.

I’d like to create a macro for UHK that jiggles the mouse indefinately until MOD key is hit again. If this possible in any way with UHK? Like a macro with a for loop.

Yes, definitely possible with macro commands, although possibly a bit complicated. See firmware/doc-dev/user-guide.md at master · UltimateHackingKeyboard/firmware · GitHub and firmware/doc-dev/reference-manual.md at master · UltimateHackingKeyboard/firmware · GitHub

Something like:

setVar stopJiggler 0
if ($jigglerActive) break
setVar jigglerActive 1
loop:
<gui action to move mouse one pixel right>
<gui action to move mouse one pixel left>
delayUntil 50000
if ($stopJiggler) {
    setVar stopJiggler 0
    setVar jigglerActive 0
    break
}
goTo loop

And a macro to stop it:

setVar stopJiggler 1
2 Likes

This is the most amusing use case ever! :smiley:

That worked perfectly. Thank you!! :smiley:

Is there any way to activate and deactivate the script together with the status of Caps Lock? That way i’d have a “status symbol” showing when its active and not. I never use caps lock anyways :sweat_smile:

If you mean to steal the caps lock led for showing the status of the jiggler without actually activating caps lock, then no. What you can do is to override a per-key-RGB color of a specific key to show the status with set backlight.keyRgb.LAYERID.KEYID <number 0-255 (INT)> <number 0-255 (INT)> <number 0-255 (INT)>

Otherwise you sure can ifNotCapsLockOn tapKey capsLock at the beginning of the macro and ifCapsLockOn tapKey capsLock in the exit block.

If you mean you want to trigger it by caps lock state, then you can use the $onCapsLockStateChange macro event.

It’s a very useful use case. I have something for that too.

I created a keymap --- which when selected pushes the mouse around a little bit while displaying an animation on the LED display. So that’s how I can see whether it’s currently active.

The keymap is a copy of my normal keymap but runs the command call keepAlive in its $onKeymapChange --- macro.

One key Fn-ISO on my normal keymap switches to this keymap, and the same key Fn-ISO on the --- keymap switches back to my normal keymap. So I can use this key to toggle between mouse jiggling on/off.

The keepAlive macro pretty much looks like this:

setVar r 6
startloop:
ifKeymap --- setLedTxt 200 "`-'"
ifKeymap --- setLedTxt 200 "---"
ifKeymap --- repeatFor r startloop
keepalive:

A “moveMouse” command with “x”: 3, “y”: 0 (right 3 pixels)

ifNotKeymap --- goTo final
ifKeymap --- setLedTxt 200 "---"
ifKeymap --- setLedTxt 200 "}--"
ifKeymap --- setLedTxt 200 "-}-"
ifKeymap --- setLedTxt 200 "--}"

Then a “moveMouse” command with “x”: 0, “y”: 1 (down 1 pixel)

ifNotKeymap --- goTo final

Then a “delay” command with “delay”: 2000.
Then a “moveMouse” command with “x”: -3, “y”: 0 (left 3 pixels).

ifNotKeymap --- goTo final
ifKeymap --- setLedTxt 200 "---"
ifKeymap --- setLedTxt 200 "--{".
ifKeymap --- setLedTxt 200 "-{-"
ifKeymap --- setLedTxt 200 "{--"

Then a “moveMouse” command with “x”: 0, “y”: -1 (up 1 pixel)

ifNotKeymap --- goTo final

Then a “delay” command with “delay”: 2000.

ifKeymap --- goTo keepalive

final:
setLedTxt 800 "[-]"
setLedTxt 200 "[\\]"
setLedTxt 200 "[|]"
setLedTxt 200 "[/]"
setLedTxt 200 "[-]"
setLedTxt 200 "[\\]"
setLedTxt 200 "[|]"
setLedTxt 200 "[/]"
setLedTxt 200 "[-]"
setLedTxt 200 "[*]"
setLedTxt 200 "|_|"

The mouse moves are so subtle that I can normally just use the mouse normally even if jiggling is on. I will still be able to click buttons etc.

@kareltucek Would be great to have mousemove commands directly in the macro language. This makes the whole macro look cleaner, and easier to export and send to someone else or post here…

3 Likes

UPDATE: Figured it out, thanks for sharing!

@maexxx love this idea. A little confused with this part of it though

is onKeymapChange a macro that needs to be set up like onInit ?

Yes, exactly. It is run when you change to that keymap.

You could, of course, also run a similar keepAlive macro within the same keymap that you normally use, but the way I wrote the macro it will automatically terminate when you switch away from the special --- keymap.

Anyway, I am glad you sorted it out. Enjoy :slight_smile: