Page 1 of 1

Expansion of new 'How To'

Posted: Tue Apr 26, 2011 12:25 pm
by MattBell7
Just seen the How to Tom just posted, http://forum.imacros.net/viewtopic.php?f=6&t=12790, and figured it may be worth adding this to it (but i can't myself as i can't post in that forum)

Using this code, you can tell your vbs to run your macro from a dynamic location. i.e. the same folder as the vbs, regardless of where iMacros is configured to use. This is especially useful if you move your macros around a lot between different folder structures, or if they're used by many people with slightly different configurations.

Code: Select all

Dim iim1, iret
'initialize iMacros instance
set iim1 = CreateObject ("imacros")

DIM oShell, ofso, wshell
Set oShell = CreateObject("WScript.Shell")
Set ofso = CreateObject("Scripting.FileSystemObject")
oShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName)
set wshell = createobject("wscript.shell")

iret = iim1.iimPlay(wshell.currentdirectory&"Your Macro.iim")
iret = iim1.iimPlay(wshell.currentdirectory&"Your Next Macro.iim")
iret = iim1.iimPlay(wshell.currentdirectory&"Your Final Macro.iim")

Re: Expansion of new 'How To'

Posted: Wed Apr 27, 2011 6:42 pm
by Volodath
How does that affect performance when compared to just storing the script in the macro itself?

I'm not a huge nerd (just a little) and don't understand much as to the actual nuts and bolts of process usage, but it would be interesting to see what processing power usage there would be between the two.

Re: Expansion of new 'How To'

Posted: Thu Apr 28, 2011 7:19 am
by MattBell7
i dont think it makes a difference, the reason for using the vbs is that it allows you to do things imacros doesn't, like conditionals. The only difference to having this purely in a single macro, will be the impact of the wscript.exe that runs on your machine, which is fairly minimal anyway...

Re: Expansion of new 'How To'

Posted: Mon May 02, 2011 8:04 am
by Tom, Tech Support
Hi Matt,

I like your suggestion, and I use this myself quite a bit, but there's an even quicker way to obtain the script path:

Code: Select all

scriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
I will update the How-To with your suggestion!

Re: Expansion of new 'How To'

Posted: Mon Sep 02, 2013 5:17 pm
by FoxDot
Is there any way to determine iMacros folder locations using JavaScript??

Re: Expansion of new 'How To'

Posted: Tue Sep 03, 2013 3:29 pm
by FoxDot
Actually I found a partial solution:

Code: Select all

SET !DATASOURCE Address.csv
SET !EXTRACT {{!DATASOURCE}}
PROMPT {{!EXTRACT}}
but will work only if Address.csv file is present in Datasource folder.

I know this value is stored somewhere in iMacros itself ))

It will be better and the best solution if I could extract the value from user_pref() - Firefox profile preferences :)

Code: Select all

user_pref("extensions.imacros.defdatapath", "D:\\01. iMacros\\Datasources");

Re: Expansion of new 'How To'

Posted: Wed Sep 04, 2013 11:01 am
by Tom, Tech Support
Hi FoxDot,

You can get the location of the DataSources folder from the !FOLDER_DATASOURCE built-in variable.

You can also retrieve it using the built-in Javascript scripting interface in iMacros for Firefox with the following:

Code: Select all

imns.Pref.getFilePref("defdatapath").path

Re: Expansion of new 'How To'

Posted: Thu Sep 05, 2013 9:28 am
by FoxDot
Thanks Tom, this is what i was looking for:

Code: Select all

imns.Pref.getFilePref("defdatapath").path