Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Open web-url from Script UI in default browser

Community Expert ,
Apr 24, 2020 Apr 24, 2020

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

Best regards
TOPICS
Actions and scripting
3.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 24, 2020 Apr 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.
...
Translate
Adobe
Community Expert ,
Apr 24, 2020 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2020 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 24, 2020 Apr 24, 2020

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

 

As to your question you probably can only make button.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 24, 2020 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2020 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2020 Apr 24, 2020

Thankyou JJMark. This help to implement what I needed. 

Thanks to all community members here.

 

Best regards

Charu

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 31, 2021 Aug 31, 2021

I'm Mark. He is Mack 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 31, 2021 Aug 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 31, 2021 Aug 31, 2021

No error for me without .toString().

 

Could you place that in Try..Catch statement and say what type of error?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 01, 2021 Sep 01, 2021

I get this error: "Object of type Folder found where a Number, Array, or Property is needed".
Only when running the script targeting After Effects. If I target ExtendScript Toolkit CS5, there's no error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 01, 2021 Sep 01, 2021

The code was posted for Photoshop scripting you seem to have adapted it for use with  After effects scripting as well...... I first use it in CS2 and it still works in Photoshop 2021 version 22.5.  I just hack at scripting Photoshop I do not know JavaScript.  To know when ".toString()" should be use I my try that if a hack fails on me.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 01, 2021 Sep 01, 2021

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 01, 2021 Sep 01, 2021
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines