Giáo Trình How To Use AutoIt A Professional Manner part 72 docx

6 289 0
Giáo Trình How To Use AutoIt A Professional Manner part 72 docx

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

Thông tin tài liệu

Opt("OnExitFunc","OnAutoItExit");"OnAutoItExit" called Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't Opt("SendKeyDelay", 5) ;5 milliseconds Opt("SendKeyDownDelay", 1) ;1 millisecond Opt("TCPTimeout",100) ;100 milliseconds Opt("TrayAutoPause",1) ;0=no pause, 1=Pause Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon Opt("TrayMenuMode",0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode",0) ;0=disable, 1=enable Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect Opt("WinSearchChildren", 1) ;0=no, 1=search children also Opt("WinTextMatchMode", 1) ;1=complete, 2=quick Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to - 4=Nocase Opt("WinWaitDelay", 250) ;250 milliseconds Function Reference GUICtrlGetHandle trả lại handle của control GUICtrlGetHandle ( controlID ) Parameters controlID control id Return Value Success: Returns handle Failure: Returns 0. Remarks ko hỗ trợ các control sau: Dummy, Graphic, Object, ListViewItem and TabItem ! ListViewItems và TabItems được quản lý thông qua danh mục. Để có được lập chỉ mục của các bản ghi sử dụng DllCall() và DllStructCreate(). Related GUICtrlRead, GUICtrlGetState, IsHWnd Example #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $hGui, $FileMenu, $OpenItem, $SaveItem, $OptionsMenu Local $ViewItem, $ToolsItem, $ExitItem, $HelpMenu, $AboutItem Local $EndBtn, $Msg $hGui = GUICreate("My GUI", 300, 200) $FileMenu = GUICtrlCreateMenu("&File") $OpenItem = GUICtrlCreateMenuItem("&Open", $FileMenu) $SaveItem = GUICtrlCreateMenuItem("&Save", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $OptionsMenu = GUICtrlCreateMenu("O&ptions", $FileMenu) $ViewItem = GUICtrlCreateMenuItem("View", $OptionsMenu) GUICtrlCreateMenuItem("", $OptionsMenu) $ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu) GUICtrlCreateMenuItem("", $FileMenu) $ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu) $HelpMenu = GUICtrlCreateMenu("&?") $AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu) $EndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20) SetMenuColor($FileMenu, 0xEEBB99) ; BGR color value SetMenuColor($OptionsMenu, 0x66BB99); BGR color value SetMenuColor($HelpMenu, 0x99BBEE) ; BGR color value GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $ExitItem, $EndBtn, $GUI_EVENT_CLOSE ExitLoop Case $AboutItem MsgBox(64, "About ", "Colored menu sample") EndSwitch WEnd EndFunc ;==>Example ; Apply the color to the menu Func SetMenuColor($nMenuID, $nColor) Local $hMenu, $hBrush, $stMenuInfo Local Const $MIM_APPLYTOSUBMENUS = 0x80000000 Local Const $MIM_BACKGROUND = 0x00000002 $hMenu = GUICtrlGetHandle($nMenuID) $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOR($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) ; release Struct not really needed as it is a local $stMenuInfo = 0 EndFunc ;==>SetMenuColor Function Reference GUICtrlGetState trả lại trạng thái của control GUICtrlGetState ( [controlID] ) Parameters controlID controlid Return Value Success: trả lại giá trị của state, xem GUICtrlSetState để biết giá trị. Failure: Returns -1 nếu lỗi control. Remarks các giá trị trả lại enabled/disabled/hidden/show/dropaccepted Trường hợp ngoại lệ ListView controls sẽ trả lại số của item đc chọn Related GUICtrlRead, GUICtrlSetState Example #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $n, $msg GUICreate("My GUI (GetControlState)") $n = GUICtrlCreateCheckbox("checkbox", 10, 10) GUICtrlSetState(-1, 1) ; checked GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd MsgBox(0, "state", StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d", GUICtrlRead($n), GUICtrlGetState($n))) EndFunc ;==>Example . Opt("OnExitFunc","OnAutoItExit");"OnAutoItExit" called Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach. Opt("TrayAutoPause",1) ;0=no pause, 1=Pause Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon Opt("TrayMenuMode",0). thông qua danh mục. Để có được lập chỉ mục c a các bản ghi sử dụng DllCall() và DllStructCreate(). Related GUICtrlRead, GUICtrlGetState, IsHWnd Example #include <GUIConstantsEx.au3>

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