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:

Firstly, whoever set autoamtic lock at one minute clearly has a low understanding of security. Make security controls too painful, people will find a way, so here we all are.

I don’t understand how interleaving gui mouse movement works? I’m assuming this is pseudocode?

<gui action to move mouse one pixel right>

I meant this:

2 Likes

This is terrific. We have the same issue at work. A machine that we use for Teams conference calls will go to sleep unless we deploy someone to sit next to it just to shake the mouse periodically. I bought a mouse jiggler online fairly cheaply and it does the job.

Thanks for this but I am getting an error.

Error at jiggle start 1/3/6: Variable not found: jigglerActive)
> 3 | if ($jigglerActive) break
>   |      ^

I do see the jiggle happening however. But I keep getting an error (ERR on the LED display)

It eventually works. It seems the $jigglerActive does eventually get set, but the error keeps appearing until I resave something to the keyboard to “reset” it.

I feel like the keyboard needs to declare this variable during onInit or something before it can safely start the jiggle.

But do we really need that guard? If the user hits the key that the starts the script multiple times while the loop is active, do we risk running multiple loops if there is no guard to break early if the jiggler is active?

BTW, how do I clear the error msg on the LED display without resorting to resaving the keyboard config?

It suffices to initialize jigglerActive in your $onInit macro (setVar jigglerActive 0).

1 Like