System Module
#system.rest system.rest(number msec)

Put the process to sleep for 'msec' milliseconds. This will "freeze" script execution for this duration.

Generally, it is a bad practice to use this for timing. The exact time it takes for the processor to return from this yield is not precise. It's also a bad idea to have any long pauses in your main loop, so use this function responsibly.

#system.exec string system.exec(string cmd)

Run the given command and return its output as a string.

While running the command, the script execution is paused until the command finishes. For example, the 'ping' command usually takes a few seconds to finish.

Example:
-- Run the ping command, as if you ran it from the console local pingData = system.exec("ping www.google.com"); print(pingData);
Example output:
Pinging www.google.com [172.217.4.196] with 32 bytes of data: Reply from 172.217.4.196: bytes=32 time=13ms TTL=55 Reply from 172.217.4.196: bytes=32 time=8ms TTL=55 Reply from 172.217.4.196: bytes=32 time=11ms TTL=55 Reply from 172.217.4.196: bytes=32 time=17ms TTL=55 Ping statistics for 172.217.4.196: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 8ms, Maximum = 17ms, Average = 12ms
#system.shellExec number system.shellExec(table execInfo)

Execute a system command or process when given a SHELLEXECUTEINFO structure. Returns the process ID to the newly started process.

'execInfo' should be a table of key/value pairs of only the values which you want to set. For example:

Example:
-- Opens a new Command Shell local data = { lpVerb = 'open', lpFile = 'cmd', lpDirectory = 'C:\\' }; local procId = system.shellExec(data);

You may use this function to start new programs that run independently of MicroMacro; this will not freeze the script execution at all since it will not wait for any output.

#system.getClipboard string system.getClipboard()

Returns the system clipboard data (What you copied when pressing CTRL+C/right-click copy) as a string.

#system.setClipboard boolean system.setClipboard(string data)

Sets the system's clipboard to 'data'. Returns true on success, false on failure.

#system.getActiveCodePage number system.getActiveCodePage()

Returns the system's current code page as an integer.

#system.getConsoleCodePage number system.getConsoleCodePage()

Returns the console's current code page as an integer.

#system.setPriority system.setPriority(string priority)

Change the process's priority. 'priority' should be "high", "low", or "normal" (default)

#system.repollHid system.repollHid()

Force a repolling of Human Input Devices (keyboard, mouse, gamepads). This refreshes the state for these devices so that any new input can be retrieved.

Typically you should not use this function unless you know what you are doing. Calling this function may result in input-related events not properly being triggered. There generally is no need for it as MicroMacro will repoll HIDs for you with every main loop cycle.

One potential use for this is when you need to get the new keyboard state within a long-running loop.

Example:
while(true) do -- Need to force repolling here so that our call to keyboard.pressed() works as expected system.repollHid(); if( keyboard.pressed(key.VK_ENTER) ) then doSomething(); end end

Page last updated at 2021-11-14 12:59:36


Copyright 2024