HƯỚNG DẪN LẬP TRÌNH AUTOIT BÀI 4: GIAO DIỆN - GUI - FORM - LẬP TRÌNH AUTOIT

Latest

Tuesday, November 21, 2017

HƯỚNG DẪN LẬP TRÌNH AUTOIT BÀI 4: GIAO DIỆN - GUI - FORM

1. Cấu trúc tạo GUI (giao diện người dùng)

#include <GUIConstantsEx.au3> ; cái này không thể thiếu nếu muốn tạo GUI
; Tạo 1 cửa sổ (form cũng thế, gọi form cho tiện !)
      GUICreate ( "title", width , height, left, top, style , exStyle, parent)

      ;Tạo Label
      GUICtrlCreateLabel("text",left,top, style , exStyle, parent)

      ; Tạo button 
      GUICtrlCreateButton("OK",width , height, left, top,style,exStyle, parent) 

      GUISetStage(@SW_SHOW) ; hiện form (mặc định là không hiện)
      ;cấu trúc tắt forrm
      while 1
         if GuiGetMsg() = $GUI_EVENT_CLOSE then
         exit
         endif
      wend

Cách đơn giản hơn để tạo một form đó là sử dụng phần mềm 'koda': Tải về tại đây.
sau khi tải về, mở KD.exe thiết kế GUI tùy theo mục đích, sau đó nhấn F9 để hiện code và copy vào Autoit.


Bảng kiểu mở rộng:
Đầu tiên add thư viện WindowsConstants (các hằng có sẵn trong Windows).
Cấu trúc
#include <WindowsConstants.au3>
kiểu
mô tả
$WS_EX_ACCEPTFILES
Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState. for other controls the drag&drop info can be retrieved with @GUI_DRAGID, @GUI_DRAGFILE, @GUIDROPID.
$WS_EX_APPWINDOW
Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_CLIENTEDGE
Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP
Includes a question mark in the title bar of the window. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX.
$WS_EX_DLGMODALFRAME
Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the style parameter.
$WS_EX_MDICHILD
Create a child window included in its parent window (simulation not real MDI).
$WS_EX_OVERLAPPEDWINDOW
Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE
Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST
Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT
The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW
tạo ra một cửa sổ công cụ, thanh tiêu đề nhỏ hơn, ko hiện ico trên thanh tiêu đề, ko hiện tên trên taskbar, ko di chuyển tới cửa sổ này đc = Alt+Tab, nhưng menu hệ thống vẫn hiện ra khi ấn Alt+Space
$WS_EX_WINDOWEDGE
Chỉ rõ rằng một cửa sổ có một biên giới với một cạnh được nêu ra.
$WS_EX_LAYERED
tạo ra GUI ẩn, chú ý kiểu này ko dùng cho GUI con

Thế là xong phần lý thuyết

2 comments: