I’m using API to call ui vision but I don’t know exactly how to pass custom variables
this is what I put in windows cmd:
"C:\Program Files\Mozilla Firefox\firefox.exe" -no-remote -P links "file:///C:/Users/Administrator/Desktop/Tools/ui.vision.html?macro=download_mp4_file.js&direct=1&closeBrowser=1&savelog=log.txt&dynamicUrl=``https://safebooru.org/samples/2386/sample_52a9b62657315c27f209c70d2f0db0df6c6c6275.jpg&dynamicFilename=test.jpg``"
but gives error:
Status=Error: getVar: 'dynamicUrl' is not set — set it with uiv.setVar('dynamicUrl', …) first, or run the command that stores into it. To allow it, pass a default: uiv.getVar('dynamicUrl', null)
[status] download_mp4_file.js started
[error] download_mp4_file.js failed: getVar: 'dynamicUrl' is not set — set it with uiv.setVar('dynamicUrl', …) first, or run the command that stores into it. To allow it, pass a default: uiv.getVar('dynamicUrl', null) (line 2) (Runtime 0.21s)
this is the macro:
// Retrieve dynamic values passed from n8n into UI.Vision global variables
const url = uiv.getVar('dynamicUrl');
const wantedName = uiv.getVar('dynamicFilename');
const downloadFolder = 'C:\Users\Administrator\Desktop\Tools\paw downloads';
// The server generates the file on request, so give the download a generous
// start window (seconds) before the transfer itself is awaited.
uiv.setVar('!TIMEOUT_WAIT', 30);
uiv.log('Starting download: ' + url, 'blue');
// uiv.download returns the name the file actually got on disk.
const file = uiv.download(url, { timeout: 300 });
if (!file) {
throw new Error('Download did not complete - no file name returned.');
}
uiv.log('Downloaded as: ' + file, 'green');
// --- rename on disk -------------------------------------------------------
// A plain "move" through cmd.exe: no PowerShell quoting problems, and /Y
// overwrites an existing file with the wanted name so repeated runs work.
const src = downloadFolder + '\' + file;
const dst = downloadFolder + '\' + wantedName;
uiv.log('Renaming to: ' + wantedName, 'blue');
uiv.run('XRunAndWait', 'cmd.exe', '/c move /Y "' + src + '" "' + dst + '"');
// --- verify ---------------------------------------------------------------
const check = uiv.run('XRunAndWait', 'cmd.exe',
'/c if exist "' + dst + '" (exit 0) else (exit 1)');
// XRunAndWait throws on a non-zero exit code, so reaching this line means the
// file with the wanted name is on disk.
uiv.log('Saved as: ' + dst, 'green');
How to fix this?