<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.webos-internals.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Phil+bw</id>
	<title>WebOS Internals - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.webos-internals.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Phil+bw"/>
	<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/wiki/Special:Contributions/Phil_bw"/>
	<updated>2026-04-15T20:01:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>http://wiki.webos-internals.org/index.php?title=Komodo_Macro&amp;diff=9980</id>
		<title>Komodo Macro</title>
		<link rel="alternate" type="text/html" href="http://wiki.webos-internals.org/index.php?title=Komodo_Macro&amp;diff=9980"/>
		<updated>2010-05-19T19:51:59Z</updated>

		<summary type="html">&lt;p&gt;Phil bw: /* Useful Macros */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Macros show up in the toolbox panel on the right-hand side of the Komodo window. They can be used to automate almost everything in Komodo, and all the  Komodo add-on functionality is exposed to the macros.&lt;br /&gt;
&lt;br /&gt;
Since users are used to writing JavaScript for their Mojo applications all macros are written in JavaScript (Python is also allowed, but not documented).&lt;br /&gt;
&lt;br /&gt;
If you do not see the panel: '''View''' &amp;gt; '''Tabs &amp;amp; Sidebars''' &amp;gt; '''Toolbox'''.[[Image:Komodo_Toolbox_Macro.png|frame|right|Add a new Macro to the Toolbox]]&lt;br /&gt;
&lt;br /&gt;
== Macro Basics ==&lt;br /&gt;
&lt;br /&gt;
To create a new macro simply add your code to the starting script below&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
komodo.assertMacroVersion(2); // Macro Version&lt;br /&gt;
if(komodo.view &amp;amp;&amp;amp; komodo.view.scintilla)&lt;br /&gt;
{&lt;br /&gt;
    komodo.view.scintilla.focus(); // Sets focus&lt;br /&gt;
}&lt;br /&gt;
[... Your Script Here ...]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Deploy Functions ==&lt;br /&gt;
&lt;br /&gt;
The deploy functions will automatically toggle and animate the add-on to prevent conflicts. The functions automatically use the active project to perform operations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// Emulator Functions&lt;br /&gt;
ko.extensions.webos.emulator.packageInstallLaunch();&lt;br /&gt;
ko.extensions.webos.emulator.packageInstallInspect();&lt;br /&gt;
ko.extensions.webos.emulator.remove();&lt;br /&gt;
ko.extensions.webos.emulator.launch();&lt;br /&gt;
ko.extensions.webos.emulator.close();&lt;br /&gt;
// Device Functions&lt;br /&gt;
ko.extensions.webos.device.packageInstallLaunch();&lt;br /&gt;
ko.extensions.webos.device.remove();&lt;br /&gt;
ko.extensions.webos.device.launch();&lt;br /&gt;
ko.extensions.webos.device.close();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above functions can optionally be passed an object with onSuccess and onFailure property functions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // This means the function worked&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // This means the function failed, the UI will show this also.&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more customization you must use the base Palm functions listed below.&lt;br /&gt;
&lt;br /&gt;
== Macro Functions ==&lt;br /&gt;
&lt;br /&gt;
All functions are asynchronous, with onSuccess and onFailure callbacks. These are written to make more complicated tasks very simple to write into a macro.&lt;br /&gt;
&lt;br /&gt;
=== Check If Connected ===&lt;br /&gt;
&lt;br /&gt;
The first thing you need to determine is if the emulator or device is connected.&lt;br /&gt;
&lt;br /&gt;
==== Is Emulator Connected ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.isEmulatorConnected({&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Emulator was found&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Emulator was not found&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Is Device Connected ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.isDeviceConnected({&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Device was found&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Device was not found&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Check if the Project is a webOS Project ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
if(ko.extensions.webos.project.isWebOS)&lt;br /&gt;
{&lt;br /&gt;
    // It is!&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Palm Commands ===&lt;br /&gt;
&lt;br /&gt;
You may have never used the Palm command line since you are used to the add-on, but the following are what the quick buttons rely on:&lt;br /&gt;
&lt;br /&gt;
==== Generate Application ====&lt;br /&gt;
&lt;br /&gt;
This function is documented only to show the complete list of commands. It is recommended that you use the new project option in the emulator as this will only create the src/ contents.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.generateApplication({&lt;br /&gt;
    appInfo:{}, // The appinfo.json object&lt;br /&gt;
    path:&amp;quot;&amp;quot;, // Absolute file path. &amp;quot;C:\Folder&amp;quot; for instance&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Created a application at path&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Failed to create application template&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Package Application ====&lt;br /&gt;
&lt;br /&gt;
Package an application simply creates the ipk and places it into either the bin/release or bin/debug based on the framework_config.json settings.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.packageApplication({&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Created the ipk package file&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Failed to create package&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Install Application ====&lt;br /&gt;
&lt;br /&gt;
Install an application to the device or emulator. There are currently two options.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.emulator.cmdName&lt;br /&gt;
ko.extensions.webos.device.cmdName&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you pick a device or emulator to install to you must select an ipk. If you do not select an IPK it is automatically populated with the current project's ipk based off framework_config.json and appinfo.json.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.installApplication({&lt;br /&gt;
    device:ko.extensions.webos.emulator.cmdName,&lt;br /&gt;
    path:&amp;quot;&amp;quot;, // OPTIONAL: Absolute path to ipk file.&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // &lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // Test&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Launch Application ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.launchApplication({})&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Close Application ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.closeApplication({})&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Remove Application ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.palm.removeApplication({})&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Editing &amp;quot;appinfo.json&amp;quot; ===&lt;br /&gt;
&lt;br /&gt;
Need to read in the appinfo.json or save property changes through commands. Like all commands these are asynchronous, meaning they won't cause Komodo to freeze while they are being run. &lt;br /&gt;
&lt;br /&gt;
==== Getting the Object ====&lt;br /&gt;
&lt;br /&gt;
To get the active project's &amp;quot;appinfo.json&amp;quot; into an object simply call the function below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.project.getAppInfo({&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // this.json contains the object while this.text contains the contents&lt;br /&gt;
        alert(this.json.version); // or any other property.&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // this.errorCode == 1, this.error == &amp;quot;Error: Failed to load appinfo.json&amp;quot;&lt;br /&gt;
        // this.errorCode == 2, this.error == &amp;quot;Error: Failed to parse appinfo.json&amp;quot;&lt;br /&gt;
        alert(this.error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Saving the Object ====&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;appinfo&amp;quot; property contains either the full appinfo.json or partial properties. Make sure that overwrite = false or the entire appinfo.json will be overwritten.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ko.extensions.webos.project.setAppInfo({&lt;br /&gt;
    overwrite:false, // Completely overwrites file&lt;br /&gt;
    appinfo:{},&lt;br /&gt;
    onSuccess:function()&lt;br /&gt;
    {&lt;br /&gt;
        // this.json contains the object while this.text contains the contents&lt;br /&gt;
        alert(this.json.version);&lt;br /&gt;
    },&lt;br /&gt;
    onFailure:function()&lt;br /&gt;
    {&lt;br /&gt;
        // this.errorCode == 1, this.error == &amp;quot;Error: Failed to load appinfo.json&amp;quot;&lt;br /&gt;
        // this.errorCode == 2, this.error == &amp;quot;Error: Failed to parse appinfo.json&amp;quot;&lt;br /&gt;
        alert(this.error);&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Editing &amp;quot;framework_config.json&amp;quot; ===&lt;br /&gt;
&lt;br /&gt;
Need to read in the &amp;quot;framework_config.json&amp;quot; or save property changes through commands. Like all commands these are asynchronous meaning they won't cause Komodo to freeze while they are being run.&lt;br /&gt;
&lt;br /&gt;
==== Getting the Object ====&lt;br /&gt;
&lt;br /&gt;
[Will type up shortly]&lt;br /&gt;
&lt;br /&gt;
==== Saving the Object ====&lt;br /&gt;
&lt;br /&gt;
[Will type up shortly]&lt;br /&gt;
&lt;br /&gt;
=== Useful Macros ===&lt;br /&gt;
&lt;br /&gt;
If you find a useful macro list it below.&lt;br /&gt;
&lt;br /&gt;
===== One touch save/debug/launch to emulator =====&lt;br /&gt;
====== Submitted by phil_bw ======&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
//One touch save/debug/launch to emulator macro.  This macro is useful if it's assigned to a key such as F5.&lt;br /&gt;
komodo.assertMacroVersion(2);&lt;br /&gt;
if (komodo.view &amp;amp;&amp;amp; komodo.view.scintilla) { komodo.view.scintilla.focus(); }&lt;br /&gt;
komodo.doCommand('cmd_save') //Save&lt;br /&gt;
if(ko.extensions.webos.project.isWebOS){&lt;br /&gt;
    ko.extensions.webos.palm.isEmulatorConnected({&lt;br /&gt;
        onSuccess:function()&lt;br /&gt;
        {&lt;br /&gt;
            ko.extensions.webos.view('jslint'); //Debug&lt;br /&gt;
            ko.extensions.webos.emulator.packageInstallLaunch(); //Launch&lt;br /&gt;
        },&lt;br /&gt;
        onFailure:function()&lt;br /&gt;
        {&lt;br /&gt;
            alert(&amp;quot;Emulator not found.&amp;quot;)&lt;br /&gt;
        }&lt;br /&gt;
    });&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
    //If you use Komodo Edit for non-webos projects you can add what you want to happen after save here&lt;br /&gt;
    //For example if you do web development the following command will show a preview after the project is saved&lt;br /&gt;
    //komodo.doCommand('cmd_browserPreview') &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil bw</name></author>
	</entry>
</feed>