AutoIt3版本:
Version 3.5.4
AutoIt3 GUI官方介绍:
A GUI consists of one or more windows and each window contains one or more controls. GUIs are "event driven" which means you react to events - like a button that is clicked. You spend most of your time idling and waiting for an event to happen - this is a little different to a normal script where you are in control of what happens and when! Think of it as waiting by the door for the postman - you sit there until a letter pops through the postbox and then you look at the letters and decide what to do with them - this is exactly how GUIs work - you wait for the postman to come to you.
AutoIt3脚本代码:#include
#include
;UGI使用事件模式
Opt("GUIOnEventMode", 1)
;创建一个窗口
Local $window=GUICreate("大小写转-小奋斗", 400, 300)
;绑定事件
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseWindow")
;创建文本域
Local $inputEdit=GUICtrlCreateEdit("", 30,10,340,100)
;创建按钮
Local $transforUpperButton=GUICtrlCreateButton("大写", 100,135,60,25)
Local $transforLowerButton=GUICtrlCreateButton("小写", 170,135,60,25)
Local $clearButton=GUICtrlCreateButton("清除", 240,135,60,25)
;创建文本域
Local $outputEdit=GUICtrlCreateEdit("", 30, 180,340,100)
;事件绑定
GUICtrlSetOnEvent($transforUpperButton, "TransforUpperButton")
GUICtrlSetOnEvent($transforLowerButton, "TransforLowerButton")
GUICtrlSetOnEvent($clearButton, "ClearButton")
;显示当前窗口
GUISetState(@SW_SHOW)
; 消息循环模式
While 1
Sleep(100);
WEnd
;关闭窗口
func CloseWindow()
MsgBox($MB_OK, "提示", "您选择了关闭窗口! 正在退出...")
Exit
EndFunc
;转换成大写
Func TransforUpperButton()
; 获取控件内容
$sourceTxt = GUICtrlRead($inputEdit)
; 从控件上修改数据
GUICtrlSetData($outputEdit,StringUpper($sourceTxt))
EndFunc
;转换成小写
Func TransforLowerButton()
; 获取控件内容
$sourceTxt = GUICtrlRead($inputEdit)
; 从控件上修改数据
GUICtrlSetData($outputEdit,StringLower($sourceTxt))
EndFunc
;转换成小写
Func ClearButton()
; 从控件上修改数据
GUICtrlSetData($inputEdit,"")
GUICtrlSetData($outputEdit,"")
EndFunc
AutoIt3运行效果: