topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 9:27 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Possible to trigger alias actions with a user-defined path?  (Read 9760 times)

jzippo

  • Supporting Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 26
    • View Profile
    • Donate to Member
Possible to trigger alias actions with a user-defined path?
« on: September 12, 2007, 05:54 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?

newfile.png

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #1 on: September 12, 2007, 06:06 AM »
can you paste a screenshot of your snag alias and i can advise further

jzippo

  • Supporting Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 26
    • View Profile
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #2 on: September 12, 2007, 06:13 AM »
The alias...

snagalias.png

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #3 on: September 12, 2007, 06:31 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.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #4 on: September 12, 2007, 06:33 AM »
as a quick fix for now you could probably get away with this: put in the regular expression pattern:
(.*) \+snag

jzippo

  • Supporting Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 26
    • View Profile
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #5 on: September 12, 2007, 07:04 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 AM by jzippo »

nitrix-ud

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 560
    • View Profile
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #6 on: September 12, 2007, 11:11 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

jzippo

  • Supporting Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 26
    • View Profile
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #7 on: September 12, 2007, 03:29 PM »
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();
« Last Edit: September 13, 2007, 07:24 AM by jzippo »

nitrix-ud

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 560
    • View Profile
    • Donate to Member
Re: Possible to trigger alias actions with a user-defined path?
« Reply #8 on: September 13, 2007, 12:28 PM »
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