1
votes

I am really new to programming, I tried looking for answers, but can't find any. Can somebody help me?

I want to create a script where you press a certain mouse button, the button will perform different keys with different timing. For example: I click the right mouse click, the following will be executed:

W-SPACE-SHIFT-W-W

I know how to do this, but how do you turn it into a script where the interval is different each time? Like I press the mouse button then this happens: W - (delay between 0.5 sec and 1 sec) - SPACE (delay between 0.5 sec and 0.7 sec) - SHIFT (delay between 0.3 and 0.35) etc.

I thought this was the start:

EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then

    --keyboard keys will be executed all with a random interval between the keys

    end
end

It's a really simple script, but I don't know how to make it work. Help would be really appreciated.

Good day,

-Joël

1

1 Answers

-1
votes

You can do this using AutoHotKey, listening for the RButton event and using the Sleep function to delay the kepresses. For example;

(Note: you could probably use variables with random delays using math functions)

RButton::
    Send, w
    Sleep, 500
    Send, {Space}
    Sleep, 500
    Send, {Shift}
    ; etc...
Return

Of course, you can do more advanced scripts than this, AHK is a really simple but advanced piece of software that you can use to do nearly anything (Including calling obscure DLLs). People have designed libraries to do anything you want with it as well.

This might not be Lua, but it might be what you are looking for! ;)