找回密码
 加入
搜索
查看: 9550|回复: 19

[系统综合] 循环的几种办法,求解

 火.. [复制链接]
发表于 2013-5-7 19:08:27 | 显示全部楼层 |阅读模式
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
while 1
WinWait ( "循环","" )
ping 1.1.1.1
wend

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

        EndSwitch
WEnd

如果用这样的循环,那么就永远跳不出来了,
Case $GUI_EVENT_CLOSE
        Exit
也没了作用,请问还有其他的办法么?既能循环也能关闭
发表于 2013-5-7 19:29:04 | 显示全部楼层
利用@error值判断,然后跳出循环Exitloop
 楼主| 发表于 2013-5-7 19:46:28 | 显示全部楼层
回复 2# haijie1223


   如何,请范例一下。循环我还是要的啊。
发表于 2013-5-7 20:43:18 | 显示全部楼层
发表于 2013-5-7 21:35:16 | 显示全部楼层
回复 3# basc


    暂时有2中方法:
1、伸手:说说你的要求。
2、看帮助:自己动手解决。
现在正好有时间,用第一种方法的话,也能满足你~

评分

参与人数 1金钱 +30 收起 理由
魔导 + 30 发哥 幽默哦

查看全部评分

 楼主| 发表于 2013-5-8 13:28:42 | 显示全部楼层
回复 5# haijie1223


    #NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Windows\system32\SHELL32.dll|-2
#AutoIt3Wrapper_Outfile=会员111.exe
#AutoIt3Wrapper_Res_Comment=会员信息 DIY BASC
#AutoIt3Wrapper_Res_Description=会员信息 DIY BASC
#AutoIt3Wrapper_Res_Fileversion=1.0.0.8
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#region ### START Koda GUI section ### Form=

Local $kahao, $zhuzhi, $xingming, $mima, $sfz,$chuangkou,$mulu,$ziti
$mulu=IniRead("basc.ini", "会员信息", "mulu", "e:\wx2004")
$ziti=IniRead("basc.ini", "会员信息", "ziti", "楷体")
$chuangkou=IniRead("basc.ini", "会员信息", "chuangkou", "金雅网吧会员卡信息")
$Form1 = GUICreate($chuangkou, 305, 271, @DesktopWidth-@DesktopWidth, @DesktopHeight-318, $WS_SYSMENU)
GUISetBkColor(0xABCDEF)
WinSetOnTop($Form1, "", 1);窗口前置
$Label1 = GUICtrlCreateLabel("姓名", 28, 12, 42, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label2 = GUICtrlCreateLabel("会员密码", 5, 160, 80, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label3 = GUICtrlCreateLabel("身份证号码", 6, 207, 99, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label4 = GUICtrlCreateLabel("会员卡号", 4, 111, 80, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label5 = GUICtrlCreateLabel("住址", 29, 59, 42, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
While 1
       
;读取RZXCard.mdb,表为userinfo的最后一行
Local $mdb_data_path = $mulu & "\RZXCard.mdb", $mdb_data_pwd = "rzx1218"
Local $tblname = "userinfo"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select last(id_usernum) as kahao From " & $tblname & " ")
$kahao = $RS.fields("kahao").value
$RS.close
$RS.Open("Select last(id_key) as mima From " & $tblname & " ")
$mima = $RS.fields("mima").value
$RS.close
$RS.Open("Select last(id_idcard) as sfz From " & $tblname & " ")
$sfz = $RS.fields("sfz").value
$RS.close
$RS.Open("Select last(id_workcompany) as zhuzhi From " & $tblname & " ")
$zhuzhi = $RS.fields("zhuzhi").value
$RS.close
$RS.Open("Select last(id_Name) as xingming From " & $tblname & " ")
$xingming = $RS.fields("xingming").value
$RS.close
$addfld.Close
;读取RZXCard.mdb,表为userinfo的最后一行


$kahao = _HexToString($kahao);十六进制转换
$zhuzhi = _HexToString($zhuzhi)
$xingming = _HexToString($xingming)
$mima = _HexToString($mima)
$sfz = _HexToString($sfz)
$Input1 = GUICtrlCreateInput($xingming, 109, 16, 209, 21)
GUICtrlSetFont(109, 16, 209, 21, $ziti)
$Input2 = GUICtrlCreateInput($zhuzhi, 108, 67, 209, 21)
GUICtrlSetFont(108, 67, 209, 21, $ziti)
$Input3 = GUICtrlCreateInput($kahao, 106, 111, 209, 21)
GUICtrlSetFont(106, 111, 209, 21, $ziti)
$Input4 = GUICtrlCreateInput($mima, 106, 163, 209, 21)
GUICtrlSetFont(106, 163, 209, 21, $ziti)
$Input5 = GUICtrlCreateInput($sfz, 108, 210, 209, 21)
GUICtrlSetFont(108, 210, 209, 21, $ziti)
GUISetState(@SW_SHOW)
WinActivate ( "激活提示","")
WinWait("激活提示","")
WEnd
#endregion ### END Koda GUI section ###

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

        EndSwitch
WEnd

代码。问题来了,运行程序,成功读取ACCESS的内容并在GUI显示,之后的循环读取,GUI内容不会更新。当发现“激活提示”窗口视乎,ACCESS的内容就会被更新。我要的就是,只要发现ACCESS内容被更新了,GUI就显示其内容
发表于 2013-5-8 15:11:57 | 显示全部楼层
本帖最后由 liangzz 于 2013-5-8 15:16 编辑

应该改用响应GUI事件模式Opt("GUIOnEventMode", 1),即使用类似VBA、vb里基于事件的模式

Opt("GUIOnEventMode", 1) ;响应GUI事件模式
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseMain");窗体特殊事件响应
GUISetState(@SW_SHOW)

while 1
        WinWait ( "循环","" )
        sleep(1000)
WEnd
exit

Func CloseMain()
        exit
EndFunc
 楼主| 发表于 2013-5-8 19:07:03 | 显示全部楼层
回复 7# liangzz


    如何套用在我这个问题上。半了说明,没看懂。
发表于 2013-5-8 20:02:32 | 显示全部楼层
把MDB文件拿上来~
 楼主| 发表于 2013-5-8 20:24:48 | 显示全部楼层
[/url]回复 9# haijie1223


ini
[会员信息]
chuangkou=金雅网吧会员卡信息
;窗口标题
ziti=微软雅黑
;程序字体
mulu=e:\wx2004
;万象安装目录

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-5-8 21:03:19 | 显示全部楼层
#NoTrayIcon
#region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Windows\system32\SHELL32.dll|-2
#AutoIt3Wrapper_Outfile=会员111.exe
#AutoIt3Wrapper_Res_Comment=会员信息 DIY BASC
#AutoIt3Wrapper_Res_Description=会员信息 DIY BASC
#AutoIt3Wrapper_Res_Fileversion=1.0.0.8
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#region ### START Koda GUI section ### Form=

Local $kahao, $zhuzhi, $xingming, $mima, $sfz, $chuangkou, $mulu, $ziti
$mulu = IniRead("basc.ini", "会员信息", "mulu", "")
$ziti = IniRead("basc.ini", "会员信息", "ziti", "楷体")
$chuangkou = IniRead("basc.ini", "会员信息", "chuangkou", "金雅网吧会员卡信息")
$Form1 = GUICreate($chuangkou, 305, 271, 0, @DesktopHeight - 318, $WS_SYSMENU)
GUISetBkColor(0xABCDEF)
WinSetOnTop($Form1, "", 1);窗口前置
$Label1 = GUICtrlCreateLabel("姓名", 28, 12, 42, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label2 = GUICtrlCreateLabel("会员密码", 5, 160, 80, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label3 = GUICtrlCreateLabel("身份证号码", 6, 207, 99, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label4 = GUICtrlCreateLabel("会员卡号", 4, 111, 80, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
$Label5 = GUICtrlCreateLabel("住址", 29, 59, 42, 29)
GUICtrlSetFont(-1, 14, 400, 0, $ziti)
;~ ssdds()
$Input1 = GUICtrlCreateInput("", 109, 16, 180, 21)
GUICtrlSetFont(109, 16, 209, 21, $ziti)
$Input2 = GUICtrlCreateInput("", 108, 67, 180, 21)
GUICtrlSetFont(108, 67, 209, 21, $ziti)
$Input3 = GUICtrlCreateInput("", 106, 111, 180, 21)
GUICtrlSetFont(106, 111, 209, 21, $ziti)
$Input4 = GUICtrlCreateInput("", 106, 163, 180, 21)
GUICtrlSetFont(106, 163, 209, 21, $ziti)
$Input5 = GUICtrlCreateInput("", 108, 210, 180, 21)
GUICtrlSetFont(108, 210, 209, 21, $ziti)
GUISetState(@SW_SHOW)
AdlibRegister("ssdds",1000)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func ssdds()
        ;读取RZXCard.mdb,表为userinfo的最后一行

        Local $mdb_data_path = $mulu & "\RZXCard.mdb", $mdb_data_pwd = "rzx1218"
        Local $tblname = "userinfo"
        $addfld = ObjCreate("ADODB.Connection")
        $addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
        $RS = ObjCreate("ADODB.Recordset")
        $RS.ActiveConnection = $addfld
        $RS.Open("Select last(id_usernum) as kahao From " & $tblname & " ")
        $kahao = $RS.fields("kahao").value
        $RS.close
        $RS.Open("Select last(id_key) as mima From " & $tblname & " ")
        $mima = $RS.fields("mima").value
        $RS.close
        $RS.Open("Select last(id_idcard) as sfz From " & $tblname & " ")
        $sfz = $RS.fields("sfz").value
        $RS.close
        $RS.Open("Select last(id_workcompany) as zhuzhi From " & $tblname & " ")
        $zhuzhi = $RS.fields("zhuzhi").value
        $RS.close
        $RS.Open("Select last(id_Name) as xingming From " & $tblname & " ")
        $xingming = $RS.fields("xingming").value
        $RS.close
        $addfld.Close
        ;读取RZXCard.mdb,表为userinfo的最后一行
        $kahao = _HexToString($kahao);十六进制转换
        $zhuzhi = _HexToString($zhuzhi)
        $xingming = _HexToString($xingming)
        $mima = _HexToString($mima)
        $sfz = _HexToString($sfz)
        GUICtrlSetData($Input1, $xingming)
        GUICtrlSetData($Input2, $zhuzhi)
        GUICtrlSetData($Input3, $kahao)
        GUICtrlSetData($Input4, $mima)
        GUICtrlSetData($Input5, $sfz)
EndFunc   ;==>ssdds
 楼主| 发表于 2013-5-8 21:11:28 | 显示全部楼层
回复 11# haijie1223


    感谢了。解决了。
另外;~ ssdds()注释了,为什么FUNC还循环
发表于 2013-5-11 02:13:17 | 显示全部楼层
这个东东是任子行???
发表于 2013-5-11 02:19:03 | 显示全部楼层
学习了。。。。。
发表于 2013-5-14 20:29:11 | 显示全部楼层
学习学习了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-22 11:18 , Processed in 0.101152 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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