How to open a link with a different protocol than http - google-apps-script

I try to get a google spreadsheet to open my phone numbers in cell F as callto:// links, so that my voip-software can instantly call this number.
Unfortunately writing callto://number into the cells makes the spreadsheet guess that, the link is http:/callto://number.
So I tried to implement a UI, that reads the number from the cell and issue a window.open, but that is not possible.
Then I tried to put this callto://-link into an anchor element, but that doesn't work either. I also tried to use setHTML but, that doesn't work.
Any ideas how I can get this problem solved?

I customised an existing workflow to work for this purpose and it works really well. It is using the Mac application Alfred (requires the paid-for Powerpack) to use. The workflow consists of a few parts:
Highlight/select the number inside Google Sheets (or any other app)
Fire the keyboard shortcut assigned to the Alfred workflow.
The workflow copies the number into the clipboard.
It escapes any extraneous characters to make it a usable phone number.
It prepends the text snippet tel:// to the number. The workflow can easily be adjusted to use callto://
It executes the "link" that has been built.
FaceTime launches automatically to call using your nearby connected iPhone using Mac's handoff feature. If you use call to links, it may open Skype or other VOIP apps assigned to handle the links natively.
If you like the idea, you may download my workflow and give it a go.

Related

How can I search for a specific function and then edit it?

Unless I'm missing something, the App Script Editor lacks the ability to find a specific function within the project.
I'd like to be able to search for a specific function and then edit it.
Alternatively, how can I view a list of functions within my project (and which .gs file each is in)?
To be clear, I have a number of (logically named) .gs script files within my project each with a number of functions within.
This is not yet an available feature for the new Apps Script IDE - however there is already a fearure request for enabling cross-file search on Google's Issue Tracker:
Search function in Apps Script editor should allow searching of all project files, not just the currently open one.
Google prioritises feature requests by popularity, so make sure to give the issue a star on the above page to let them know this is highly requested.
In the mean time, the legacy editor still has cross-file search available, so you can use this to search in all project files at once.
The new Monaco script editor lacks cross-file search, but the legacy script editor has this feature. So a workaround is to click Use legacy editor in the top right-hand corner and do your search there.
Click the star icon ☆ in the top left-hand corner of issue 175233560 to vote for this feature request and get notified of changes in status.
Yes it does seem to lack that ability as far as I can see. I use control f and then just select between the different files. It keeps the search active between files. Making it possible to find strings in other files. I would prefer if it would just tell me where but I haven't identified that ability as yet.

Google Chrome --new-window switch ignores --window-position and --window-size

I'm trying to control the size and position of newly spawned Google Chrome windows via the command line (through C#.)
My command line ends up looking like:
--new-window --window-position=100,100 --window-size=800,600 www.UrlToOpen.com
However, the new window just opens over top of where the last Chrome window was started.
The end result I'm looking for is to be able to start multiple instances of Google Chrome, in separate windows, with a specific location and size. The only way I've been able to do this so far is by specifying that each instance is to have it's own --user-data-dir. However, this is not ideal given how many extensions a user may have installed, and it would not be the best user experience.
Does anyone have any suggestions?
If Chrome is not programmed to allow this, you only have one option.
Create the process and keep the process object.
Use Process.MainWindowHandle to get the newly created window (you might need to use a loop and Process.Refresh, or Process.WaitForInputIdle)
Use the SetWindowPos native function to position the window wherever you want it.
Native hooks could be used to detect creation of the window, but that requires you to create an unmanaged DLL.
I have another idea for you, why not use a chrome extension for handling the positioning.
Background: We had related difficulties. Internal webapp that opens multiple documents in windows, and need to be placed in other monitors.
The javascript does not support this, for security reasons and only a native extension can properly work with the tabs/windows objects.
Therefore, we have created an open source chrome extension for doing exactly that: flexible windows position across multi-monitor setups.
Perhaps more interest to you would be the feature to use predefine templates. The template file is located in any webserver you like and therefore can be easily share across different users.
The chrome extension is called "MultiWindow Positioner" and its complete free. You can get it at the chrome store here
The actual source code you find in github in the project chrome-multiwindow-positioner
Disclaimer: I am the maintainer of the open source (MIT) github project. If there any interesting idea, or comments feel free to share them here.

How to login to a website, read data?

I would like to write a GoogleApps script that accesses a website, logins using my credentials, makes a selection from a drop down menu and copies the displayed values to paste them on my active spreadsheet.
Is this possible or should I go about it a different way?
Directly, that is not possible. However if the website offers an API or if the website makes use of URL parameters to pass information about what you've selected, it might be possible if the website also uses HTTP authentication.
Absolutely possible. Capture what you need to do for authentication. Repeat it with Google Apps script.
Capture what you need to do with the drop downs. Repeat it with Google Apps script.
Quite generic instructions, but you didn't give any more specificity to your problem. Use something like TamperData addon for Firefox to capture/see what Google Apps Script needs to pass back and forth to the server.

Google Form API?

I would like to (programmatically) convert a text file with questions to a Google form. I want to specify the questions and the questiontypes and their options. Example: the questiontype scale should go from 1 to 7 and should have the label 'not important' for 1 and 'very important' for 7.
I was looking into the Google Spreadsheet API but did not see a solution.
(The Google form API at http://code.lancepollard.com/introducing-the-google-form-api is not an answer to this question)
Google released API for this: https://developers.google.com/apps-script/reference/forms/
This service allows scripts to create, access, and modify Google Forms.
Until Google satisfies this feature request (star the feature on Google's site if you want to vote for it), you could try a non-API approach.
iMacros allows you to record, modify and play back macros that control your web browser. My experiments with Google Drive showed that the basic version (without DirectScreen technology) doesn't record macros properly. I tried it with both the plugin for IE (basic and advanced click mode) and Chrome (the latter has limited iMacro support). FYI, I was able to get iMacros IE plug-in to create questions on mentimeter.com, but the macro recorder gets some input fields wrong (which requires hacking of the macro, double-checking the ATTR= of the TAG commands with the 'Inspect element' feature of Chrome, for example).
Assuming that you can get the TAG commands to produce clicks in the right places in Google Drive, the approach is that you basically write (ideally record) a macro, going through the steps you need to create the form as you would using a browser. Then the macro can be edited (you can use variables in iMacros, get the question/questiontype data from a CSV or user-input dialogs, etc.). Looping in iMacros is crude, however. There's no EOF for a CSV (you basically have to know how many lines are in the file and hard-code the loop in your macro).
There's a way to integrate iMacro calls with VB, etc., but I'm not sure if it's possible with the free versions. There's another angle where you generate code (Javascript) from a macro, and then modify it from there.
Of course, all of these things are more fragile than an API approach long-term. Google could change its presentation layer and it will break your macros.
Seems like Apps Script now has a REST API and SDK's for it. Through Apps Script you can generate Google Forms. This API was really hard to find by trying to google for it and I haven't yet tested it myself, but I am going to build something with it today (hopefully). So far everything looks good.
EDIT: Seems like the REST API I am using works very well for fully automated usage.
In March(2022) google released REST API for google form. API allows basic crud operation & also added support for registering watches on the form to notify whenever either form is updated or a new response is received.
As of now (March 2016), Google Forms APIs allow us to create forms and store them in Google Drive. However, Forms APIs do not allow one programmatically modify the form (such as modify content, add or delete questions, pre-filled data, etc). In other words, the form is static. In order to serve custom, external APIs are needed.

Copy/Paste in JavaScript?

I know this question was asked like a million times by now, but I couldn't really find a good up-to-date solution.
I've implemented my own menu to provide the user the ability to Cut, Copy and Paste into my WebApp.
But I'm not sure how to actually work with the clipboard on Firefox, IE, Safari/Chrome.
Thank you for your help.
I just wrote a detailed technical blog post on this very subject (I work for Lucidchart and we recently did an overhaul on our clipboard). Included in the post is this fiddle which is a working example of copying and pasting via Javascript.
The good news is that this example gives you working code for setting/getting any supported clipboard data types whenever the user uses a clipboard hotkey.
The bad news is that using your own context menu to copy and paste is problematic. Even Google can't get around this (try using context-menu copy or paste in Google Docs in Firefox). You'll be able to get it to work without too much trouble in IE. This is because you can access the clipboardData object at anytime from Javascript via:
window.clipboardData
(When you attempt to do this outside of a system cut, copy, or paste event, however, IE will prompt the user to grant the web application clipboard permission.)
In Chrome, you can create a chrome extension that will give your web app clipboard permissions (this is what we do for Lucidchart). Then for users with your extension installed you'll just need to fire the system event yourself when they click the menu option:
document.execCommand('copy');
It looks like Firefox has some options that allow users to grant permissions to certain sites to access the clipboard, but I haven't tried any of these personally.
did u try :
http://ericphan.info/development/cross-browser-copy-and-paste-with-jquery-copy/
UPDATE:
the link is not available so i copy the content from cache :
The Scenario
I was working on a client project for SSW when the client reported a bug in the web app.
The bug involved a dynamically generated mailto link that got updated when you selected multiple employees. The client was reporting an error when he selected more than 10 employees to email. His Lotus Notes mail client popped up an error saying:
Error processing command line arguments
Testing this myself I found that Outlook 2007 could easily support the emails of 30-40 employees before the mailto link stopped working.
The Cause
It turns out that the mailto spec has a limit and the mail clients also have a limit. Lotus Notes only handles 240 characters in the mailto link and other modern mail clients like Outlook 2007 support the 2083 characters - the max length of a URL
This explains the discrepancy in testing.
The fix - JQuery to the rescue
Since this is a limitation of the HTML spec we needed another solution to meet the client’s requirement of “I want to be able to select multiple employees and send an email to all of them”
We could have created an email form that used SMTP to send out the email - but the client wanted to use Lotus Notes as his mail client.
We ended up changing the “email” button to copy all the emails (comma separated) onto the clipboard and popped open a new email window. All the client had to do was hit CTRL + V and paste the emails into the TO field. This was the quickest and most cost effective solution that gave the client the flexibility to use their own email client.
There is a JQuery plugin called jquery.copy that provided cross browser copy and paste by using a flash (swf) file. This is similar to how the syntax highlighter on my blog works.
Once you reference the jquery.copy.js file all you need to do to push data into the clipboard is run the following:
$.copy("some text to copy");
Nice and easy ;)
Note: you may need to change the path the the SWF file in jquery.copy.js to get this to work