Gui,Add,Custom
実行制御 | GUI表示 | 演算・変数 | メモリ・DLL操作 | 文字列操作 |
キーボード | マウス | シェル | ウィンドウ | ウィンドウグループ
ステータスバー | コントロール | サウンド | ファイル | INIファイル |
レジストリ | 環境変数 | AutoHotkey | その他 | 設定関係 | オブジェクト
Gui,Add,Custom [v1.1.10+][編集]
AutoHotkeyで直接サポートされていないその他のコントロールをGUIウィンドウに埋め込む。
Gui, Add, Custom [, ClassName Options]
Parameters[編集]
| 引数名 | 説明 |
|---|---|
| ClassName | Name にWin32APIのクラス名を指定。 |
| Options | オプションを半角スペース区切りで列挙。 Gui,Addの項参照。 |
Remarks[編集]
AutoHotkeyで直接サポートされていないその他のコントロールもGUIウィンドウに埋め込むことができる。
そのため、Win32のクラス名はGui, AddのClassオプションで指定する必要がある。
Gui, Add, Custom, ClassComboBoxEx32; ComboBoxExコントロールを追加する。Gui, Add, Custom, ClassScintilla; Scintillaコントロールを追加する。;コントロールを追加する前にSciLexer.dllライブラリをロードする必要があることに注意。
AutoHotkey uses the standard Windows control text routines when text is to be retrieved/replaced in the control via Gui, Add or GuiControl/Get.
G-Label Notifications: A g-label such as gMySubroutine may be listed in the control's options in order to capture events coming from the control. This subroutine may consult the built-in variables A_Gui and A_GuiControl. More importantly, it may consult A_GuiEvent, which contains one of the following strings (for compatibility with future versions, a script should not assume these are the only possible values):
- Normal: A
WM_COMMANDmessage was received.A_EventInfocontains a control-defined notification code (equivalent toHIWORD(wParam)in C/C++). - N: A
WM_NOTIFYmessage was received.A_EventInfocontains a pointer to the control notification structure (NMHDR). A 32-bit signed integer value may be returned to the control by assigning it toErrorLevel(by default, the g-label thread'sErrorLevelis set to zero). Invalid values are treated as zero.
Related[編集]
Example(s)[編集]
IPアドレスコントロール を追加して使用する方法
Gui, Add, Custom, ClassSysIPAddress32 r1 w150 hwndhIPControl gIPControlEvent Gui, Add, Button, Default, OK IPCtrlSetAddress(hIPControl, A_IPAddress1) Gui, Show Return GuiClose: ExitApp ButtonOK: Gui, Hide ToolTip MsgBox % "You chose " IPCtrlGetAddress(hIPControl) ExitApp IPControlEvent: If A_GuiEvent = Normal {; WM_COMMAND was received.If (A_EventInfo = 0x0300); EN_CHANGEToolTip Control changed! } Else If A_GuiEvent = N {; WM_NOTIFY was received.; Get the notification code. Normally this field is UInt but the IP address; control uses negative codes, so for convenience we read it as a signed int.nmhdr_code := NumGet(A_EventInfo + 2*A_PtrSize, "int") If (nmhdr_code != -860); IPN_FIELDCHANGEDReturn; Extract info from the NMIPADDRESS structureiField := NumGet(A_EventInfo + 2*A_PtrSize + 4, "int") iValue := NumGet(A_EventInfo + 2*A_PtrSize + 8, "int") If iValue >= 0 ToolTip Field #%iField% modified: %iValue% Else ToolTip Field #%iField% left empty } Return IPCtrlSetAddress(hControl, ipaddress) { static WM_USER := 0x400 static IPM_SETADDRESS := WM_USER + 101; Pack the IP address into a 32-bit word for use with SendMessage.ipaddrword := 0 Loop, Parse, ipaddress, . ipaddrword := (ipaddrword * 256) + A_LoopField SendMessage IPM_SETADDRESS, 0, ipaddrword,, ahk_id %hControl% } IPCtrlGetAddress(hControl) { static WM_USER := 0x400 static IPM_GETADDRESS := WM_USER + 102 VarSetCapacity(addrword, 4) SendMessage IPM_GETADDRESS, 0, &addrword,, ahk_id %hControl% Return NumGet(addrword, 3, "UChar") "." NumGet(addrword, 2, "UChar") "." NumGet(addrword, 1, "UChar") "." NumGet(addrword, 0, "UChar") }