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

好像很简单,但俺不懂

  [复制链接]
发表于 2008-9-19 18:39:04 | 显示全部楼层 |阅读模式
Auto It 能不能实现以下要求,请大家指点。
有运行与停止两个按钮,点击运行,程序就开始运行。点击停止,程序就停止。
发表于 2008-9-19 19:30:09 | 显示全部楼层
停止的意思是关闭吗?这样很容易的..
 楼主| 发表于 2008-9-19 19:45:29 | 显示全部楼层
我用了以下代码,但不行

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 473, 141, 1643, 207)
$Progress1 = GUICtrlCreateProgress(15, 72, 433, 41)
$Button1 = GUICtrlCreateButton("Run", 48, 16, 121, 41, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
$Button2 = GUICtrlCreateButton("Stop", 280, 16, 121, 41, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$mdb_data_path="D:\home\Training\ASPX\CCC\SCVData\DataAdmin.mdb"

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                       
                        While 1
                               
                                       
                               
                                ;MsgBox(0,"test","hello")
                               
                                du()

                                $nMsg = GUIGetMsg()
                                Switch $nMsg
                                        Case $GUI_EVENT_CLOSE
                                                Exit
                                        case $Button2
                                                ExitLoop
                                EndSwitch
                                Sleep(30000)
                        WEnd

                Case $Button2
                        ;Exit
        EndSwitch
WEnd

Func du()

                $addfld = ObjCreate("ADODB.Connection")
                $addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_data_path)
                $RS =ObjCreate("ADODB.Recordset")
                $RS.ActiveConnection = $addfld
                $RS.Open ("Select * From test where runFlag='Y'")
                while Not $RS.eof And Not $RS.bof
           if @error =1 Then ExitLoop
            ;GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (3).value&"|"& $RS.Fields (4).value,$ListView1 )
                        $sQuery ="update test set  runFlag='N' WHERE uid="& $RS.Fields(0).value
                        $addfld.execute($sQuery)
                        ;$RS("runFlag")="N"
                        ;$rs.update       
                        MsgBox(0, "", $RS.Fields (2).value);显示表第一个数据
                        $rs.movenext
                WEnd
                $rs.close
                $addfld.Close
EndFunc
发表于 2008-9-20 11:47:03 | 显示全部楼层
这么写似乎不行吧,你把里面的那个switsh,另外,你那个界面的坐标似乎不对吧
发表于 2008-9-27 11:34:26 | 显示全部楼层
$Form1 = GUICreate("Form1", 473, 141, 1643, 207)
按这一句看,你的屏幕真的是很宽啊!!!


 While 1
                                
                                        
                                
                                ;MsgBox(0,"test","hello")
                                
                                du()

                                $nMsg = GUIGetMsg()
                                Switch $nMsg
                                        Case $GUI_EVENT_CLOSE
                                                Exit
                                        case $Button2
                                                ExitLoop
                                EndSwitch
                                ;Sleep(30000)  这个Sleep 加的相当无聊啊!帮助没看清!
                        WEnd

修改后可以正常运行的:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 473, 141)
$Progress1 = GUICtrlCreateProgress(15, 72, 433, 41)
$Button1 = GUICtrlCreateButton("Run", 48, 16, 121, 41, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
$Button2 = GUICtrlCreateButton("Stop", 280, 16, 121, 41, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
GUISetState()
#EndRegion ### END Koda GUI section ###
;$mdb_data_path="D:\home\Training\ASPX\CCC\SCVData\DataAdmin.mdb"

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        While 1
                            ;MsgBox(0,"test","hello")
                                du()
                                $nMsg = GUIGetMsg()
                                Switch $nMsg
                                        Case $GUI_EVENT_CLOSE
                                                                                        Exit
                                                                                case $Button2
                                                                                        ToolTip("")
                                                                                        ExitLoop
                                EndSwitch
                                ;Sleep(30000)  注意不要有这个!
                        WEnd

                Case $Button2
                        Exit
        EndSwitch
WEnd

Func du()
ToolTip("测试运行..." & @SEC)
                ;$addfld = ObjCreate("ADODB.Connection")
                ;$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_data_path)
                ;$RS =ObjCreate("ADODB.Recordset")
                ;$RS.ActiveConnection = $addfld
                ;$RS.Open ("Select * From test where runFlag='Y'")
                ;while Not $RS.eof And Not $RS.bof
           ;if @error =1 Then ExitLoop
            ;GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (3).value&"|"& $RS.Fields (4).value,$ListView1 )
            ;            $sQuery ="update test set  runFlag='N' WHERE uid="& $RS.Fields(0).value 
             ;           $addfld.execute($sQuery)
              ;          ;$RS("runFlag")="N"
                        ;$rs.update        
                ;        MsgBox(0, "", $RS.Fields (2).value);显示表第一个数据
               ;         $rs.movenext
                ;WEnd
             ;   $rs.close
              ;  $addfld.Close
EndFunc


[ 本帖最后由 liongodmien 于 2008-9-27 11:36 编辑 ]

评分

参与人数 1金钱 +1 收起 理由
xyl006 + 1

查看全部评分

发表于 2008-9-27 14:09:54 | 显示全部楼层
顶了..学习学习!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-29 07:14 , Processed in 0.148059 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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