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

6 175 0
Giáo Trình How To Use AutoIt A Professional Manner part 45 pps

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

Thông tin tài liệu

32) $n2 = GUICtrlCreateIcon(@WindowsDir & "\cursors\horse.ani", -1, 0, 40, 32, 32) GUISetState(@SW_SHOW) Dim $a = 0, $b = 0 While ($a < 300) And ($b < 300) $a = $a + Int(Random(0, 1) + 0.5) $b = $b + Int(Random(0, 1) + 0.5) GUICtrlSetPos($n1, $a, 0) GUICtrlSetPos($n2, $b, 40) Sleep(20) WEnd Sleep(1000) Opt("GUICoordMode", $iOldOpt) EndFunc ;==>Example2 Function Reference GUICtrlCreateInput tạo ra Input control cho GUI để nhập hiện chuỗi kí tự. GUICtrlCreateInput ( "text", left, top [, width [, height [, style [, exStyle]]]] ) Parameters text text hiện trị sẵn trên control left tọa độ X top tọa độ Y width chiều rộng height chiều cao style kiểu. xem thêm GUI Control Styles Appendix. default ( -1) : $ES_LEFT, $ES_AUTOHSCROLL forced styles : $WS_TABSTOP only if no $ES_READONLY. $ES_MULTILINE is always reset. exStyle kiểu mở rộng. xem Extended Style Table. Return Value Success: trả lại ControlID Failure: Returns 0. Remarks để lấy giá trị của control ta dùng GUICtrlRead. để đặt các thuộc tính cho control ta dùng GUICtrlSet để nhập kiểu password ta thêm thuộc tính $ES_PASSWORD cho nó. nếu bạn muốn kéo và thả file trên edit bạn cần phải tạo gui có thuộc tính WS_EX_ACCEPTFILES extended style ở hàm GUICreate() và set kiểu $GUI_DROPACCEPTED cho nó bằng guictrlsetstate. lựa chọn nhiều file sẽ đc phân biệt bởi dấu "|" để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include <EditConstants.au3> in your script. Default resizing is $GUI_DOCKHEIGHT. Related GUICoordMode (Option), GUICtrlSet , GUIGetMsg, GUICtrlRead Example #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $file, $btn, $msg GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateInput("", 10, 5, 300, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn ExitLoop EndSelect WEnd MsgBox(4096, "drag drop file", GUICtrlRead($file)) EndFunc ;==>Example Function Reference GUICtrlCreateLabel tạo raLabel control cho GUI để hiện thị text. GUICtrlCreateLabel ( "text", left, top [, width [, height [, style [, exStyle]]]] ) Parameters text text hiện trị sẵn trên control left tọa độ X top tọa độ Y width chiều rộng height chiều cao style kiểu. xem thêm GUI Control Styles Appendix. default ( -1) : none. forced styles : $SS_NOTIFY, $SS_LEFT exStyle kiểu mở rộng. xem Extended Style Table. Return Value Success: trả lại ControlID Failure: Returns 0. Remarks để lấy giá trị của control ta dùng GUICtrlRead. để đặt các thuộc tính cho control ta dùng GUICtrlSet để sử dụng nhiều kiểu trong style ta dùng BitOr($GUI_SS_DEFAULT_LABEL, newstyle, ). để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include <StaticConstants.au3> in your script. Default resizing is $GUI_DOCKAUTO size and position will occur. để đặt màu nền của label là trong suốt ta dùng GUICtrlSetBkColor( label handle, $GUI_BKCOLOR_TRANSPARENT). Related GUICoordMode (Option), GUICtrlSet , GUIGetMsg Example #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $widthCell, $msg, $iOldOpt GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetHelp("notepad") ; will run notepad if F1 is typed $iOldOpt = Opt("GUICoordMode", 2) $widthCell = 70 GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, $widthCell) ; first cell 70 width GUICtrlCreateLabel("Line 2 Cell 1", -1, 0) ; next line GUICtrlCreateLabel("Line 3 Cell 2", 0, 0) ; next line and next cell GUICtrlCreateLabel("Line 3 Cell 3", 0, -1) ; next cell same line GUICtrlCreateLabel("Line 4 Cell 1", -3 * $widthCell, 0) ; next line Cell1 GUISetState() ; will display an empty dialog box ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE $iOldOpt = Opt("GUICoordMode", $iOldOpt) EndFunc ;==>Example . <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $widthCell, $msg, $iOldOpt GUICreate("My GUI") ; will create a dialog box that when displayed is centered. GUICtrlRead Example #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $file, $btn, $msg GUICreate(" My GUI input acceptfile",. BitOr($GUI_SS_DEFAULT_LABEL, newstyle, ). để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include <StaticConstants.au3> in your script. Default resizing is $GUI_DOCKAUTO size and

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

Từ khóa liên quan

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

Tài liệu liên quan