Tải bản đầy đủ (.pdf) (6 trang)

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

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (99.15 KB, 6 trang )



Function Reference
GUIStartGroup
Defines that any subsequent controls that are created will be "grouped" together.
GUIStartGroup ( [winhandle] )
Parameters
winhandle
[optional] Windows handle as returned by GUICreate (default is the
previously used window).

Return Value
Success:

Returns 1.
Failure:

Returns 0.

Remarks
This function is generally used when working with radio button controls. When
you click a radio button all other radio buttons in the same grouping are reset. The
GUIStartGroup function allows you to easily define these groups.
Related
GUICtrlCreateGroup
Example

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)


Example()

Func Example()
Local $button_1, $group_1, $radio_1, $radio_2, $radio_3
Local $radio_4, $radio_5, $radio_6, $input_1, $input_2
Local $radioval1, $radioval2, $msg

Opt("GUICoordMode", 1)

GUICreate("Radio Box Grouping 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)
GUIStartGroup()
$radio_4 = GUICtrlCreateRadio("Radio &A", 120, 120, 70, 20)
$radio_5 = GUICtrlCreateRadio("Radio &B", 120, 150, 60, 20)
$radio_6 = GUICtrlCreateRadio("Radio &C", 120, 180, 60, 20)
GUIStartGroup()
$input_1 = GUICtrlCreateInput("Input 1", 200, 20, 160, 30)
$input_2 = GUICtrlCreateInput("Input 2", 200, 70, 160, 30)

; Set the defaults (radio buttons clicked, default button, etc)
GUICtrlSetState($radio_1, $GUI_CHECKED)
GUICtrlSetState($radio_6, $GUI_CHECKED)
GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)


; Init our vars that we will use to keep track of radio events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 2

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. Both
; methods are equally valid
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit

Case $msg = $button_1
MsgBox(0, "Button", "Radio " & $radioval1 & @LF & "Radio " &
Chr($radioval2 + Asc("A")) & @LF & GUICtrlRead($input_1) & @LF &
GUICtrlRead($input_2))

Case $msg = $radio_1 Or $msg = $radio_2 Or $msg = $radio_3
$radioval1 = $msg - $radio_1

Case $msg = $radio_4 Or $msg = $radio_5 Or $msg = $radio_6
$radioval2 = $msg - $radio_4

EndSelect

WEnd
EndFunc ;==>Example



Function Reference
GUISwitch
Switches the current window used for GUI functions.
GUISwitch ( winhandle [, tabitemID] )
Parameters
winhandle The handle of the window to switch to.
tabitemID controlID of the tabitem control to be selected.

Return Value
Success:

Returns the handle of the previously current.
Failure:

Returns a NULL handle.

Remarks
Many of the GUI specific functions work on the "current" window - this is usually
the last window created with GUICreate. This function allows you to make another
window "current". That's does not mean that the referenced window will become
active. You have to use WinActivate.

Using the tabitemID allow to create new control in the specified tabitem control.
Don't forget to close tabitem definition GuiCtrlCreateTabItem("")
Related

GUICreate, GUIDelete
Example

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
Local $parent1, $parent2, $tabitem, $msg

$parent1 = GUICreate("Parent1")
GUICtrlCreateTab(10, 10)
$tabitem = GUICtrlCreateTabItem("tab1")
GUICtrlCreateTabItem("tab2")
GUICtrlCreateTabItem("")

$parent2 = GUICreate("Parent2", -1, -1, 100, 100)

GUISwitch($parent2)
GUISetState()
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

GUISwitch($parent1, $tabitem)
GUICtrlCreateButton("OK", 50, 50, 50)
GUICtrlCreateTabItem("")


GUISetState(@SW_SHOW, $parent1)
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example



Function Reference
HotKeySet
Đặt hoặc bỏ một phím nóng, khi ấn phím đó 1 chương trình con sẽ đc gọi.
HotKeySet ( "key" [, "function"] )
Parameters
key phím nóng.
xem

quy

ư
ớc

phím trong hàm

Send()
.

function tên hàm ko có dấu () sẽ đc gọi khi ấn key



×