☆Read the code Ahk 3-simply fl PV code

Source: Internet
Author: User

Code:

I = 0
Loop
{
I + = 1
Filereadline, line,./url.txt, % I %
If errorlevel <> 0
Break
Run, % line %, Min
Random, stime, 3000,9000
Sleep, % stime %
}
Msgbox. All URL resources are traversed!

Description 1:
Loop is a loop command in the Ahk to repeat a series of commands for a specified number of times. Exit when the break or return command is encountered. The format is:
Loop [, Count]
{
Loop body ......
}
Count cannot be an expression, but can be a variable.
The loop command implies a variable a_index, which is used to record the first loop of the current State. Let's look at an official example:
Loop, 3
{
Msgbox, number of cycles: % a_index %.
Sleep 100
}

Loop
{
If a_index> 25
Break; interrupt cycle
If a_index <20
Continue; skip this loop and start a new loop
Msgbox, the current value of the cyclic variable a_index is % a_index %
}

NOTE 2:
The sleep command is used to wait for the script for a specified time, in milliseconds. For example, if you wait for one second, sleep, 1000

NOTE 3:
In this example, variables are used to store values in the memory. Like most script programs, there is no difference between strings and numbers in the Ahk, and the script will

Row-based judgment, treated differently. variables generally do not need to be declared and can be used directly.
Let's look at an official example:
MySQL var1 = 123
Myvar2 = my string
If myvar2 = my string
{
Msgbox myvar2 contains the string "my string"
}
If myvar1> = 100
{
Msgbox myvar1 contains % myvar1 %, which is larger than 100.
}

The code is easy to understand. Note that the second myvar1 is used as a variable. The percentage symbol is used to include the variable name. The value of myvar1 is displayed in the corresponding position of the dialog box.
To perform a mathematical operation, use the colon equal sign to indicate the operation result of the expression to a variable.
For example: netprice: = price * (1-discount/100)
The I + = 1 code is actually a simplified way of writing I: = I + 1.

Note 4:
Filereadline is a text Operation Command provided by Ahk. The command reads the specified line from the specified text file and assigns a value to the specified variable. Format:
Filereadline, output variable, file name, row number
Errorlevel is a variable embedded in the command. When an error occurs while reading the file (generally because the number of lines reading the file exceeds the limit), errorlevel is assigned a value of 1.

Note 5:
The random command is used to obtain the random number of a specified range. The command format is:
Random: output variable [, minimum, maximum]
Code random, stime, indicates that a random value is obtained between and.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.