ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Find And Run Robot

Possible to trigger alias actions with a user-defined path?

<< < (2/2)

jzippo:
the "(.*) \+snag" trick does not work at all. It somehow screws up the parameters sent to the receiving script.

The first parameter to the SnagIt-script is the path in which to save the screen capture. Previously $$1 sent the path I selected in FARR but with this trick the 1st parameter contains the path of the script itself. The arguments thus became transposed in some way or perhaps doubled (probably doubled since the script itself is still launched).

nitrix-ud:
@jzippo
would you mind showing us your javascript file ?
it seems interesting !
i did not know about the cscript.exe trick...

do you think it would be possible to launch bookmarklet using this ?

Cheers, Nitrix

jzippo:
I have no idea what you mean by a bookmarklet, but here's the code for SnagItCapture.js (works with SnagIt version 7):


--- ---function snagItInit(sPath, inputMode, delaySecs) {
snagIt = new ActiveXObject("SnagIt.ImageCapture"); //Global object
wshShell = new ActiveXObject("WScript.Shell"); //Global object
objFSO = new ActiveXObject("Scripting.FileSystemObject"); //Global object

//Check if file points to directory (if not, then this path is treated as a file).
//Automatic naming scheme is applied if sPath is directory
var isFolder = objFSO.FolderExists(sPath);

//-- Input constants --
snagImageInput = new Object();
snagImageInput.siiDesktop = 0;
snagImageInput.siiWindow = 1;
snagImageInput.siiRegion = 4;
snagImageInput.siiClipboard = 7;
snagImageInput.siiCustomScroll = 18;

//-- Output constants --
snagImageOutput = new Object();
snagImageOutput.sioClipboard = 4;
snagImageOutput.sioFile = 2;

//-- ImageFileType constants --
snagImageFileType = new Object();
snagImageFileType.siftBMP = 0;
snagImageFileType.siftPCX = 1;
snagImageFileType.siftTIFF = 2;
snagImageFileType.siftJPEG = 3;
snagImageFileType.siftGIF = 4;
snagImageFileType.siftPNG = 5;
snagImageFileType.siftTGA = 6;

//-- OutputImageFile.FileNamingMethod constants --
snagOutputFileNamingMethod = new Object();
snagOutputFileNamingMethod.sofnmPrompt = 0;
snagOutputFileNamingMethod.sofnmFixed = 1;
snagOutputFileNamingMethod.sofnmAuto = 2;

//-- AutoScrollMethod constants --
snagAutoScrollMethod = new Object();
snagAutoScrollMethod.sasmVertical = 1;
snagAutoScrollMethod.sasmNone = 0;
snagAutoScrollMethod.sasmHorizontal = 2;
snagAutoScrollMethod.sasmBoth = 3;

//-- AutoScrollStartingPosition constants --
snagAutoScrollStartingPosition = new Object();
snagAutoScrollStartingPosition.sasspCurrent = 0;
snagAutoScrollStartingPosition.sasspTop = 1;
snagAutoScrollStartingPosition.sasspLeft = 2;
snagAutoScrollStartingPosition.sasspTopLeft = 3;

//Select input
if (!inputMode) {
snagIt.Input = snagImageInput.siiWindow;
} else {
snagIt.Input = inputMode;
}


snagIt.Output = snagImageOutput.sioFile; //Select output
snagIt.AutoScrollOptions.AutoScrollMethod = snagAutoScrollMethod.sasmNone; //Select autoscroll

if (delaySecs && delaySecs > 0) {
snagIt.DelayOptions.DelaySeconds = delaySecs;
snagIt.DelayOptions.EnableDelayedCapture = true;
snagIt.DelayOptions.EnableCountdownWindow = true;
}

//if (pickX && pickY) {
// snagIt.InputWindowOptions.SelectionMethod = 3; //swsmPoint (default swsmInteractive)
// snagIt.InputWindowOptions.XPos = pickX;
// snagIt.InputWindowOptions.YPos = pickY;
//}

if (snagIt.Output == snagImageOutput.sioFile) {
snagIt.OutputImageFile.FileType = snagImageFileType.siftPNG;

WScript.Echo(sPath);

if (isFolder) {
snagIt.OutputImageFile.FileNamingMethod = snagOutputFileNamingMethod.sofnmPrompt;
snagIt.OutputImageFile.Directory =  sPath; //Inargument

} else {
snagIt.OutputImageFile.FileNamingMethod = snagOutputFileNamingMethod.sofnmFixed;
WScript.Echo("Save in: " + objFSO.GetParentFolderName(sPath) +"\\"+ objFSO.GetFileName(sPath));
snagIt.OutputImageFile.Directory =  objFSO.GetParentFolderName(sPath); //Inargument
snagIt.OutputImageFile.Filename = objFSO.GetFileName(sPath); //Inargument
}

//snagIt.OutputImageFile.AutoFilePrefix = filePrefix; //Inargument
//snagIt.OutputImageFile.AutoNumPrefixDigits = 4;
}


if (snagIt.AutoScrollOptions.AutoScrollMethod != snagAutoScrollMethod.sasmNone)  {
//snagIt.AutoScrollOptions.Delay = 150;
snagIt.AutoScrollOptions.ForegroundScrollingWindow = true;
snagIt.IncludeCursor = false;
snagIt.AutoScrollOptions.StartingPosition = snagAutoScrollStartingPosition.sasspTop; //Select AutoScrollStartingPosition
}
}

function printSnagItWindowInputOpts() {
WScript.Echo("InputWindowOptions.Handle: " + snagIt.InputWindowOptions.Handle);
WScript.Echo("InputWindowOptions.SelectionMethod: " + snagIt.InputWindowOptions.SelectionMethod);
WScript.Echo("InputWindowOptions.XPos: " + snagIt.InputWindowOptions.XPos);
WScript.Echo("InputWindowOptions.YPos: " + snagIt.InputWindowOptions.YPos);
}


function getFileDirArg() {
//WScript.Echo("FileDirArg: " + WScript.Arguments.Item(0));
return WScript.Arguments.Item(0);
}

function getInputModeArg() {
return (WScript.Arguments.Count() > 1) ? parseInt(WScript.Arguments.Item(1)) : undefined;
}

function getDelaySecsArg() {
return (WScript.Arguments.Count() > 2) ? parseInt(WScript.Arguments.Item(2)) : undefined;
}

function snagItCapture() {
snagIt.Capture();
while(!snagIt.IsCaptureDone) {
WScript.Sleep(500);
}

var runPath = '"' + objFSO.GetParentFolderName(WScript.ScriptFullName) + '\\nircmd.exe" clipboard set "' + snagIt.LastFileWritten + '"';
wshShell.Run(runPath);
WScript.StdErr.WriteLine(snagIt.LastError);
}

function snagItDestroy() {
//printSnagItWindowInputOpts();
snagIt = null;
snagImageInput = null;
snagImageOutput = null;
}


snagItInit(getFileDirArg(), getInputModeArg(), getDelaySecsArg());
snagItCapture();
snagItDestroy();

nitrix-ud:
thanks for you answer very interesting ;)

a bookmarklet is a javascript function which is within a bookmark, for example the one below will validates HTML using the W3C HTML validator :


--- ---javascript:(function(){ function fixFileUrl(u) { var windows,u; windows = (navigator.platform.indexOf("Win") != -1);  /* chop off file:///, unescape each %hh, convert / to \ and | to : */  u = u.substr(windows ? 8 : 7); u = unescape(u); if(windows) { u = u.replace(/\//g,"\\"); u = u.replace(/\|/g,":"); } return u; } /* bookmarklet body */ var loc,fileloc; loc = document.location.href; if (loc.length > 9 && loc.substr(0,8)=="file:///") { fileloc = fixFileUrl(loc); if (prompt("Copy filename to clipboard, press enter, paste into validator form", fileloc) != null) { document.location.href = "http://validator.w3.org/file-upload.html" } } else document.location.href = "http://validator.w3.org/check?uri=" + escape(document.location.href); void(0); })();


it is stored as a bookmark/favorite in your browser, and i always wondered if one could launch a bookmarklet from FARR

Navigation

[0] Message Index

[*] Previous page

Go to full version