11

I can't figure out how to use imacros with JavaScript. I have looked at their Help, have seen countless examples here on Stack Overflow, but don't know what am missing. It has not been explained clearly anywhere.

Here is what I tried:

  1. Used the example explained in their help file here: http://wiki.imacros.net/JavaScript

    But nothing happens when I click the 'Click Here to Run' link (even in IE with ActiveX). NOTE: I don't have imacros for IE - the example shown above has image of the macro start in IE, but run in Firefox. And no further explanation..

  2. Tried to import a JS file into imacros, but it doesn't seem to be working for me.

When I use code like the following:

var macro;
macro = "CODE:";
macro += "XXXXXX" + "\n";
macro += "XXXXXX" + "\n";

....
iimPlay(macro);

It says:

"Error -1100: Unknown command: VAR at line: 1"
  1. Tried to use the above inside a script tag of an HTML page, & load the functions on page-load/click. But that doesn't work either.

What am I doing wrong, and what do I need to do?

Soon after I posted this, I think I got it to work for a while. I was able to open a JS file which opened a URL. So I had deleted the Q. But now it isn't working again, and I can't figure out why.. Can somebody help?

Basically I am having the exact same problem as this person here: Javascript and Imacro to Open Google.com I get the same 'unknown command: var' as him. And their question remains unresolved too.

halfer
  • 19,824
  • 17
  • 99
  • 186
user3001859
  • 265
  • 1
  • 3
  • 13

3 Answers3

16

It looks like you are trying to run javascript inside an iim file. Open notepad or another text editor and paste the following code:

var test;
test ="CODE:";
test +="SET !ERRORIGNORE YES "+"\n";
test +="URL GOTO=www.google.com "+"\n";

iimPlay(test)

Save the file with a .js extension. Next open up firefox and the iMacros addon. Go to Manage -> Settings -> Paths Tab -> Folder Datasource. Enter the path where you saved the file above. Refresh iMacros by clicking the iMacro button on and off. The javascript file should show up in the left pane. Run the file to test.

Folder DataSource

You should notice the icon to the left of the file name is different for the javascript files and the extension is ".js" instead of ".iim".

BaSsGaz
  • 666
  • 1
  • 18
  • 31
Creamstout10
  • 513
  • 4
  • 15
  • Thanks a lot for the great replies. It worked.. almost.. It works with some probs on my laptop. When I copy the files in the default dir, or when I change the path to point to the JS file (as you showed), the js files become totally blank. Luckily, I had them open in notepad++ & was able to recover them, but its really strange. Tried it several times, and this happened each time. Even when imacros is not open (as I thought, when I copy files while imacros is open, it must be overwriting them somehow). But this happened when the plugin was closed too. It worked fine on my old desktop however. – user3001859 Aug 23 '14 at 07:17
  • Also won't the JS files work on the imacros 10 desktop software? (not the plugin)? For one, the JS files don't even show up in the left panel there. When I open them manually, it says 'Unknown command: VAR at line: 1'. And the edit macro button is inactive (indicating no file is loaded). – user3001859 Aug 23 '14 at 07:18
4

Good answer Creamstout83

enter image description here

I would also add this to answer above. Un checking this option will speed up the process. And checking it will enable better debugging.

edinvnode
  • 3,497
  • 7
  • 30
  • 53
  • 1
    Be careful :) If you have it checked "Show Javascript during replay" you'll be able to stop infinite loop by iMacros. If you have it unchecked - you won't be able to stop infinite loop. – whitesiroi May 16 '15 at 08:29
3

If you're experiencing this problem while using Chrome to run iMacros; the answer is really simple:

Download Firefox and run the iMacros plugin on there.

I experienced the same problem, receiving the error message: "Error -1100: Unknown command: VAR at line: 1", while using Chrome.

But with Firefox I can now run javascript files, have more options to play around with, and less bugs to disrupt my scrapes.

troy
  • 165
  • 1
  • 4
  • Yes, iMacros on Chrome drove me crazy but it actually is not as buggy on Chrome Canary if you dare to try. I do agree Firefox works best but I had to use Chrome for my own reasons. – Svet Mar 28 '16 at 14:03
  • That is true. Chrome may have improved by now. However, it's useful to use Firefox if you use Chrome because you could have it running in the background while you use Chrome for browsing. – troy Mar 29 '16 at 17:15
  • Imacros add-on doesn't support firefox quantum. What to do now?? – GradDev Mar 23 '18 at 03:20