找回密码
 加入
搜索
查看: 2616|回复: 5

[系统综合] 怎么写按钮事件

  [复制链接]
发表于 2012-4-8 18:46:20 | 显示全部楼层 |阅读模式
点击按钮触发一下代码事件
$var = IniRead("execution.ini", "QQ", "QQ", "")
Run($var)
不知道该怎么写进去

这是窗体代码
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$var1=IniRead("execution.ini","Form","width","")
$var2=IniRead("execution.ini","Form","height","")
$Form1 = GUICreate("Menu", $var1, $var2, -1,-1)
$Form1context = GUICtrlCreateContextMenu()
$MenuItem2 = GUICtrlCreateMenuItem("Add", $Form1context)
$MenuItem1 = GUICtrlCreateMenuItem("Exit", $Form1context)
$Button1 = GUICtrlCreateButton("Button1", 24, 32, 57, 57, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 88, 32, 57, 57, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 152, 32, 57, 57, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Button4", 24, 96, 57, 57, $WS_GROUP)
$Button5 = GUICtrlCreateButton("Button5", 152, 96, 57, 57, $WS_GROUP)
$Button6 = GUICtrlCreateButton("Button6", 88, 96, 57, 57, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2012-4-8 18:53:07 | 显示全部楼层
你是用 Koda 编辑器?
那在设置各控件时, 鼠标双击按钮等控件, 就会有个添加 '事件通知' 的信息框, 直接确定就行了.
然后要按 F10 切换到 Scite 编辑器中编写相应按钮 '事件 '的代码!
注意编写好后要'另存为..', 该文件是在临时文件夹里, 且容易被 Koda 覆盖掉!
发表于 2012-4-8 19:31:06 | 显示全部楼层
Switch 照着Case $GUI_EVENT_CLOSE添
Case $Button1
        $var = IniRead("execution.ini", "QQ", "QQ", "")
        Run($var)
就行了
发表于 2012-4-8 20:42:58 | 显示全部楼层
看帮助文件就能够知道怎么做了,有现成的例子啊!
发表于 2012-4-9 00:44:51 | 显示全部楼层
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
Case $Button1
        $var = IniRead("execution.ini", "QQ", "QQ", "")
        Run($var)
Case $Button2
         Run($var)
Case $Button3
         Run($var)
Case $Button4
         Run($var)
        EndSwitch
WEnd


完整了吧
发表于 2012-4-9 08:54:07 | 显示全部楼层
5楼已完美回答,也可以写成函数调用事件模式!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-20 15:37 , Processed in 0.080601 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表