Welcome Guest.   Make a donation to an author on the site September 16, 2014, 12:31:10 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the full one-year retrospective report on DonationCoder.com.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Possible to trigger alias actions with a user-defined path?  (Read 4265 times)
jzippo
Supporting Member
**
Posts: 26

View Profile Give some DonationCredits to this forum member
« on: September 12, 2007, 05:54:18 AM »

Is it true that FARR doesn't allow one to trigger an alias action with a path that points to something that does not exist? I want to be able to do this as I would like to use FARR for constructing a path for a resource that is to be created by an alias action. That is, I would like to search for a folder in FARR, select it with TAB and then type in a name for a new file that is to be constructed by an alias action in that path. Impossible, or?

The image below shows what I mean. The path "C:\Documents and Settings\Joe\Desktop\inhere\" appears after selecting a folder in FARR with TAB. The user then adds newfile.png to the path and +snag to send it to this alias for further processing. The result of this would be that a screen capture is performed with SnagIt and saved in a file named newfile.png that SnagIt creates. Is this possible?

Logged
mouser
First Author
Administrator
*****
Posts: 33,354



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: September 12, 2007, 06:06:22 AM »

can you paste a screenshot of your snag alias and i can advise further
Logged
jzippo
Supporting Member
**
Posts: 26

View Profile Give some DonationCredits to this forum member
« Reply #2 on: September 12, 2007, 06:13:36 AM »

The alias...

Logged
mouser
First Author
Administrator
*****
Posts: 33,354



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: September 12, 2007, 06:31:32 AM »

ok sorry i got confused, i thought it was going to be that you forgot to use a regular expression in your alias, but i realize now the problem is exactly as you said, because it's not finding a match it's not showing a result for you to trigger.

when you use a regular expression match, then what you type does not have to yield a result, but the way you are using the alias in +alias mode, it seems it does.

i agree fully that in this case it should show the results.. give me a few days and i'll add it in the next farr update.
Logged
mouser
First Author
Administrator
*****
Posts: 33,354



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: September 12, 2007, 06:33:07 AM »

as a quick fix for now you could probably get away with this: put in the regular expression pattern:
(.*) \+snag
Logged
jzippo
Supporting Member
**
Posts: 26

View Profile Give some DonationCredits to this forum member
« Reply #5 on: September 12, 2007, 07:04:46 AM »

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).
« Last Edit: September 12, 2007, 09:51:53 AM by jzippo » Logged
nitrix-ud
Charter Member
***
Posts: 482

View Profile Give some DonationCredits to this forum member
« Reply #6 on: September 12, 2007, 11:11:03 AM »

@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
Logged
jzippo
Supporting Member
**
Posts: 26

View Profile Give some DonationCredits to this forum member
« Reply #7 on: September 12, 2007, 03:29:50 PM »

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

[copy or print]
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();
« Last Edit: September 13, 2007, 07:24:49 AM by jzippo » Logged
nitrix-ud
Charter Member
***
Posts: 482

View Profile Give some DonationCredits to this forum member
« Reply #8 on: September 13, 2007, 12:28:00 PM »

thanks for you answer very interesting Wink

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

[copy or print]
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
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.038s | Server load: 0.13 ]