找回密码
 加入
搜索
查看: 2467|回复: 4

[AU3基础] [已解决]应用Checkbox上的一点麻烦

[复制链接]
发表于 2010-4-12 18:56:25 | 显示全部楼层 |阅读模式
本帖最后由 lancaogen1999 于 2010-4-14 20:17 编辑

下面一段代码运行后料表3和料表4都会不停的闪烁,
如果加了sleep语句之后程序会反应迟钝,是不是我的用法不对,
请问各位大大这个问题怎么解决,谢谢啦!
#include <Excel.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("料表转换v2.0 by slowly.liu & yf.bai", 625, 443, 192, 124)
GUICtrlCreateLabel("请选择料表:", 64, 40, 150, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表1", 64, 88, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表2", 64, 144, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox2 = GUICtrlCreateCheckbox("料表4", 45, 256, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox1= GUICtrlCreateCheckbox("料表3", 45, 200, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Inputlb1 = GUICtrlCreateInput("", 170, 88, 321, 25)
$Inputlb2 = GUICtrlCreateInput("", 170, 144, 321, 25)
$Inputlb3 = GUICtrlCreateInput("", 170, 200, 321, 25)
$Inputlb4 = GUICtrlCreateInput("", 170, 256, 321, 25)
$Button1 = GUICtrlCreateButton("浏览", 536, 88, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("浏览", 536, 144, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("浏览", 536, 200, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("浏览", 536, 256, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$OK = GUICtrlCreateButton("转换", 128, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
$Exit = GUICtrlCreateButton("退出", 376, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
If GUICtrlRead($Checkbox1)=$GUI_UNCHECKED Then
        GUICtrlSetState($Inputlb3,$GUI_DISABLE)
        GUICtrlSetState($Button3,$GUI_DISABLE)
        GUICtrlSetState($Inputlb4,$GUI_DISABLE)
        GUICtrlSetState($Button4,$GUI_DISABLE)       
Else
        GUICtrlSetState($Inputlb3,$GUI_ENABLE)
        GUICtrlSetState($Button3,$GUI_ENABLE)
EndIf
If GUICtrlRead($Checkbox2)=$GUI_UNCHECKED Then
        GUICtrlSetState($Inputlb4,$GUI_DISABLE)
        GUICtrlSetState($Button4,$GUI_DISABLE)       
Else
        GUICtrlSetState($Inputlb3,$GUI_ENABLE)
        GUICtrlSetState($Button3,$GUI_ENABLE)       
        GUICtrlSetState($Inputlb4,$GUI_ENABLE)
        GUICtrlSetState($Button4,$GUI_ENABLE)
EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Exit
                        Exit
                Case $Button1
                        $var1 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
                        GUICtrlSetData($Inputlb1,$var1)
                        $lb1=_ExcelBookOpen($var1)
                        $gs= _ExcelBookOpen(@ScriptDir & "\Α.bak")
                Case $Button2
                        $var2 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
                Case $Button3
                        $var3 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
                Case $Button4
                        $var4 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

 楼主| 发表于 2010-4-13 20:44:23 | 显示全部楼层
为什么没人回复呢?是我的问题太简单了吗?
发表于 2010-4-13 20:56:39 | 显示全部楼层
#include <Excel.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("料表转换v2.0 by slowly.liu & yf.bai", 625, 443, 192, 124)
GUICtrlCreateLabel("请选择料表:", 64, 40, 150, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表1", 64, 88, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("料表2", 64, 144, 75, 23)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox2 = GUICtrlCreateCheckbox("料表4", 45, 256, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Checkbox1 = GUICtrlCreateCheckbox("料表3", 45, 200, 75, 25)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Inputlb1 = GUICtrlCreateInput("", 170, 88, 321, 25)
$Inputlb2 = GUICtrlCreateInput("", 170, 144, 321, 25)
$Inputlb3 = GUICtrlCreateInput("", 170, 200, 321, 25)
$Inputlb4 = GUICtrlCreateInput("", 170, 256, 321, 25)
$Button1 = GUICtrlCreateButton("浏览", 536, 88, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("浏览", 536, 144, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("浏览", 536, 200, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("浏览", 536, 256, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$OK = GUICtrlCreateButton("转换", 128, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
$Exit = GUICtrlCreateButton("退出", 376, 336, 121, 41)
GUICtrlSetFont(-1, 20, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetState($Inputlb3, $GUI_DISABLE)
GUICtrlSetState($Button3, $GUI_DISABLE)
GUICtrlSetState($Inputlb4, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_DISABLE)

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

                Case $Checkbox1
                        If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
                                GUICtrlSetState($Inputlb3, $GUI_DISABLE)
                                GUICtrlSetState($Button3, $GUI_DISABLE)
                        Else
                                GUICtrlSetState($Inputlb3, $GUI_ENABLE)
                                GUICtrlSetState($Button3, $GUI_ENABLE)
                        EndIf
                Case $Checkbox2
                        If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then
                                GUICtrlSetState($Inputlb4, $GUI_DISABLE)
                                GUICtrlSetState($Button4, $GUI_DISABLE)
                        Else
                                GUICtrlSetState($Inputlb4, $GUI_ENABLE)
                                GUICtrlSetState($Button4, $GUI_ENABLE)
                        EndIf
                Case $Button1
                        $var1 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
                        GUICtrlSetData($Inputlb1, $var1)
                        $lb1 = _ExcelBookOpen($var1)
                        $gs = _ExcelBookOpen(@ScriptDir & "\Α.bak")
                Case $Button2
                        $var2 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
                Case $Button3
                        $var3 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
                Case $Button4
                        $var4 = FileOpenDialog("打开", @DesktopDir & "", "Excel文件(*.xls)", 2)
                        If @error Then
                                ExitLoop
                        EndIf
        EndSwitch
WEnd
发表于 2010-4-14 11:31:26 | 显示全部楼层
好长哦,看着头有点大了。
 楼主| 发表于 2010-4-14 18:52:40 | 显示全部楼层
谢谢afan,我有点朦胧的明白了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 23:20 , Processed in 0.081857 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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