If statement iMacros if语句[需要帮助]

If statement iMacros if语句[需要帮助],if-statement,imacros,If Statement,Imacros,我目前正在尝试做一个if/else语句,但是我无法让它工作 这是我的代码: SET !ERRORIGNORE YES URL GOTO=https://en.wikipedia.org/wiki/Main_Page WAIT SECONDS=2 SET !VAR1 {{!URLCURRENT}} PROMPT {{!VAR1}} WAIT SECONDS=2 EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV

我目前正在尝试做一个if/else语句,但是我无法让它工作

这是我的代码:

SET !ERRORIGNORE YES
URL GOTO=https://en.wikipedia.org/wiki/Main_Page
WAIT SECONDS=2
SET !VAR1 {{!URLCURRENT}}
PROMPT {{!VAR1}} 
WAIT SECONDS=2
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>UL>LI:nth-of-type(3)>A" BUTTON=0
WAIT SECONDS=2
SET !VAR2 {{!URLCURRENT}}
PROMPT {{!VAR2}}
SET !VAR3 EVAL("var d=\"{{!VAR1}}\"; var s=\"{{!VAR2}}\" ; if (d==s) {var x=https://www.google.de/;}x; else {var y=https://www.youtube.com;} y;")
URL GOTO={{!VAR3}}
(提示是查看!VAR的设置是否正确)

我试图以wikipedia为例,将Web链接保存为VAR1,然后转到另一个页面,我将其设置为VAR2。 在那之后,我想比较它们,检查它们,然后选择它们是否不同(很明显是不同的),imacro是否应该访问youtube

有人可以帮忙吗?我不想在iMacro中使用.js,我知道这是可能的,但我不知道如何

我将此代码用作参考:

我非常喜欢的一个例子如下:(我需要打开 在某些游戏中,在20h-08h之间按开关On/Off按钮点亮 在页面上。然后我使用:)


SET-Light-EVAL(“var d=\”{{{!NOW:hh}}}”if((d>7)和&(d好的,我让它为我工作,对它添加了一些注释

URL GOTO=https://en.wikipedia.org/wiki/Main_Page
WAIT SECONDS=1

'Set the VAR1 to the current url= https://en.wikipedia.org/wiki/Main_Page
SET !VAR1 {{!URLCURRENT}}
WAIT SECONDS=1
URL GOTO=https://en.wikipedia.org/wiki/Portal:Featured_content
WAIT SECONDS=1

'Set the VAR2 to the current url= https://en.wikipedia.org/wiki/Portal:Featured_content
SET !VAR2 {{!URLCURRENT}}
'   1.Now !VAR3 is our answer from the if statement
'   2.We need to assign the text from {{!VAR1}} to a var x,y,z,...
'     In this case, we use the letter d and s, and assign text with \"....\" to the var
'   3.We check if d and s are equal by if (d==s), there is also not equal (d!=s)
'     Or bigger(but only for numbers) (d>s) or smaller (d<s)
'   4.After the if we say what !VAR3 should become if the if statement is right
'     This is done by creating a new var (in this case the x)
'     However the output shall be again a text, so we assign x to https://www.google.de
'     And do this by assigning text to a var with  \"....\"        so in this case {var x = \"https://www.google.de\";}
'   5.After that we add the else, if the statement was false, and assign x to the text, which should
'         !Be VAR3  when the statement was wrong, and we do this again the same way        so in this case {var x=\"https://www.youtube.com\";}
'       6. At the end we "call" x and tell that whatever x has become, it is now !VAR3
SET !VAR3 EVAL("var d=\"{{!VAR1}}\"; var s=\"{{!VAR2}}\" ; if (d==s){var x = \"https://www.google.de\";} else {var x=\"https://www.youtube.com\";} x;") 

'checking if code worked (and it did)
URL GOTO={{!VAR3}}

'you can of course change the SET !VAR1 or !VAR2 to some text inside a page, or whatever you like
URL转到=https://en.wikipedia.org/wiki/Main_Page
等待秒数=1
'将VAR1设置为当前url=https://en.wikipedia.org/wiki/Main_Page
SET!VAR1{{!URLCURRENT}
等待秒数=1
URL转到=https://en.wikipedia.org/wiki/Portal:Featured_content
等待秒数=1
'将VAR2设置为当前url=https://en.wikipedia.org/wiki/Portal:Featured_content
SET!VAR2{{!URLCURRENT}
'1.现在!VAR3是if语句中的答案
'2.我们需要将{{!VAR1}中的文本分配给变量x,y,z,。。。
'在本例中,我们使用字母d和s,并将带有\“…”的文本分配给变量
'3.我们通过if(d==s)检查d和s是否相等,也有不相等的(d!=s)
'或更大(但仅适用于数字)(d>s)或更小(d
URL GOTO=https://en.wikipedia.org/wiki/Main_Page
WAIT SECONDS=1

'Set the VAR1 to the current url= https://en.wikipedia.org/wiki/Main_Page
SET !VAR1 {{!URLCURRENT}}
WAIT SECONDS=1
URL GOTO=https://en.wikipedia.org/wiki/Portal:Featured_content
WAIT SECONDS=1

'Set the VAR2 to the current url= https://en.wikipedia.org/wiki/Portal:Featured_content
SET !VAR2 {{!URLCURRENT}}
'   1.Now !VAR3 is our answer from the if statement
'   2.We need to assign the text from {{!VAR1}} to a var x,y,z,...
'     In this case, we use the letter d and s, and assign text with \"....\" to the var
'   3.We check if d and s are equal by if (d==s), there is also not equal (d!=s)
'     Or bigger(but only for numbers) (d>s) or smaller (d<s)
'   4.After the if we say what !VAR3 should become if the if statement is right
'     This is done by creating a new var (in this case the x)
'     However the output shall be again a text, so we assign x to https://www.google.de
'     And do this by assigning text to a var with  \"....\"        so in this case {var x = \"https://www.google.de\";}
'   5.After that we add the else, if the statement was false, and assign x to the text, which should
'         !Be VAR3  when the statement was wrong, and we do this again the same way        so in this case {var x=\"https://www.youtube.com\";}
'       6. At the end we "call" x and tell that whatever x has become, it is now !VAR3
SET !VAR3 EVAL("var d=\"{{!VAR1}}\"; var s=\"{{!VAR2}}\" ; if (d==s){var x = \"https://www.google.de\";} else {var x=\"https://www.youtube.com\";} x;") 

'checking if code worked (and it did)
URL GOTO={{!VAR3}}

'you can of course change the SET !VAR1 or !VAR2 to some text inside a page, or whatever you like