创建一个批处理文件来打开firefox,然后运行一个宏(等待它完成),然后运行另一个宏

时间:2013-08-09 23:25:50

标签: batch-file imacros

我想: (1)加载Firefox (2)运行Iopus Imacro(.iim) - 等待此完成,然后 (3)运行下一个宏。

到目前为止,我已经尝试了启动/等待 - 调用以及我可以在互联网上找到的许多其他建议,这是我到目前为止(只运行完美 - 只要只有一个宏文件(。 iim)玩):

@ECHO ON
ECHO
ECHO You have 5 sec to close this Window to prevent the Macro from running...
timeout 5
ECHO Start Firefox and wait another 10 seconds...
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
timeout 10
ECHO Now running the macro (in a 2nd Tab)...
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro1.iim"

rem Macro Execution completed
ECHO FINISHED!

当我尝试添加更多要运行的文件时,如下所示:

@ECHO ON
ECHO
ECHO You have 5 sec to close this Window to prevent the Macro from running...
timeout 5
ECHO Start Firefox and wait another 10 seconds...
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
timeout 10
ECHO Now running the macro (in a 2nd Tab)...
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro1.iim"
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro2.iim"    
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro3.iim"

rem Macro Execution completed
ECHO FINISHED!

Firefox启动然后立即加载所有.iim文件,但没有一个运行。

我还尝试创建多个批处理文件,以便运行一个,然后在第一个完成时调用第二个...不起作用!

此代码launch-macros-one-by-one-from-a-batch-file

cd C:\Program Files (x86)\Mozilla Firefox\
start firefox.exe
ping -n 05 127.0.0.1>null
start /wait firefox.exe imacros://run/?m=unlimited1.iim
start /wait firefox.exe imacros://run/?m=unlimited2.iim

启动了2个firefox窗口,但没有运行任何宏!

@foxdrive - 这是我在评论中提到的代码@ 9pm左右......

`@ECHO ON
ECHO
ECHO You have 5 sec to close this Window to prevent the Macro from running...
timeout 5
ECHO Start Firefox and wait another 10 seconds...
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
timeout 10
ECHO Now running the macro (in a 2nd Tab)...
set "tempfile=C:\Users\Public\Documents\iMacros\Macros\flag.txt"
type nul>"%tempfile%"    
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "imacros://run/?m="mymacro1.iim"
:loop1
if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop1

type nul>"%tempfile%"    
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "imacros://run/?m="mymacro2.iim"   
:loop2
if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop2

type nul>"%tempfile%"    
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "imacros://run/?m="mymacro3.iim"
:loop3
if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop3

rem Macro Execution completed
ECHO FINISHED!`  

1 个答案:

答案 0 :(得分:3)

现在宏在完成时删除了这个临时文件,这应该可以工作:

@echo off
ECHO You have 5 sec to close this Window to prevent the Macro from running...
timeout 5
ECHO Start Firefox and wait another 10 seconds...
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
timeout 10
set "tempfile=C:\Users\Public\Documents\iMacros\Macros\flag.txt"
echo macro 1 running
type nul>"%tempfile%"    
start "" /w /b "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro1.iim"
:loop1
if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop1
echo macro 2 running
type nul>"%tempfile%"    
start "" /w /b "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro2.iim"    
:loop2
if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop2
echo macro 3 running
type nul>"%tempfile%"    
start "" /w /b C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="mymacro3.iim"
:loop3
if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop3