Copy link to clipboard
Copied
Good Morning,
Jumping off from this post back in 2012
https://community.adobe.com/t5/illustrator-discussions/link-to-a-web-page-from-ai-javascript/td-p/45...
from Muppet_Mark-phjQ9l Guru , Dec 06, 2012
var f = File( Folder.desktop + '/TestURL.url' );
f.open( 'w' );
f.write( '[InternetShortcut]' + '\r' + 'URL=http://www.google.com' + '\r' );
f.close();
f.execute();
When the script creates the URL Shortcut on my desktop is there a way to have it update the URL everytime I run the script to pull up the Order Number?
var strEnter = prompt("Please Enter the New Order # (a 7-digit number)", "");
var f = File( Folder.desktop + '/TestURL.url' );
f.open( 'w' );
f.write( '[InternetShortcut]' + '\r' + 'URL=http://MyWebSite&orderNumber=' + strEnter + '\r' );
f.close();
f.execute();
Thank you!
If I understand you correctly - does this work for you?
//for example
//https://community.adobe.com/html/assets/banner2.png
var Filename_or_Number_does_not_matter = prompt("Please Enter the New Order # (a 7-digit number)", "banner2.png");
var f = File( Folder.desktop + '/TestURL.url' );
f.open( 'w' );
f.write( '[InternetShortcut]' + '\r' + 'URL=https://community.adobe.com/html/assets/' + Filename_or_Number_does_not_matter + '\r' );
f.close();
f.execute();
Copy link to clipboard
Copied
You can have a CEP extension if you want to pull up the order right there inside of Illustrator, but otherwise a good way is to do the following:
1) Create an HTML page somewhere on your desktop, you can use regular VSCode without any ESTK for this.
2) Put a script into the HTML page which has a function that tries to load a JS script from the same folder and is named a certain name that doesn't change. Make this function repeat in an interval every second or less, its purpose is to find and load a JS file which has some data inside it.
3) With your JSX extendscript use a method to write the JS file to that location in step 2. Make this JS file have contents such as var data = { "url" : "my-url.com"}; When the HTML page's javascript finds and loads this file, make it change the window.location object to the url inside the data that was just found. Now the page will redirect to the url and that's that.
4) Clean up the written JS file using JSX by waiting a good second (longer than HTML page's javascript interval) with $.sleep(1000) and then removing the file. This way when you press the back button or go to the page by double clicking the HTML file from the filesystem, it will run the time interval function but not find any JS file with data and therefore will not redirect anywhere.This way you can be more sure that only script-activated actions are responsible for the website someone's about to see.
I have a complex example in github, you can observe this part of the example to see such an HTML page and JS file at work. The HTML page looks huge, the time-interval script does a lot. You can strip all of that content out and just narrow down on the structure of the time-interval method itself.
To recap:
Copy link to clipboard
Copied
If I understand you correctly - does this work for you?
//for example
//https://community.adobe.com/html/assets/banner2.png
var Filename_or_Number_does_not_matter = prompt("Please Enter the New Order # (a 7-digit number)", "banner2.png");
var f = File( Folder.desktop + '/TestURL.url' );
f.open( 'w' );
f.write( '[InternetShortcut]' + '\r' + 'URL=https://community.adobe.com/html/assets/' + Filename_or_Number_does_not_matter + '\r' );
f.close();
f.execute();
Copy link to clipboard
Copied
@pixxxelschubser That worked the first time I used the script on order 5994589, but when I ran it again for order 5994699 it just reopened the webpage for the first order number 5994589.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@pixxxelschubser so it worked great for a few days and then this morning when I was demonstrating it; it would only pull up a Previous Order# site, not the one associated with the Order# I was currently working on.
Is there an extra step that could be included in the script to ensure it cannot pull up the site from a previous use?
Thanks appreciate the assist!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
1. I can have a generic Google Search Page if that helps.
2. I am running the Script from Inside Illustrator
3. No Changes in the Script that I am aware of
4. Here is the Script with the Generic Google Search for the website
var strEnter = prompt("Please Enter the New Order #", "");
if (strEnter != null) {
var doc = app.activeDocument;
var PTS_IN = 72;
var width = 90 * PTS_IN;
var height = 90* PTS_IN;
var presets = app.startupPresetsList;
var preset = presets[3];
var docPreset = new DocumentPreset();
docPreset.title = strEnter;
docPreset.units = RulerUnits.Inches;
docPreset.width = width;
docPreset.height = height;
var doc = app.documents.addDocument(preset, docPreset, false);
} else { alert ("Please Try Again Invalid Order # :" + strEnter);
};
// Open Order Preview Screen for the Order # Entered. Added on 2/1/22
var f = File( Folder.desktop + '/Search.url' );
f.open( 'w' );
f.write( '[InternetShortcut]' + '\r' + 'URL=https://www.google.com/search?q=' + strEnter + '\r');
f.close();
f.execute();
Copy link to clipboard
Copied
Works for me on Window with Firefox as expected. The web page with the number is opened and a new document is created with the number as name.
The script is started again:
Internet page with the new number is opened and a new document with the new number as name is created.
Please check the hierarchy of your website.