1. Trang chủ
  2. » Công Nghệ Thông Tin

Giáo Trình How To Use AutoIt A Professional Manner part 100 pps

7 168 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 21,52 KB

Nội dung

Remarks Please only disable break with good reason. AutoIt normally creates a tray icon when running, and right-clicking this icon allows the user to pause or exit the script. If Break is disabled (0), then the user cannot terminate the script this way. Related None. Example Break(0) ;Disable break Function Reference Call Calls a user-defined function contained in a string parameter. Call ( "function" [, param1 [, param2 [, paramN ]]] ) Parameters function The name of the user function to call. param Arguments that will be passed to the function being invoked. Return Value Success: Returns the return value of the called function. Both @error and @extended may contain values if the called function set them. Failure: Sets @error to 0xDEAD and @extended to 0xBEEF if the function does not exist or invalid number of parameters. Remarks The function cannot be a built-in AutoIt function or plug-in function. The function can pass arguments to functions, however, ByRef parameters are not supported; there is no way to retrieve the ByRef parameter. A special array can be passed in lieu of individual parameters. This array must have it's first element set to "CallArgArray" and elements 1 - n will be passed as seperate arguments to the function. If using this special array, no other arguments can be passed to Call(). See example for a demonstration. Both Call() itself can set @error or the called function can set @error. If Call() sets @error the value will be 0xDEAD and @extended will also be set to 0xBEEF. See the example for a demonstration of testing for a function that was not found. Related AdlibEnable Example ; This calls a function accepting no arguments. Call("Test1") ; This calls a function accepting one argument and passes it an argument. Call("Test2", "Message from Call()!") ; This demonstrates how to use the special array argument. Global $aArgs[4] $aArgs[0] = "CallArgArray" ; This is required, otherwise, Call() will not recognize the array as containing arguments $aArgs[1] = "This is a string" ; Parameter one is a string $aArgs[2] = 47 ; Parameter two is a number Global $array[2] $array[0] = "Array Element 0" $array[1] = "Array Element 1" $aArgs[3] = $array ; Parameter three is an array ; We've built the special array, now call the function Call("Test3", $aArgs) ; Test calling a function that does not exist. This shows the proper way to test by ; checking that both @error and @extended contain the documented failure values. Local Const $sFunction = "DoesNotExist" Call($sFunction) If @error = 0xDEAD And @extended = 0xBEEF Then MsgBox(4096, "", "Function does not exist.") Func Test1() MsgBox(4096, "", "Hello") EndFunc Func Test2($sMsg) MsgBox(4096, "", $sMsg) EndFunc Func Test3($sString, $nNumber, $aArray) MsgBox(4096, "", "The string is: " & @CRLF & $sString) MsgBox(4096, "", "The number is: "& @CRLF & $nNumber) For $i = 0 To UBound($aArray) - 1 MsgBox(4096, "", "Array[" & $i & "] contains:" & @CRLF & $aArray[$i]) Next EndFunc Function Reference CDTray Opens or closes the CD tray. CDTray ( "drive", "status" ) Parameters drive The drive letter of the CD tray to control, in the format D: , E: , etc. status Specifies if you want the CD tray to be open or closed: "open" or "closed" Return Value Success: Returns 1. Failure: Returns 0 if drive is locked via CD burning software or if the drive letter is not a CD drive. Remarks CDTray works as expected with virtual CD drives such as DAEMON Tools. CDTray does not work on non-local/mapped CD drives; CDTray must be run from the computer whose drive it affects. CDTray("X:", "close") tends to return 0 even on laptop-style cd trays that can only be closed manually. Related DriveGetType, DriveStatus Example ; Open the CD tray on drive E: CDTray("E:", "open") Function Reference Execute Execute an expression. Execute ( string ) Parameters string string representing an expression to be evaluated. Return Value Success: Returns the value of the evaluated expression. Failure: Returns "" (blank string) with @error set not to 0. Remarks None. Related Assign, Eval, Call Example $a=1 $v=Execute("$a+1") ; $v is set to 2 Function Reference AutoItSetOption Changes the operation of various AutoIt functions/parameters. AutoItSetOption ( "option" [, param] ) Parameters option The option to change. See Remarks. param [optional] The value to assign to the option. The type and meaning vary by option. See remarks below. If the param is not provided, then the function just returns the value already assigned to the option. The keyword Default can be used for the parameter to reset the option to its default value. Return Value Returns the value of the previous setting for the option. Remarks You may use Opt() as an alternative to AutoItSetOption(). AutoIt will halt with an error message if the requested option is unknown. Options are as follows: Option Param CaretCoordMode Sets the way coords are used in the caret functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window ExpandEnvStrings Changes how literal strings and % symbols are interpreted. By default strings are treated literally, this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%". 1 = expand environment variables (similar to AutoIt v2) 0 = do not expand environment variables (default) Without this option the usual way would be: "The temp directory is: " & EnvGet("temp") . one is a string $aArgs[2] = 47 ; Parameter two is a number Global $array[2] $array[0] = "Array Element 0" $array[1] = "Array Element 1" $aArgs[3] = $array ; Parameter. contained in a string parameter. Call ( "function" [, param1 [, param2 [, paramN ]]] ) Parameters function The name of the user function to call. param Arguments that will be passed to the. functions/parameters. AutoItSetOption ( "option" [, param] ) Parameters option The option to change. See Remarks. param [optional] The value to assign to the option. The type and meaning vary by

Ngày đăng: 08/07/2014, 21:20

TỪ KHÓA LIÊN QUAN