Giáo Trình How To Use AutoIt A Professional Manner part 77 ppt

5 144 0
Giáo Trình How To Use AutoIt A Professional Manner part 77 ppt

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

Thông tin tài liệu

GUICreate, GUICtrlCreate , GUICtrlRead, GUIOnEventMode (Option), GUIEventOptions (Option), GUIGetCursorInfo Example #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() ; ; Example - Press the button to see the value of the radio boxes ; The script also detects state changes (closed/minimized/timeouts, etc). Func Example() Local $button_1, $group_1, $radio_1, $radio_2, $radio_3 Local $radioval1, $radioval2, $msg Opt("GUICoordMode", 1) GUICreate("Radio Box Demo", 400, 280) ; Create the controls $button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40) $group_1 = GUICtrlCreateGroup("Group 1", 30, 90, 165, 160) GUIStartGroup() $radio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20) $radio_2 = GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20) $radio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20) ; Init our vars that we will use to keep track of GUI events $radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button $radioval2 = 2 ; Show the GUI GUISetState() ; In this message loop we use variables to keep track of changes to the radios, another ; way would be to use GUICtrlRead() at the end to read in the state of each control While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "", "Dialog was closed") Exit Case $msg = $GUI_EVENT_MINIMIZE MsgBox(0, "", "Dialog minimized", 2) Case $msg = $GUI_EVENT_MAXIMIZE MsgBox(0, "", "Dialog restored", 2) Case $msg = $button_1 MsgBox(0, "Default button clicked", "Radio " & $radioval1) Case $msg >= $radio_1 And $msg <= $radio_3 $radioval1 = $msg - $radio_1 EndSelect WEnd EndFunc ;==>Example Function Reference GUIGetStyle Retrieves the styles of a GUI window. GUIGetStyle ( [ winhandle] ) Parameters winhandle [optional] Windows handle as returned by GUICreate (default is the previously used window). Return Value Success: returns a two-element array that containing the styles information: $array[0] = Style $array[1] = ExStyle Failure: Returns 0. Remarks Be carefull Style changes after GUISetState(). Related GUICreate, GUISetStyle Example #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $NewStyle = False, $hWnd, $Style, $GuiStyles, $Msg $hWnd = GUICreate("Gui Style", 260, 100) $Style = GUICtrlCreateButton("Set Style", 45, 50, 150, 20) $GuiStyles = GUIGetStyle($hWnd) ; be careful the style change after opening GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Style If Not $NewStyle Then GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW)) GUICtrlSetData($Style, 'Undo Style') $NewStyle = True Else GUISetStyle($GuiStyles[0], $GuiStyles[1]) GUICtrlSetData($Style, 'Set Style') $NewStyle = False EndIf Case Else EndSwitch WEnd EndFunc ;==>Example 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") ExpandVarStrings Changes how literal strings and variable/macro ($ and @) symbols are interpreted. By default strings are treated literally, this option allows you to use variables and macros inside strings, e.g., "The value of var1 is $var1$". 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign". 0 = do not expand variables (default) . 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. [, 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. = False EndIf Case Else EndSwitch WEnd EndFunc ;==>Example Function Reference AutoItSetOption Changes the operation of various AutoIt functions/parameters. AutoItSetOption

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

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan