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

Prompt limit is 255 characters, otherwise Photoshop crashes! Is there a better way?

Guest
Apr 17, 2015 Apr 17, 2015

I noticed today that the "prompt" command appears to have a limit where it can accept no more than 255 characters.  If you try to enter more, Photoshop crashes!

Photoshop CC v14.2.1 x64

Windows 7 64-bit SP1

16 GB RAM

I tried the following:

    var defaultTextString = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.1234567890123456789012345678901234567890123456789|12345";
    var textString = prompt("Enter citation:", defaultTextString);

With 255 characters in the defaultTextString, the prompt works as expected.  If you add an additional character to the defaultTextString, the prompt box comes up as expected with the full default text as expected.  However, when you hit the OK button, you get the following Windows error and Photoshop closes.

Adobe Photoshop CC has stopped working

A problem caused the program to stop working correctly. 

Windows will close the program and notify you if a solution is

available.

I am relatively new to Photoshop scripting.  Is there another command that I should be using for text input larger that 255 characters?

  - Brad

TOPICS
Actions and scripting
1.0K
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

Deleted User
Apr 21, 2015 Apr 21, 2015

Davide,

  Thanks for taking the time to reply with the code sample.  I tried to copy and paste it into a new window in ExtendScript Toolkit, and I got an error on line 2.  Unfortunately, I am not experienced enough yet to find the exact problem.  However, you got me pointed in the right direction and I was able to learn a lot about windows!

  For the benefit of others, there is windowing code for Photoshop called ScriptUI.  I found a helpful tutorial here:  ScriptUI for dummies | Peter Kahrel

  Fro

...
Translate
Adobe
Advocate ,
Apr 17, 2015 Apr 17, 2015

Hi Brian,

try using this customized version:

function longPrompt(myText, myCitation) {

    var winRes = "dialog { \

        preferredSize: [250,150], \

        alignChildren: ['fill', 'top'], \

        orientation: 'column', \

        text: 'Confirm', \

        titleText: StaticText {}, \

        citationText: EditText { preferredSize: [200, 100], properties: {multiline: true, scrolling: true } }, \

        buttonsGroup: Group { \

            orientation: 'row', \

            alignChildren: ['center', 'top'], \

            cancelButton: Button { text: 'Cancel' }, \

            confirmButton: Button { text: 'Ok' } \

        } \

    }"

    var w = new Window(winRes);

    w.titleText.graphics.font = "dialog:18-Bold";

    w.titleText.text = myText;

    w.citationText.text = myCitation || "Enter your text"

    var result = w.show();

    return (result === 1) ? w.citationText.text : false

}

var textString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus."

var result = longPrompt("Enter citation", textString);

$.writeln(result);

Hope this helps.

Regards

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

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
Apr 17, 2015 Apr 17, 2015

Ouch. wchar_t text [256]; ... ::GetDlgItemTextW (hwnd, 11, text, 2048); I don't think that will fit! I'll log a bug.

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
Guest
Apr 21, 2015 Apr 21, 2015

Thanks for logging the bug!

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
Guest
Apr 21, 2015 Apr 21, 2015

Davide,

  Thanks for taking the time to reply with the code sample.  I tried to copy and paste it into a new window in ExtendScript Toolkit, and I got an error on line 2.  Unfortunately, I am not experienced enough yet to find the exact problem.  However, you got me pointed in the right direction and I was able to learn a lot about windows!

  For the benefit of others, there is windowing code for Photoshop called ScriptUI.  I found a helpful tutorial here:  ScriptUI for dummies | Peter Kahrel

  From what I found on the web, the CS2 scripting guide contains some of the most comprehensive documentation for ScriptUI (see Chapter 4):  Adobe CS2 Photoshop JavaScript Scripting Reference - JavaScriptReferenceGuide.pdf

   - Brad

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
Advocate ,
Apr 22, 2015 Apr 22, 2015
LATEST

Hi,

my fault, some (invisible) spaces were left after the "\" try this one:

function longPrompt(myText, myCitation) {

    var winRes = "dialog { \

        preferredSize: [250,150], \

        alignChildren: ['fill', 'top'], \

        orientation: 'column', \

        text: 'Confirm', \

        titleText: StaticText {}, \

        citationText: EditText { preferredSize: [200, 100], properties: {multiline: true, scrolling: true } }, \

        buttonsGroup: Group { \

            orientation: 'row', \

            alignChildren: ['center', 'top'], \

            cancelButton: Button { text: 'Cancel' }, \

            confirmButton: Button { text: 'Ok' } \

        } \

    }";

    var w = new Window(winRes);

    w.titleText.graphics.font = "dialog:18-Bold";

    w.titleText.text = myText;

    w.citationText.text = myCitation || "Enter your text"

    var result = w.show();

    return (result === 1) ? w.citationText.text : false

}

var textString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus."

var result = longPrompt("Enter citation", textString);

$.writeln(result);

Davide

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