Highlighted

app.preferences.setStringPreference("startupFileType") not working.

Adobe Community Professional ,
May 15, 2020

Copy link to clipboard

Copied

Hello all,

 

I have this situation where a script automatically creates some documents which are different from the preferred new document profile the users would like to see the very next time they wish to name a new document manually.

The documents.addDocument(presetName, presetSettingsObj) function automatically sets this preference.

However, when I try to re-set this preference it doesn't really set it, although when alerting the newly-set preference it provides a proper value.

I guess I can just make new blank documents with the stored preset to force this auto-behavior, but I thought that settings this via script was going to work - if it doesn't work here, then I'm skeptical of all the other ones too!

#target illustrator
function test () {
	const PREFS_KEY_STARTUP_PRESET = "startupFileType";
	var presetFilePath = app.preferences.getStringPreference(PREFS_KEY_STARTUP_PRESET);
	alert("Original preference: " + presetFilePath);
	var presetFile = File(presetFilePath);
	var otherPresetName = app.startupPresetsList[2]; // pick any in the list that's different from the original.
	// alert(otherPresetName);
	var newDocPreset = app.getPresetSettings(otherPresetName);
	app.documents.addDocument(otherPresetName, newDocPreset);
	var newPreference = app.preferences.getStringPreference(PREFS_KEY_STARTUP_PRESET);
	alert("New auto-added preference: " + newPreference);
	app.preferences.setStringPreference(PREFS_KEY_STARTUP_PRESET, presetFilePath);

	var restoredPreference = app.preferences.getStringPreference(PREFS_KEY_STARTUP_PRESET);
	alert("Supposedly restored preference: " + restoredPreference);
};
test();
TOPICS
Bug, Scripting

Views

1.6K

Likes

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

app.preferences.setStringPreference("startupFileType") not working.

Adobe Community Professional ,
May 15, 2020

Copy link to clipboard

Copied

Hello all,

 

I have this situation where a script automatically creates some documents which are different from the preferred new document profile the users would like to see the very next time they wish to name a new document manually.

The documents.addDocument(presetName, presetSettingsObj) function automatically sets this preference.

However, when I try to re-set this preference it doesn't really set it, although when alerting the newly-set preference it provides a proper value.

I guess I can just make new blank documents with the stored preset to force this auto-behavior, but I thought that settings this via script was going to work - if it doesn't work here, then I'm skeptical of all the other ones too!

#target illustrator
function test () {
	const PREFS_KEY_STARTUP_PRESET = "startupFileType";
	var presetFilePath = app.preferences.getStringPreference(PREFS_KEY_STARTUP_PRESET);
	alert("Original preference: " + presetFilePath);
	var presetFile = File(presetFilePath);
	var otherPresetName = app.startupPresetsList[2]; // pick any in the list that's different from the original.
	// alert(otherPresetName);
	var newDocPreset = app.getPresetSettings(otherPresetName);
	app.documents.addDocument(otherPresetName, newDocPreset);
	var newPreference = app.preferences.getStringPreference(PREFS_KEY_STARTUP_PRESET);
	alert("New auto-added preference: " + newPreference);
	app.preferences.setStringPreference(PREFS_KEY_STARTUP_PRESET, presetFilePath);

	var restoredPreference = app.preferences.getStringPreference(PREFS_KEY_STARTUP_PRESET);
	alert("Supposedly restored preference: " + restoredPreference);
};
test();
TOPICS
Bug, Scripting

Views

1.6K

Likes

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
May 15, 2020 0
Adobe Community Professional ,
May 15, 2020

Copy link to clipboard

Copied

sorry I don't understand what you're trying to do 😞

 

what's not working? what should the script do if it worked?

Likes

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
Reply
Loading...
May 15, 2020 0
Adobe Community Professional ,
May 16, 2020

Copy link to clipboard

Copied

The script, in my opinion, lies to me! It says the new preset type (new document profile) is set inside of the script, but when I go manually to make the new document, it does not pre-fill the dropdown with the one set by the script command, it's the one automatically set from when the script added a new document.

I am hoping to store and set this preference inside the script, but I may have to resort ot creating a new blank document & removing it at the end of my script to set this preference and thus make it populate the proper new document profile into the new document dialog for the users.

Likes

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
Reply
Loading...
May 16, 2020 0
Adobe Community Professional ,
May 16, 2020

Copy link to clipboard

Copied

What drop down? I don't see any dropdowns whe I make a new document.

 

ooh, I see, you're using the classic interface. If you want a new preset to show in the list don't you have to save an actual file in the presets folder?

Likes

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
Reply
Loading...
May 16, 2020 0
Adobe Community Professional ,
May 16, 2020

Copy link to clipboard

Copied

Sure, but I am not even worried about that just yet, I just want to make a new document that uses "Art & Illustration", then set it to "Basic RGB", for example, via script and the next time a user make a new document, it will be default at "Basic RGB" and not "Art & Illustration" which currently ends up being the case.

Likes

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
Reply
Loading...
May 16, 2020 0
Adobe Community Professional ,
May 17, 2020

Copy link to clipboard

Copied

I understand now;

 

I give up, nothing works 😞

Likes

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
Reply
Loading...
May 17, 2020 0
Adobe Community Professional ,
May 17, 2020

Copy link to clipboard

Copied

Thanks for trying, maybe some day our children, or our children's children will be able to use some other work around.

Likes

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
Reply
Loading...
May 17, 2020 1
Adobe Community Professional ,
May 19, 2020

Copy link to clipboard

Copied

Here is one more crazy thing, on Windows this preference returns a working file path that has nothing out of the ordinary about it, and in the Prefs file you can see a character count of about 107 for the hex-encoded file paths. On the Mac, it has something very different and that doesn't work with the script function getStringPreference - it shows a blank.

 When looking at the Mac Adobe Illustrator Prefs file, it shows character counts of upwards of 1200, and decoding this string gives various problems in the online hex decoders. However I was able to use one which showed this garbled output. Any knowledge regarding this?

Silly-V_0-1589893254808.png

 

Likes

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
Reply
Loading...
May 19, 2020 0
Adobe Community Professional ,
May 19, 2020

Copy link to clipboard

Copied

no clue, are you on Catalina? didn't the file system changed or something like that?

Likes

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
Reply
Loading...
May 19, 2020 0