AutoIt簡單的語言,容易上手,完整的教學手冊,預設好用的編輯器

先引入檔案,這檔案定義著後面的常數

CODE:

#include <GUIConstantsEx.au3>

接下來建立視窗,可以用GUICreate,參數如下
CODE:
GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
範例:
CODE:
GUICreate ("Test!!",200,100)

這個程式碼可以建造一個單調的視窗,我們來加一些和使用者互動的東西,如文字欄,參數如下:
建立一個TextBox X:10 Y:20 寬度:50
CODE:
GUICtrlCreateInput("",10,20,50)

還有很多元件GUI函式庫有提供
Label 文字標籤
Button 按鈕
Input 文字欄位
Edit 文字區塊
Checkbox 勾選區(不知道怎麼用中文講..)
Radio A set of circular buttons - only one can be active at once.
Combo 核取式清單.
List 選取式清單
Date 日期選擇.
Pic 圖片.
Icon 圖示.
Progress 進度.
Tab A group of controls that are contained in tabs.
UpDown A control that can be added to input controls.
Avi 影片
Menu 功能表
ContextMenu A menu that appears when you right click inside the window.
TreeView 樹狀清單(TreeView)
Slider A control similar to the windows sound volume control.
ListView A control displaying columns information.
ListViewItem A control displaying item in a listview control.
Graphic A control displaying graphics drawn with GUICtrlSetGraphic.
Dummy A dummy user control.


這沒有任何程式碼和使用者互動www.phate.tw7F"@9c4s(@
為了等一下要好控制元件www.phate.tw5E+p A(^7C/@ @,L/S1v
用個變數接住他像Handle一樣

CODE:
$input1 = GUICtrlCreateInput("", 10, 20, 50)
$button = GUICtrlCreateButton("Button", 30, 50, 60)

再來要講得是訊息迴圈,用一個迴圈來處理訊息(玩過C++的應該都知道),]5M/~.\.m;h0J,b8b%V;A
可以用GUIGetMsg()來取得GUI訊息(@5x7k"?$@!D(|
取得GUI元件的值可以用GUICtrlRead(並非所有元件)

CODE:
While 1
  $msg=GUIGetMsg()
  Select
    Case $msg = $button  ;使用者按下Button!!
      Msgbox(64,"TextBox的值為" & GUICtrlRead($input1),"Test")
    case $msg = $GUI_EVENT_CLOSE  ;當使用者按X,會傳回 $GUI_EVENT_CLOSE  
      Msgbox(0,"Bye","ByeBye")
      ExitLoop  ;跳離迴圈即離開
  EndSelect
WEnd

2Y-h,y&Q E!r!n#K2@8r

arrow
arrow
    全站熱搜

    ITMan 發表在 痞客邦 留言(0) 人氣()