Page 1 of 1

How to determine iMacros folder locations from VBScript

Posted: Tue Apr 26, 2011 11:15 am
by Tom, Tech Support
Have you ever wanted to be able to reference the various iMacros folders from your script? Did you know that with iMacros 7, the default folder locations are specified in the Windows Registry?

You can add the following function to your VBScripts to easily retrieve these folder locations:

Code: Select all

Function GetiMacrosFolder(folderName)
	' Valid values for folderName are: Macros, DataSources, Downloads, and Logs.
	Dim WshShell
	Set WshShell = CreateObject("WScript.Shell")
	GetiMacrosFolder = WshShell.RegRead("HKEY_CURRENT_USER\Software\iOpus\iMacros\Folder" & folderName)
End Function
UPDATE:
MattBell7 wrote:Just seen the How to Tom just posted, http://forum.iopus.com/viewtopic.php?f=6&t=12790, and figured it may be worth adding this to it.

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 scriptPath
scriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")

iret = iim1.iimPlay(scriptPath & "Your Macro.iim")
iret = iim1.iimPlay(scriptPath & "Your Next Macro.iim")
iret = iim1.iimPlay(scriptPath & Your Final Macro.iim")
See this post for more discussion.

Re: How to determine iMacros folder locations from VBScript

Posted: Fri May 06, 2011 2:57 pm
by Tom, Tech Support
In iMacros 7, you have programmatic control of the path settings by the following means:
  • Macro Folder: Specify the macro path and file name via iimPlay().
  • Downloads Folder: Specify the download path using the FOLDER parameter of the ONDOWNLOAD and SAVEAS commands.
  • DataSources Folder: Use SET !FOLDER_DATASOURCE to specify the folder containing input files.
  • Performance Log Folder: Use SET !FOLDER_STOPWATCH to specify the folder location for the file that contains the measurement data created with the STOPWATCH command.