Placing a USER name in a box?
I'm trying to add a user name to a box so whom ever saves the file last it will place there name in the box as you press the save button. I will post the code i'm thinking of using below. as well as a pic to show what i'm wanting.
#targetengine "myUniqueName"
// Add an event listener for the event "beforeSave" that is executing a function
app.addEventListener
(
/* the event you are listening to: | as String */ "beforeSave" ,
/* the function that is called when found: */ doTextFrameOnPageOne
);
function doTextFrameOnPageOne()
{ /*IS THIS WHERE I SHOULD PLACE THE CODE BELOW?*/
// Here will start your code, that is:
// 1. Looking for the user name
// 2. Check, if the text frame you want to create is already there
// 3. Adds the user name, the current date and some other information
// 4. Tells the document where to exactly put the text frame, its dimensions and other properties
// Test the function:
alert("Event \"beforeSave\" just fired.");
};
// SHOULD THIS CODE GO IN THE FUNCTION BRACKETS above?
var myString = 'Hallo InDesign ' + app.version + ', I am ' + getUser() + '.';
alert ( myString );
function getUser() {
var myUser = ($.os.substring(0, 7)=="Windows") // I'M USING A MAC SO DO I JUST REPLACE "Windows" with "MAC". ALSO I WOULD LIKE IT TO GRAB THE USER NAME FROM INDESIGN NOT THE COMPUTER*IF POSSIBLE*
? $.getenv("USERNAME")
: $.getenv("USER");
return myUser;
}
