How to create action steps in AppleScript

Note: AppleScript is deprecated as of Indigo 7.4

The following AppleScript code snippit illustrates how to make action steps using AppleScript.

tell application "IndigoServer"
	set actionGroupName to "New Action Group from AppleScript"
	-- First, we create a new action group. It could also be a trigger action or time date action
	make new action group with properties {name:actionGroupName}
	
	-- Because Action Groups, Trigger Actions, and Time Date Actions can all have multiple
	-- Action Steps, the AppleScript terminology to address each step is a bit
	-- strange. Think of it as an array of action steps.
	--
	-- If you create a time date action or a trigger action, one empty action step created 
	-- automatically, so you'll want to set that one up first. However, if you're creating an
	-- Action Group, you have to create the first step yourself. In this example, we'll have it 
	-- toggle the state of a light.
	--
	-- This step is necessary because it's an Action Group and they don't have
	-- a step created when they are created.
	make new action step of action group actionGroupName
	-- The rest of these steps are common regardless of which type you create
	set action type of action step 1 of action group actionGroupName to controlLightOrAppliance
	set device name of action step 1 of action group actionGroupName to "Office Lamp"
	set device action of action step 1 of action group actionGroupName to toggleDevice
	
	-- Create another action step, which is synonymous with clicking the 
	-- "Add New" button on any Actions or Action Group definition tab. Here,
	-- we'll pass in a list of properties so we can do it all in one statement.
	-- And, for this step, we'll have it set a variable.
	make new action step of action group actionGroupName with properties ¬
		{action type:modifyVariable, variable action:setValue,  ¬
		variable name:"tempVar", variable value:"variable value here"}
end tell
as_create_action_steps.txt · Last modified: 2020/04/02 21:40 (external edit)
 

© Perceptive Automation, LLC. · Privacy