autohotkey - Handling loops in AHK script -


I am thinking - What is the best way to handle loop in AHK script?

Example instead:

 ; [= IE.document.getElementsByClassName ( "name") 0] .innertext String_Object: Results gather 1 sleep 1000 Addr1 = StrSplit (addr1, "` ") if (substr (Addr1, 1, 2) =" M ") {Addrl : = String_object [2] ",". Trim (string_object [3]) ",". PostCode MsgBox,% Addr1%} Other {Addr1: = String_Object [1] ",". Trim (string_object [2]) ",". PostCode MsgBox,% Addr1%}; = IE.document.getElementsByClassName ( "name") [1] .innertext String_Object: Results collected 2 Sleep 1000 Addr2 = StrSplit (addr2, "` ") if (substr (Addr2, 1, 2) =" M ") {Addr2 : = String_object [2] ",". Trim (string_object [3]) ",". PostCode MsgBox,% Addr2%} Other {Addr2: = String_Object [1] ",". Trim (string_object [2]) ",". PostCode MsgBox,% Addr2%}  

I want to do something like this (note this is a pseudocode):

  j = 0 i = 1 while (i & lt; = 5) {sleep 1 1000 Adder [i]: = IE.document.getElementsByClassName ( "name") [J] .innertext String_objekt = Strisplit (Eder [i] "` ") if (Substrost) (ader [i], 1, 2) = "mk") {adr: [ii]: = string_object [2] ",". Trim (string_object [3]) ",". PostCode MsgBox,% Addr [i]%} Other [Addr [i]: = String_Object [1] ",". Trim (string_object [2]) ",". Postcode MSBBC,% Addr [i]%} J = J + 1I = I + 1}  

Is it possible to complete it in AH?

I think what you are looking for is Loops and A_Index

A_Index automatically tracks the current loop action of that loop in which it exists; This is unique to your loop, and nested loops will track their own A_Index, for a simple example, try the following code:

  loop, 3 {messagebox, external-loop% A_Index% loop , 3 {MsgBox, Inner-loop% A_Index%}}  

Depending on your proxy code, you will do anything for the effect of:

  Loop, 5 {sleep 1000 ADR: = IE.document.getElementsByClassName ("name") [A_Index - 1] .innertext String_Object: = StrSplit (addr [A_Index], "` ") if (substr (p [A_Index ], 1, 2) = "m") {p [A_Index]: = string_object [2] ",". Trim (string_object [3]) ",". PostCode MsgBox,% Addr [A_Index]%} Other [Addr [A_Index]: = String_Object [1] ",". Trim (string_object [2]) ",". PostCode MsgBox,% Addr [A_Index]%}}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -