Google docs & javascript & iMacros

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
tmallard
Posts: 5
Joined: Fri Nov 21, 2014 2:07 pm

Google docs & javascript & iMacros

Post by tmallard » Fri Nov 21, 2014 2:38 pm

Hi,

Using Google Sheet, I have been adding a script, which creates a submenu, this submenu entry executes javascript.
I would like to execute iimPlay from that javascript when I select the submenu entry from Google Sheet.


I get the following error : iimPlay is not defined.

What do I need to do?
Is it possible because it is not clear to me if javascript is executed on client side or server side in that case.

I am using iMacros 8.8.7 for Firefox.

Thks
skippyto
Posts: 108
Joined: Wed Aug 20, 2008 8:14 am

Re: Google docs & javascript & iMacros

Post by skippyto » Fri Nov 21, 2014 3:08 pm

Hi tmallard,

You can try with document.location :

Code: Select all

document.location = 'imacros://run/?m=myScript.js'
or

Code: Select all

document.location = 'imacros://run/?m=myMacro.iim'
But as it is a firefox addon, iMacros for firefox need to be installed in your firefox profil to run...

Skippyto.
tmallard
Posts: 5
Joined: Fri Nov 21, 2014 2:07 pm

Re: Google docs & javascript & iMacros

Post by tmallard » Fri Nov 21, 2014 3:45 pm

Sorry but I don't get it.

I stil get an error with 'document not defined'.
Do I miss sthg with the javascript syntax?


Here is my code, that is being called from Google Sheet submenu
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-scri ... preadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();

for (var i = 0; i <= numRows - 1; i++) {
var row = values;
Logger.log(row);
}

document.location = 'imacros://run/?m=PUC/SearchPlayer.iim'
};

/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the readRows() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-scri ... preadsheet
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Read Data",
functionName : "readRows"
}];
spreadsheet.addMenu("Script Center Menu", entries);
};


Thks.
tmallard
Posts: 5
Joined: Fri Nov 21, 2014 2:07 pm

Re: Google docs & javascript & iMacros

Post by tmallard » Fri Nov 21, 2014 4:30 pm

And, of course, I have iMacros addon for Firefox installed.
tmallard
Posts: 5
Joined: Fri Nov 21, 2014 2:07 pm

Re: Google docs & javascript & iMacros

Post by tmallard » Mon Nov 24, 2014 6:33 pm

Hi,

I changed my code to open URL from google scripts.
Trying to open http URL works fine, but trying to open imacros URL does not saying that URL is invalid.


Any help welcome.

Thks.


Here is my code:
function showURL(href){
var app = UiApp.createApplication().setHeight(50).setWidth(200);
app.setTitle("Show URL");
var link = app.createAnchor('open ', href).setId("link");
app.add(link);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}

/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-scri ... preadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();

for (var i = 0; i <= numRows - 1; i++) {
var row = values;
Logger.log(row);
}

showURL('imacros://run/?m=PUC/SearchPlayer.iim');

};

/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the readRows() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-scri ... preadsheet
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Read Data",
functionName : "readRows"
}];
spreadsheet.addMenu("Script Center Menu", entries);
};
Post Reply