Calling commands
Diatom/User guide/Calling commands

Calling commands and passing parameters

The distribution's base scripts and native components provide the call interfaces.

Call by name

ahk
GoSub({name: "starter_notepad"})
GoSub({name: "show_message", message: "Hello from another command"})

The receiver can read a custom field from this.

ini
[show_message]
type=f
code='''
MsgBox(this["message"])
'''

Pass any target-window or pointer fields that the called action needs explicitly.

Call a persistent script

Use ahkpost(target, function, args...) to send, or ahkcall(target, function, args...) to wait for a result. The target must expose its receiving endpoint.

ini
[call_service]
type=t
to=my_service
fn=show_text
ps=hello
auto=1

This requires a registered my_service command with a show_text function. auto can start an existing target definition when the receiver is unavailable.

Parameters and returns

ps normally carries one string. On the AHK receiving path, rv=js can decode JSON and psin=1 can expand an argument array. vr controls the main program's separate substitution stage.

The main program's synchronous return path primarily forwards type=t calls. General command submission does not automatically return a function's business result. Check the target's return contract before using synchronous calls for long-running work.

User guide

Loading the guide…