For a few of those Commands I had never seen them before, but yep, they are still documented in the Wiki, and I guess they probably still work in v8.9.7.
User on SOF didn't mention their FCI even after I asked them, but OK, here is the complete Thread... Enjoy...!
Original Thread on SOF:
- Imacros javascript macro execute commands after closed browser
User on SOF = camomillo
+ Quotes of Comments (on SOF also):
I have an imacros javascript macro that use some if to execute the commands.
This imacros javascript close in automatically firefox if the are some conditions but execute other commands after firefox is closed.
This imacros javascript grab current ip on internet and save it in variable.
Check if the ip grabbed is #EANF# (not extracted) and close firefox.
Compare with a loop the current ip with a list of ip saved in csv and if current ip is already used close firefox.
Update the loop number.
Update some firefox settings.
Run an iim macro.
Save info in csv.
Open a batch file.
With a loop check the current ip to check the connection internet is up.
This imacros javascript have a problem, after closed firefox because an if statement is true run bat file but the batch file will be run only if the if statement will not found.
Why after the firefox will be closed run start.bat ?
The if were inserted to interrupt the execution of the script and to close firefox but note that the bat file is also loaded.
I need to run start.bat only when firefox not will be closed with iimPlayCode ("TAB CLOSE") command.
This is the codeCode: Select all
//////////////////////////////////////////////////////// /////////////////////// Variables ////////////////////// //////////////////////////////////////////////////////// var jsNewLine = "\n" var Loops = 500 //////////////////////////////////////////////////////// ///////// Clear Cookies And Cache With Imacros ///////// //////////////////////////////////////////////////////// iimPlayCode ("CLEAR") //////////////////////////////////////////////////////// //////////////////// Ip Current Save /////////////////// //////////////////////////////////////////////////////// iimPlayCode ("TAB OPEN") iimPlayCode ("TAB T=2") iimPlayCode ("URL GOTO=https://ident.me/") iimPlayCode ("WAIT SECONDS=10") iimPlayCode ("TAG POS=1 TYPE=PRE ATTR=* EXTRACT=TXT") //////////////////////////////////////////////////////// ////////////// Save Ip Current In Variable ///////////// //////////////////////////////////////////////////////// IpCurrent = iimGetLastExtract(1); //////////////////////////////////////////////////////// /////////////////////// Close Tab ////////////////////// //////////////////////////////////////////////////////// iimPlayCode ("TAB CLOSE") //////////////////////////////////////////////////////// //////////// Ip Current #EANF# Close Browser /////////// //////////////////////////////////////////////////////// if (IpCurrent == "#EANF#") { iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("PAUSE") } //////////////////////////////////////////////////////// ///////////////////////// Loop ///////////////////////// //////////////////////////////////////////////////////// for (i = 0; i < Loops; i ++ ) { //////////////////////////////////////////////////////// ////////////////////// Macro Code ////////////////////// //////////////////////////////////////////////////////// code = ""; code += "CODE:" + jsNewLine code += "SET !ERRORIGNORE YES" + jsNewLine code += "SET !LOADCHECK YES" + jsNewLine code += "SET !REPLAYSPEED FAST" + jsNewLine code += "SET !POINTER YES" + jsNewLine code += "SET !TIMEOUT 30" + jsNewLine code += "SET !TIMEOUT_TAG 0" + jsNewLine code += "SET !EXTRACT_TEST_POPUP NO" + jsNewLine code += "SET !DATASOURCE F:\\ip_addresses_used.csv" + jsNewLine code += "SET !DATASOURCE_COLUMNS 2" + jsNewLine code += "SET !DATASOURCE_LINE " + i + jsNewLine code += "ADD !EXTRACT {{!COL1}}" + jsNewLine iimPlay(code); //////////////////////////////////////////////////////// /////////////// Save Ip Used In Variable /////////////// //////////////////////////////////////////////////////// IpUsed = iimGetLastExtract(1); //////////////////////////////////////////////////////// ///////////////////// Display Loop ///////////////////// //////////////////////////////////////////////////////// iimDisplay("Completed Loop " + i) //////////////////////////////////////////////////////// /// Compare Ip Current (Extracted) With Ip Used (Csv) // //////////////////////////////////////////////////////// if (IpCurrent == IpUsed) { iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("PAUSE") } } //////////////////////////////////////////////////////// ////////////////// Settings On Firefox ///////////////// //////////////////////////////////////////////////////// prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); prefs.setBoolPref("pdfjs.disabled", true); // Disable Pdf Js prefs.setBoolPref("webgl.disabled", true); // Disable WebGL prefs.setBoolPref("webgl.enable-webgl2", false); // Disable WebGL2 prefs.setBoolPref("media.peerconnection.enabled", false); // Disable WebRTC prefs.setBoolPref("xpinstall.signatures.required", false); // Disable Xpi Addons Signature (For Ras) prefs.setCharPref("browser.startup.homepage", "about:memory"); // Browser Startup Homepage prefs.setIntPref("browser.display.use_document_fonts", 0); // Disable Numbers Of Fonts prefs.setIntPref("browser.sessionhistory.max_entries", 2); // Disable Tab History //////////////////////////////////////////////////////// /////////////////////// Run Macro ////////////////////// //////////////////////////////////////////////////////// iimPlay ("mymacro.iim") //////////////////////////////////////////////////////// ///////////////////// Save Ip Used ///////////////////// //////////////////////////////////////////////////////// IpNote = "VM-Views-1"; iimSet("IpCurrent", IpCurrent); // Need It To Store Variable iimSet("IpNote", IpNote); // Need It To Store Variable iimPlayCode ("SET !EXTRACT {{IpCurrent}}\n ADD !EXTRACT {{!NOW:dd-mm-yyyy_hh-nn}}\n ADD !EXTRACT {{IpNote}}\n SAVEAS TYPE=EXTRACT FOLDER=F:\\ FILE=ip_addresses_used.csv"); //////////////////////////////////////////////////////// ///////////////////// Run Bat File ///////////////////// //////////////////////////////////////////////////////// var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("D:\\Programmi Installati\\Macro\\bat\\start.bat"); file.launch(); //////////////////////////////////////////////////////// ////////////// Checking Connection Status ////////////// //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// /////////////////////// Variables ////////////////////// //////////////////////////////////////////////////////// var Checks = 100 //////////////////////////////////////////////////////// ///////////////////////// Loop ///////////////////////// //////////////////////////////////////////////////////// for (c = 0; c < Checks; c ++ ) { //////////////////////////////////////////////////////// //////////////////// Ip Current Save /////////////////// //////////////////////////////////////////////////////// iimPlayCode ("TAB OPEN") iimPlayCode ("TAB T=2") iimPlayCode ("URL GOTO=https://ident.me/") iimPlayCode ("WAIT SECONDS=10") iimPlayCode ("TAG POS=1 TYPE=PRE ATTR=* EXTRACT=TXT") //////////////////////////////////////////////////////// ////////////// Save Ip Current In Variable ///////////// //////////////////////////////////////////////////////// IpCurrent = iimGetLastExtract(1); //////////////////////////////////////////////////////// /////////////////////// Close Tab ////////////////////// //////////////////////////////////////////////////////// iimPlayCode ("TAB CLOSE") iimPlayCode ("WAIT SECONDS=600") //////////////////////////////////////////////////////// //////////// Ip Current #EANF# Close Browser /////////// //////////////////////////////////////////////////////// if (IpCurrent == "#EANF#") { iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("TAB CLOSE") iimPlayCode ("PAUSE") } }
Be honest...!, who knew about '!LOADCHECK' and '!POINTER'...!?, ah-ah...!?'FCIM' as a start, read my Sig (hum, maybe on the iMacros Forum)... - But your Script is a complete "Joke", sorry...!, this is 2019 but it is full of Commands that have been deprecated for at least 10 years...!
(And for a few, that I had never heard of, ah-ah...!)
- Open a parallel Thread on the iMacros Forum, nbd on SOF will be able to read your Script...
I will quote your Thread anyway after 2 or 3 days as your Thread is really a "Collector Item", ah-ah...!, quite interesting for the iMacros Forum though..., miam-miam...!
– chivracq 2 days ago
Hum OK, and I read your "Scenario Description", but it doesn't really make sense to me to be honest, and I don't even understand your only Qt: "Why after the firefox will be closed run start.bat ?", which again doesn't make sense, or even just grammatically...
– chivracq 2 days ago
Hi i need to stop script execution after if (IpCurrent == "#EANF#") or if (IpCurrent == IpUsed) in these case i need to stop the execution of script and close firefox and do not continue the script. actually the script continue and execute the bat file.
– camomillo 2 days ago
Well, "stop script execution" is not complicated, that's automatic and default behaviour with '#EANF#' if you don't use '!ERRORIGNORE', or with 'EVAL()' + 'MacroError()' and also with 'EVENT:FAIL_IF_FOUND'.
- And to close FF, you have a Thread on the iMacros Forum with 5 or 6 different ways to do so, and most of those 5 or 6 can be called conditionally, especially if using a '.js' Script. – chivracq
And yep, '!TIMEOUT' and '!TIMEOUT_TAG' do still work (in v8.8.2 + v8.9.7 for FF), I also still have a few in some of my "older" Scripts from 10 or 8 years ago that I didn't bother to update (and still use)...