Today i tried script in powershell and it’s the same of a batch file.
To start every macro need to close the previous browser opened and this reset the previous works completed from previous macro.
This solution work with different works, but if I have one site that require 100 xclick/xtype and after i must submit to safe info I can not automatize with this solution.
After Kantu execute 25 xclick/xtype stopped to work, the script close macro, close browser e launch another browser with second macro but lost the previous work.
This solution is the same of batch file that launch browser and macro one after one but not in same browser and same page (that have cookie, cache saved, form filles, login already submit) but in new browser with a new session of site loaded.
Hi, I made a screencast that shows how to run one macro after another with the command line. The source code for the Powershell script can be found on on Github.
The command line switches used are:
$arg = “”“file:///”+ $path_autorun_html + “?macro=”+ $macro + “&closeKantu=1&closeBrowser=0&direct=1&savelog=”+$log+“”“”
I tried this script but every macro close my browser, in the code have taskkill too because every macro to run need browser closed.
I do not know how can continue a macro if the browser need to close.
If the browser remain open firefox notify that firefox is opened and do not run the second macro.
It’s the same of batch file, every macro run firefox + macro and need to closing the lost the previous firefox with all work.
I search a solution to run macro with browser opened and all these script run a firefox instance before run macro, i need to run only macro NOT another instance of firefox that notify that firefox is already open.
I tried batch file and powershell without success because Kantu can not run a macro in automatically with browser opened, have not command to run macro when browser is opened otherwise open new browser with a macro.
Kantu run firefox + macro, NOT only macro this is the diffeence with imacros that can open 1 firefox and unlimited macro without closing firefox.
Actually i do not find any working script to run multiple macros leaving the browser open.
Difference with imacros
Macro javascript of macros run1 firefox (it remain open all day) and run macro one after one
Imacros javascript macro
FIrefox open (rest all day opened)
run macro 1
run macro 2
run macro 1000
Kantu powershell - batch file
Run firefox + macro 1
CLOSE FIREFOX
Run firefox + macro 2
CLOSE FIREFOX
Run firefox + macro 3
CLOSE FIREFOX
Another problem is that powershell do not recognize the time of a macro and use a bad solution to set the time in the script
$timeout_seconds = 60 #max time in seconds allowed for macro to complete (change this value if your macros takes longer to run)
This is a bad solution because if i run 1 macro that require 2 hours and 1 macro that require 10 seconds powershell can not detect the timer for every macro (2 hour and 10 seconds) and use the timer setted in the script.
Imacros detect the exact time of every macros and run one after one in precisely the time required for a macro to complete the job.
$timeout_seconds = 60 #max time in seconds allowed for macro to complete
…Imacros detect the exact time of every macros and run one after one in precisely the time required for a macro to complete the job.
Same here! These 60 seconds are the maximum allowed time. If the macro needs more, the “PlayAndWait” command in the script will return with a timeout error, and even terminate Chrome/Firefox if needed, e. g. if the browse hangs. But if the macro runs faster that is no problem.
if i run 1 macro that require 2 hours and 1 macro that require 10 seconds
Then you set $timeout_seconds = 3600*2 => The 10 seconds macro is still done after 10 seconds. This is just the max. allowed value.
Alternatively, you can also set the timeout on a per macro macro basis:
PlayAndWait LongMacro 7200 <= this macros times out after 7201 seconds
PlayAndWait ShortMacro 10 <= this macros times out after 11 seconds
I look that with firefox do not work well, have you really tried this firefox ?
I do not use Google Chrome and with firefox this script looks like it doesn’t work well.
Try with firefox please, in my test the timer do not respect and it’s possibile to run 1 macro only, to run the seconds need to close previous browser (the same case with batch file).
closeBrowser=0 have not effect i switch from 1 and 0 and i look the same result do nothing-
I hope I got something wrong and can fix it but unfortunately I think this script for firefox doesn’t work well.
closeBrowser=0 have not effect i switch from 1 and 0 and i look the same result do nothing-
In the macros from the screencast, you must remove the selectWindows | tab=close in the first macro. Because there if no tab to close, this closes the browser
in my test the timer do not respect
Important: The Firefox download folder must be the same download folder as specified in the script. => Reason: The script monitors the browser download folder for the Kantu log file to appear! This way it knows when the macro has finished. It also reads this log for the error information, which is in the first line of the log. This is the same in Firefox and in Chrome.
With this done, it works in Firefox, too:
The script is exactly the same as with Chrome. Just the line to start Chrome is now the line to start Firefox.
Today I try again the script and I will apply a lot of attention to the firefox download folder, I write to you as soon as I tried the script again and I tell you if I solved the problems, I thank you
For me the script continue to NOT working, continue to try to open new firefox.
It is very strange that it works to me it seems that it doesn’t work and every macro opens a new browser, I can’t understand how it is possible that it works for you.
I still look for a serious and working solution for firefox to open a macro after another and I haven’t found anything working,
From the error message, Powershell does not know the parameter “-first”. Maybe you have an older version of Powershell. I am on Win 10 and have 5.1. Here is how to check it: Determine installed PowerShell version - Stack Overflow
If your version does not support this paramter, you need to rewrite the script a little bit. What this line does is to read the first line of the Kantu log file.
The first macro run well but at the second reopen the browser and notify that firefox is alrealy opened and do not continue, same with a batch file.
In powershell code of Techsupport i see difference respect the code of powershell found on github can be this the reason ?
The powershell code show taskkill command and this command is used when is necessary to close the browser like my case
{
$status_text = "Macro did not complete within the time given:" + $timeout_seconds
$status_int = -2
#Cleanup => Kill Chrome instance
#taskkill /F /IM chrome.exe /T
}
I think that this script can work only with taskkill active and browser closed otherwise can not work, this cose can run one macro, close browser and run another macro losing the previous work the powershell code tell this.
From the screencast, I see that the powershell script is still waiting for the first macro to finish. Only when it finishes (or reaches timeout) the 2nd macro is started.