Autoitは、UWSCと違い無料でGUIも簡単に作ることできます。 Kodaというソフトを使えば、非常に簡単です。
一番簡単に「Window」(GUI)を表示
GUICreate(“GUI テスト”) ;// タイトルのみの「Window」作成
GUISetState() ;// Window 表示 Sleep(5000)
Window 作成しても表示されません。 GUISetState() で表示します。(defaultが表示していです) Sleep(5000) で5秒間だけ、表示します。
Windowの大きさを、指定する
GUICreate("GUI テスト",500, 120) ;// タイトル、横幅、高さを指定
GUISetState() ;// Window 表示
Sleep(5000)
Closeボタンで閉じるまで、Window表示
#include <GUIConstantsEx.au3> ;//GUi関係の定数を使うとき必要
Local $hGUI = GUICreate("Window Test", 300, 100)
GUISetState()
Local $iMsg = 0
While 1
$iMsg = GUIGetMsg()
If $iMsg = $GUI_EVENT_CLOSE Then
ExitLoop
EndIf
WEnd
GUIDelete($hGUI) ;いろいろなものを開放するために必要
矢印Xを押すまで、表示続けます。
簡単にWindowを作るためのソフト
何もしないButton 付きWindow
#include <GUIConstantsEx.au3>
;//GUIの定数、使うため
Local $Button_1, $msg
Local $hGUI = GUICreate("Button作成GUI",250, 100) ; 表示時に中央に表示されるダイアログボックスを作成
$Button_1 = GUICtrlCreateButton("Button", 70, 20, 100, 50)
;タイトル, x, y, 横幅、高さ
GUISetState() ; ボタンを持つGUI表示
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
ExitLoop
EndIf
WEnd
GUIDelete($hGUI) ;いろいろなものを開放するために必要
ボタン押しても、何も変化しません。
Button押すとMsgboxを表示する
#include <GUIConstantsEx.au3>
;//GUIの定数、使うため
Local $Button_1, $msg
Local $hGUI = GUICreate("Button作成GUI",250, 100) ; 表示時に中央に表示されるダイアログボックスを作成
$Button_1 = GUICtrlCreateButton("Button", 70, 20, 100, 50)
;コントロールID ;タイトル, x, y, 横幅、高さ
GUISetState() ; ボタンを持つGUI表示
While 1
$msg = GUIGetMsg() ;//ボタンクリックするとIDが入る
If $msg = $GUI_EVENT_CLOSE Then
ExitLoop
EndIf
If $msg = $Button_1 Then
MsgBox("","","ボタン押したよ!")
EndIf
WEnd
GUIDelete($hGUI) ;いろいろなものを開放するために必要
ボタンクリックすると「$msg=GUIGetMsg()」にボタンIDが入るようです。
カウンター、クリックするごとに+1
#include <GUIConstantsEx.au3>
;//GUIの定数、使うため
Local $Button_1, $msg
Local $hGUI = GUICreate("Button作成GUI",250, 100)
; 表示時に中央に表示されるダイアログボックスを作成
$Button_1 = GUICtrlCreateButton("0", 70, 20, 100, 50)
;コントロールID ;タイトル, x, y, 横幅、高さ
GUICtrlSetFont ($Button_1, 18) ;フォントサイズ
GUISetState() ; ボタンを持つGUI表示
Local $num = 0
While 1
$msg = GUIGetMsg() ;//ボタンクリックするとIDが入る
If $msg = $GUI_EVENT_CLOSE Then
ExitLoop
EndIf
If $msg = $Button_1 Then
;//MsgBox("","","SAM")
ControlSetText ( "Button作成GUI", $num, $Button_1, $num + 1, 1)
;// ボタンのtitle を変更する
$num = $num + 1
EndIf
WEnd
GUIDelete($hGUI) ;いろいろなものを開放するために必要
ボタンをクリックすると、ウィンドウメッセージにButtonのIDが入る
Buttonを押すと「inputBox」が出てくる
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("JWW 外変", 250, 100)
$btn = GUICtrlCreateButton("input",50,30,150,30)
GUISetState(@SW_SHOW)
Local $msg = "なにか入れて!"
while 1
$nMsg = GUIGetMsg()
Select
case $nMsg = $GUI_EVENT_CLOSE
Exit
case $nMsg = $btn
$sInput = InputBox("", $msg)
_input_draw($sInput)
EndSelect
WEnd
GUIDelete()
;
inputBoxこの大きさがDefaultのようです。
InputBox ( "title", "prompt" [, "default" [, "password char" [, width [, height [, left [, top [, timeout [, hwnd]]]]]]]] )
GUIスライダーの使いかた(値表示)
スライダーのコード GUICtrlCreateSlider()
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 232, 140, 192, 124)
GUISetFont(9, 400, 0, "MS Pゴシック")
$Checkbox1 = GUICtrlCreateCheckbox("", 32, 24, 17, 25)
$Button1 = GUICtrlCreateButton("R", 72, 16, 121, 49)
GUICtrlSetFont(-1, 12, 400, 0, "Meiryo UI")
$Slider1 = GUICtrlCreateSlider(24, 80, 129, 33)
;GUICtrlCreateSlider(x,y,w,h)
$input1 = GUICtrlCreateInput("", 160, 80, 41, 28)
GUICtrlSetFont(-1, 12, 400, 0, "Meiryo UI")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetLimit($Slider1,20,5)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Slider1
Local $num = GUICtrlRead($Slider1)
GUICtrlSetData($input1, $num)
EndSwitch
WEnd
GUI作成ソフト(Koda)を使用すれば簡単です
ダウン先: KODA FormDesigner
スライダー作成
赤矢印の「Win32」タブ選択、赤矢印(下)のスライダーを選択し、フォームにドラッグすればOKです。
GUICtrlCreateSlider ( left, top [, width [, height [, style [, exStyle]]]] )
GUIにMenuを作る
GUI Menuの設置
(1)Menuアイコンをクリック
赤枠のアイコンをクリックして下さい。
(2)Formのどこでも良いので、クリックして下さい
ウリックすると、フォーム上にアイコンができます。
コメント