User Submitted CoyoteScript

Queued Keystrokes

Author: Sander

Script Version: 1

Minimum CoyoteMIDI Build: 804

Executes all keystrokes and hotkeys sent by this script through a queue, ensuring different hotkeys aren’t being executed at the same time as others, but one at a time instead. For example, if you send “SHIFT+A’ in one translation, and just ‘A’ in another, at the exact same time, the script will first send ‘SHIFT+A”, and then make sure the second A is sent without shift still enabled.

This script adds the following translation parameters:
Keys: The keys that should be sent when this translation fires. Multiple can be specified, separated by a +. All keys listed in the same translation will be executed at the same time. Only keys sent by other translations are queued later.
				
					// Check if the 'keys' were specified when this script is ran from a translation.
enforcetrigger translation
if (mapkeys $parameters) !contains keys
    messagebox "No keys were specified!"
    return

// Get the keys to be executed out of the parameters.
$keys = (split ($parameters keys) "+")
// Add the keys to the queue.
%queued_keystrokes_queue + $keys

event uirefreshed
    // This adds the 'Keys' input box to any translation that has this script selected as an output.
    translationparameter keys (textbox Keys "The list of keys to be executed, separated by a +")

event scriptsloaded
    // Create a new empty list to serve as the queue of keystrokes.
    %queued_keystrokes_queue new list
    // make a new ID for the loop that checks for keystrokes in the queue.
    // This way we can stop the old loop when a new one starts.
    $loop_id = (guid)
    %queued_keystrokes_loop_id = $loop_id
    while %queued_keystrokes_loop_id == $loop_id
        // Add some delay in indefinite loops, so that they don't lock up the app.
        wait 0.05
        $queue = %queued_keystrokes_queue
        // Check if there's any keys in the queue.
        if (count $queue) > 0
            // Get the first keys in the list and remove them from the list.
            $keys = ($queue 1)
            %queued_keystrokes_queue - $keys
            // perform the key down on these first keys in the list.
            foreach $key in $keys
                key down $key
            wait 0.05
            // after a little bit of delay, perform the key up on these first keys again.
            foreach $key in $keys
                key up $key
				
			

2 downloads