Skip to main content
Charu Rajput
Community Expert
Community Expert
April 24, 2020
Answered

Open web-url from Script UI in default browser

  • April 24, 2020
  • 4 replies
  • 4144 views

Hello I have created a dialog for the Photoshop script and in this dialog there is a static text that is the url of some web page. Here I have used Adobe forum url as an example. Is it possible to make it clickable and open that url in the web browser. I am aware that if this is the plugin, this is psosible. But I am using Script UI to create thsi dialog, so is it possible to make clickable link in Photoshop?

 

Here is the code

function showDialog() {
    var obj = {};
    var dlg = new Window("dialog", "Sample");

    row = dlg.add('group', undefined, '');
    row.add('statictext', undefined, "Path: ");
    var pathInput = row.add('edittext', undefined, "");
    pathInput.enabled = false;
    pathInput.preferredSize = [350, 22];

    //Icon button
    var selectButton = row.add('button', undefined, 'Select', {
        name: 'Select'
    });

    selectButton.onClick = function () {
            var folderPath = Folder.selectDialog("Select a folder to save the files");
        if (folderPath) {
            pathInput.text = decodeURI(folderPath.fsName);
            goButton.enabled = true;
        }
    };

    var checkBoxGroup;
    checkBoxGroup = dlg.add('group', undefined, '');
    checkBoxGroup.alignment = "left";
    checkBoxGroup.orientation = 'column';
    checkBoxGroup.alignChildren = "left";
    checkBoxGroup.margins.left = 25;

    var buttonGroup = dlg.add('group', undefined, '');
    buttonGroup.alignment = 'right';
    var cancelButton = buttonGroup.add('button', undefined, 'Cancel', {
        name: 'Cancel'
    });

    cancelButton.onClick = function () {
        dlg.close();
    };

    var goButton = buttonGroup.add('button', undefined, 'Go', {
        name: 'Go'
    });

    goButton.onClick = function () {
        // Some other tasks 
        dlg.close();
    }
    if (pathInput.text == '') {
        goButton.enabled = false;
    }

    info = dlg.add('group', undefined, '');
    info.alignChildren = 'left'
    var version = info.add('statictext', undefined, "Version: 1.1 ");
    version.preferredSize = [350, 15];

    var website = info.add('statictext', undefined, "https://community.adobe.com/");
    website.preferredSize = [200, 15];

    dlg.show();

}

showDialog();

 

Also, attached image to give clear explanantion. Please let me know whether is it possible to do using Script UI in photoshop or not? If yes, Please share any references.

Thanks in advance

This topic has been closed for replies.
Correct answer JJMack

A Script UI  button on click function can do something to open a url in the user's default browse just through a html file over the wall to the user's OS.  The file should be associated with the user's default browser.  That is what my Script dialog Help buttons do.

 

function help() {
	try{
		var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");
		URL.open("w");
		URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');
		URL.close();
		URL.execute();
	}catch(e){
		alert("Error, Can Not Open.");
	};
}

4 replies

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
April 24, 2020

A Script UI  button on click function can do something to open a url in the user's default browse just through a html file over the wall to the user's OS.  The file should be associated with the user's default browser.  That is what my Script dialog Help buttons do.

 

function help() {
	try{
		var URL = new File(Folder.temp + "/PhotoCollageToolkit.html");
		URL.open("w");
		URL.writeln('<html><HEAD><meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html"></HEAD></HTML>');
		URL.close();
		URL.execute();
	}catch(e){
		alert("Error, Can Not Open.");
	};
}
JJMack
Tilles
Inspiring
August 31, 2021

For some reason, concatenating a String and an Object is throwing an error for me.

So, I guess the best practice is to transform the folder into String before joining:

var URL = new File(Folder.temp.toString() + "/PhotoCollageToolkit.html");

thanks for this great piece of code!

Tilles
Inspiring
September 2, 2021

Why AE if we're in Ps forum? It works for me as well with sole ESTK CC as with targeted Ps.


yep, sorry, I didnt notice I was in a PS forum.

anyway, anyone who write scripts for more than one software, may take some insight in this thread.

Legend
April 24, 2020

using .addEventListener ('click', ...), we can do click processing for statictext. If add an underline and color the text, then we get something that looks like a link. Link processing can most likely be done by calling an external script

Kukurykus
Legend
April 24, 2020

.png you attached just reopen same page in new window.

 

As to your question you probably can only make button.

Stephen Marsh
Community Expert
Community Expert
April 24, 2020

This link is for InDesign, however I'm guessing that it will also be workable in Photoshop.

 

[JS] ScriptUI - URL Links in Dialogues

Charu Rajput
Community Expert
Community Expert
April 24, 2020

Thankyou Stephen. I have gone through this link earlier as well, but unfortunately app.doScript does not exists for Photoshop.

 

Thanks

Charu

Best regards