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

Display username in listbox

Engaged ,
Jun 30, 2020 Jun 30, 2020

Copy link to clipboard

Copied

I created some script which recognize current user, and displaying alert with that username. Is it possible (and how) to use that username later in a script, for example to put that username into listbox?

TOPICS
Actions and scripting

Views

483

Translate

Translate

Report

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
Adobe
Community Expert ,
Jun 30, 2020 Jun 30, 2020

Copy link to clipboard

Copied

It would be easy the get the Current UserID  However I do not know if the Users Actual Sir Name is required to be on their computers.  Most likely users have their name on their machine somewhere  however offhand  I do not know Your name is required to in some particular location.  The UserName your script has retrieve or coded can bet put is a ScriptUI Dialog. 

JJMack

Votes

Translate

Translate

Report

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
Engaged ,
Jun 30, 2020 Jun 30, 2020

Copy link to clipboard

Copied

function isMacOS() {
return ($.os.toLowerCase().indexOf('mac') >= 0);
}
function getUserName() {
return (isMacOS()) ? $.getenv("USER") : $.getenv("USERNAME");
}
var userName = getUserName();
alert(userName);

this scripts works and show me proper name, but if i put userName as a value in listbox i got "undefinded"...

 

Votes

Translate

Translate

Report

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 ,
Jun 30, 2020 Jun 30, 2020

Copy link to clipboard

Copied

On Windows, this works

$.writeln($.getenv("USERNAME"));

Votes

Translate

Translate

Report

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
People's Champ ,
Jul 01, 2020 Jul 01, 2020

Copy link to clipboard

Copied

this scripts works and show me proper name, but if i put userName as a value in listbox i got "undefinded"..

 

How do you "put userName as a value in listbox" ?

Votes

Translate

Translate

Report

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 ,
Jul 01, 2020 Jul 01, 2020

Copy link to clipboard

Copied

ListBox.add (type: String , text: String 😞 ListItem
ScriptUI Classes
Adds an item to the choices in this list.
Returns the item control object. If this is a multi-column list box, each added  ListItem  represents one selectable row. Its  text  and  image  values specify the label in the first column, and the  subitems  property specifies the labels in the additional columns.
type: Data Type: String
The type of the child element, the string "item".
text (optional): Data Type: String
The localizable text label for the item.

Votes

Translate

Translate

Report

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
Engaged ,
Jul 02, 2020 Jul 02, 2020

Copy link to clipboard

Copied

Ok, this is the example of how that needs to look like. I have some predefined users and also i want to add someone who is new automatically on a list. Is it possible?

 

 

    var box = new Window('dialog', "TEST");
    var a = ["Peter", "John", "Sofia", userName];  
    for (var i = 0; i < a.length; i += 1) {  
     a["_"+a[i]] = i;  
    }
    box.group = box.add('group', undefined );  
    box.group.orientation='row'; 
    box.group.alignment = 'right'; 
    box.group.text1 = box.group.add('statictext', undefined, "EMP_name");
    box.group = box.group.add("dropdownlist", [25,40,160,60], a);
    function isMacOS() {
      return ($.os.toLowerCase().indexOf('mac') >= 0);
    }
    function getUserName() {
      return (isMacOS()) ? $.getenv("USER") : $.getenv("USERNAME");
    }
    var userName = getUserName();
    if (userName == 'peter_stivens') {
    box.group.selection = 0;}
    if (userName == 'john_admas') {
    box.group.selection = 1;}
    if (userName == 'sofia_richards') {
    box.group.selection = 2;}
    else{
    box.group.selection = 3;}
    var btnGroup = box.add ("group");
    btnGroup.orientation = "row";
    var btnOk = btnGroup.add("button", undefined, "OK");  
    var btnCancel = btnGroup.add("button", undefined, "Cancel"); 
    box.center();
    btnOk.onClick = function() {  
        box.close(1);
    };  
    btnCancel.onClick = function() {  
        box.close(0);
    };
    box.show();

 

Votes

Translate

Translate

Report

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 ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

A dropdownlist is not a listbox.

Votes

Translate

Translate

Report

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 ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

LATEST

And a List does not need to be predefined it can be generated  even a Pull down dropdown list. for example a font list.

 

 

 

 

 

 

 

	dlg.msgPnl.grp6a =dlg.msgPnl.add('group');
	dlg.msgPnl.grp6a.orientation='row';
	dlg.msgPnl.grp6a.alignment='fill';
	dlg.msgPnl.grp6a.st1 = dlg.msgPnl.grp6a.add('statictext',undefined,'Font');
	fontlist = new Array();
	psfontlist = new Array();
	for (var i=0,len=app.fonts.length;i<len;i++) {
		//fontlist[i] =  app.fonts[i].name;
		try { 
			if ( app.fonts[i].name!=app.fonts[i+1].name &&  app.fonts[i].name.indexOf("Acumin") == -1) {
				fontlist.push(app.fonts[i].name);
				psfontlist.push(app.fonts[i].postScriptName);
				}
			}
		catch(e) { 
			if ( app.fonts[i].name.indexOf("Acumin") == -1) {}
				fontlist.push(app.fonts[i].name);
				psfontlist.push(app.fonts[i].postScriptName);
			}
		}
	dlg.msgPnl.grp6a.dd1 = dlg.msgPnl.grp6a.add('dropdownlist',undefined,fontlist);
	dlg.msgPnl.grp6a.dd1.selection=1;

 

 

 

 

 

 

image.png

image.pngimage.pngimage.pngimage.png

The script adds text and smart object layers to  template psd documents.  The Layers outlined in red in the Layers Palette Location Size and Shape of Images are mapped via Alpha channels in the templated psd.

 

image.png

JJMack

Votes

Translate

Translate

Report

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