找回密码
 加入
搜索
查看: 1706|回复: 1

[AU3基础] 关于循环和修改托盘菜单的问题!!!【未解决】

[复制链接]
发表于 2011-3-13 06:17:42 | 显示全部楼层 |阅读模式
本帖最后由 wenyida 于 2011-5-19 16:33 编辑

想在这段代码中实现如下的功能,试了很多次结果都没弄出来,只好来求大家帮帮忙了

1.点击暂停子菜单后暂停脚本执行,(不知道除了循环外有没有其他办法,系统默认的暂停我已经关闭了,特殊需要)
2.脚本暂停后期间,将子菜单文本修改为恢复脚本运行。
        ;== == == == == == == == == == == == == "问题段" == == == == == == == == == == == == == ==
        $T_msg = TrayGetMsg();托盘菜单时间
        Select;托盘循环
                Case $T_msg = $SET_ini
                        SET_INI()
                Case $T_msg = $Print
                        _FilePrint("c:\PrintTemp.txt", @SW_HIDE)
                Case $T_msg = $T_pause_1
                        Sleep(60000)
                Case $T_msg = $T_pause_2
                        Sleep(30000)
                Case $T_msg = $T_pause_3

                Case $T_msg = $Exit
                        Exit
        EndSelect
        ;== == == == == == == == == == == == == "问题段" == == == == == == == == == == == == == ==
下面是完整程序代码块:
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=..\autoit3\Aut2Exe\Icons\NIS.ico
#AutoIt3Wrapper_Res_Comment=南蜀网吧专用
#AutoIt3Wrapper_Res_Description=收银辅助
#AutoIt3Wrapper_Res_FileVersion=1.0.0.7
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

#include <IE.AU3>
#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("TrayMenuMode", 11)
Opt("TrayAutoPause", 0)
Opt("MustDeclareVars", 1)

Global $R_ini_Pass, $SET_ini, $Print, $Exit, $T_msg, $T_pause, $T_pause_1, $T_pause_2, $T_pause_3

$R_ini_Pass = IniRead(@ScriptDir & "\set.ini", "Options", "PASSWORD", "");读取会员密码
$SET_ini = TrayCreateItem("设置");创建托盘菜单
TrayCreateItem("")
$Print = TrayCreateItem("重打小票")
TrayCreateItem("")
$T_pause = TrayCreateMenu("暂停")
$T_pause_1 = TrayCreateItem("暂停1分钟", $T_pause)
$T_pause_2 = TrayCreateItem("暂停30秒", $T_pause)
$T_pause_3 = TrayCreateItem("手动暂停", $T_pause)
TrayCreateItem("")
$Exit = TrayCreateItem("退出");托盘菜单创建结束


While 1;循环检测窗口
        Select
                Case WinExists("开户");检测会员&临时用户开户窗口
                        CHCK_ID();检测身份证号码&临时卡号-打印相关
                Case WinExists("会员充值");检测充值窗口
                        ControlClick("会员充值", "", "Edit1");金额输入框单击
                        WinWaitClose("会员充值");等待窗口关闭-防止连续点击
                Case WinExists("公安机关提示:请核实您登记的信息");检测临时开户
                        ControlClick("公安机关提示:请核实您登记的信息", "", "Edit1");点击姓名输入框
                        WinWaitClose("公安机关提示:请核实您登记的信息");等待窗口关闭-防止连续点击
                Case WinExists("会员信息");检测加入会员窗口
                        J_Member();检测是否未成年
                Case WinExists("会员口令");创建会员口令自动输入
                        ControlSetText("会员口令", "", "[CLASS:Edit; INSTANCE:1]", $R_ini_Pass)
                        ControlSetText("会员口令", "", "[CLASS:Edit; INSTANCE:2]", $R_ini_Pass)
                        ControlClick("会员口令", "", "[CLASS:Button; INSTANCE:18]")
                        Sleep(250)
                        Send("{ENTER}");会员创建完毕
                Case WinExists("茂谦商务点卡数字平台->订单打印");检测网页窗口-打印
                        Web_Print();转到打印相关
        EndSelect
        
        ;== == == == == == == == == == == == == "问题段" == == == == == == == == == == == == == ==
        $T_msg = TrayGetMsg();托盘菜单时间
        Select;托盘循环
                Case $T_msg = $SET_ini
                        SET_INI()
                Case $T_msg = $Print
                        _FilePrint("c:\PrintTemp.txt", @SW_HIDE)
                Case $T_msg = $T_pause_1
                        Sleep(60000)
                Case $T_msg = $T_pause_2
                        Sleep(30000)
                Case $T_msg = $T_pause_3

                Case $T_msg = $Exit
                        Exit
        EndSelect
        ;== == == == == == == == == == == == == "问题段" == == == == == == == == == == == == == ==
WEnd




Func SET_INI();托盘菜单-设置选项
        Opt("GUICloseOnESC", 1)
        Local $SET_config, $SET_label1, $SET_Label2, $SET_Label3, $SET_Label4, $SET_Input1, $SET_input2, $SET_Input3, $SET_Button1, $G_Msg
        
        $SET_config = GUICreate("设置", 298, 186, 192, 125);创建GUI
        $SET_label1 = GUICtrlCreateLabel("设置上机年龄", 8, 16, 130, 25)
        GUICtrlSetFont(-1, 16, 400, 0, "宋体")
        $SET_Input1 = GUICtrlCreateInput("", 144, 14, 145, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NOHIDESEL, $ES_NUMBER))
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
        $SET_Button1 = GUICtrlCreateButton("确定", 72, 144, 153, 33, $BS_DEFPUSHBUTTON)
        $SET_Label2 = GUICtrlCreateLabel("说明:设置年月例:199301", 16, 80, 266, 24)
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
        GUICtrlSetColor(-1, 0xFF0000)
        $SET_Label3 = GUICtrlCreateLabel("会员默认密码", 8, 114, 130, 25)
        GUICtrlSetFont(-1, 16, 400, 0, "宋体")
        $SET_input2 = GUICtrlCreateInput("123456", 144, 112, 145, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD, $ES_NUMBER))
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
        $SET_Label4 = GUICtrlCreateLabel("加入会员年龄", 8, 48, 130, 25)
        GUICtrlSetFont(-1, 16, 400, 0, "宋体")
        $SET_Input3 = GUICtrlCreateInput("", 144, 48, 145, 27)
        GUICtrlSetFont(-1, 14, 400, 0, "宋体")
        GUISetState(@SW_SHOW);创建完毕
        While 1
                $G_Msg = GUIGetMsg()
                Switch $G_Msg
                        Case -3;等待用户退出
                                GUIDelete($SET_config);销毁GUI-非完全退出
                                ExitLoop;结束GUI循环
                        Case $SET_Button1;确定按钮事件
                                Local $GET_Input1, $GET_input2, $GET_Input3
                                $GET_Input1 = ControlGetText($SET_config, "", $SET_Input1);上机年龄输入框
                                $GET_input2 = ControlGetText($SET_config, "", $SET_input2);新增会员默认密码-默认123456
                                $GET_Input3 = ControlGetText($SET_config, "", $SET_Input3);加入会员年龄输入框
                                If $GET_Input1 > 198001 And $GET_Input1 < 202212 Then;检测输入年龄是否在允许范围内
                                        If $SET_Input3 > 198001 And $SET_Input3 < 202212 Then;再次检测年龄范围确保配置文件设置
                                                If Not $GET_input2 = "" Then;检测输入密码是否为空
                                                        IniWrite(@ScriptDir & "\set.ini", "Options", "Age", $GET_Input1);写入配置文件
                                                        IniWrite(@ScriptDir & "\set.ini", "Options", "PASSWORD", $GET_input2)
                                                        IniWrite(@ScriptDir & "\set.ini", "Options", "Age2", $GET_Input3);写入完毕
                                                        MsgBox(4096, "成功", "设置成功");输出成功提示
                                                        GUIDelete($SET_config);销毁GUI
                                                        ExitLoop;结束循环
                                                Else
                                                        MsgBox(4096, "错误", "密码不能为空");空密码提示
                                                EndIf
                                        Else
                                                MsgBox(4096, "错误", "必须填写加入会员年龄");输入错误提示
                                        EndIf
                                        
                                Else
                                        MsgBox(4096, "错误", "请输入198001至202212中的年月");输入错误提示
                                EndIf
                EndSwitch
        WEnd
EndFunc   ;==>SET_INI


Func CHCK_ID();检测未成年&临时卡短ID
        Local $ID, $ID_Len, $Date, $Minor_Age, $Bar_name, $W_words, $TEL, $CR
        $Bar_name = IniRead(@ScriptDir & "\set.ini", "Options", "Barname", "男塾网吧");打印读取
        $W_words = IniRead(@ScriptDir & "\set.ini", "Options", "WelcomeWords", "欢迎光临")
        $TEL = IniRead(@ScriptDir & "\set.ini", "Options", "TEL", "")
        $CR = @CR;打印读取结束
        $Minor_Age = IniRead(@ScriptDir & "\set.ini", "Options", "Age", "");读取年龄设置
        $ID = ControlGetText("开户", "", "Static15");获取ID
        $ID_Len = StringLen($ID);计算ID长度
        If $ID_Len = 18 Then;检测是否身份证ID
                $Date = StringFromASCIIArray(StringToASCIIArray($ID, 6, 12, "ANSI"));获取持卡人年龄
                If $Date > $Minor_Age And $Date < 202201 Then;检测是否未成年
                        WinClose("开户");关闭开户窗口
                        MsgBox(0, "注意", "未成年不允许开卡!", 3);发出警告提示
                EndIf
        Else
                WinWaitClose("开户");等待窗口关闭
                _FileCreate("c:\khtemp.txt");清空文件内容
                Sleep(200)
                _FileWriteToLine("c:\khtemp.txt", 1, $Bar_name & "上机小票", 0);写入文本
                _FileWriteToLine("c:\khtemp.txt", 2, $CR, 0)
                _FileWriteToLine("c:\khtemp.txt", 3, "=====================")
                _FileWriteToLine("c:\khtemp.txt", 4, "用户编号:" & $ID, 0)
                _FileWriteToLine("c:\khtemp.txt", 5, "密码无需填写", 0)
                _FileWriteToLine("c:\khtemp.txt", 6, "=====================")
                _FileWriteToLine("c:\khtemp.txt", 7, $W_words, 0)
                _FileWriteToLine("c:\khtemp.txt", 8, "网吧电话:" & $TEL, 0);写入结束
                Sleep(200)
                _FilePrint("c:\PrintTemp.txt", @SW_HIDE);打印
        EndIf
EndFunc   ;==>CHCK_ID

Func Web_Print();网页自动打印
        Local $iehwnd, $iehwnd2, $oIE, $oIE2
        Dim $IE_Inputs, $IE_Input2
        WinExists("茂谦商务点卡数字平台->订单打印");检测窗口
        WinActivate("茂谦商务点卡数字平台->订单打印");激活窗口
        $iehwnd = WinActive("茂谦商务点卡数字平台->订单打印");获取窗口句柄
        $oIE = _IEAttach($iehwnd, "Embedded");创建对象变量
        $IE_Inputs = _IEGetObjByName($oIE, "ptprint", 1);获取特定对象
        _IEAction($IE_Inputs, "click");点击特定对象
        WinExists("茂谦商务点卡数字平台->订单打印");等待网页跳转
        WinActivate("茂谦商务点卡数字平台->订单打印");激活新窗口
        $iehwnd2 = WinActive("茂谦商务点卡数字平台->订单打印");获取窗口句柄
        $oIE2 = _IEAttach($iehwnd2, "Embedded");创建对象变量
        $IE_Input2 = _IEBodyReadText($oIE2);获取标签文本
        _FileCreate("c:\WEB_temp.txt");清空文件内容
        _FileWriteToLine("c:\WEB_temp.txt", 1, $IE_Input2, 1);从第一行起写入
        WinKill("茂谦商务点卡数字平台->订单打印");关闭网页
        WinKill("茂谦商务点卡数字平台->订单打印");关闭网页
        _FilePrint("c:\WEB_temp.txt", @SW_HIDE);打印
EndFunc   ;==>Web_Print

Func J_Member();加入会员年龄检测
        Local $Minor_Age2, $M_ID, $Date2
        $Minor_Age2 = IniRead(@ScriptDir & "\set.ini", "Options", "Age2", "");获取加入年龄
        WinExists("会员信息");再次检测窗口
        $M_ID = ControlGetText("会员信息", "", "[CLASS:Edit; INSTANCE:5]");获取ID
        $Date2 = StringFromASCIIArray(StringToASCIIArray($M_ID, 6, 12, "ANSI"));获取出生年月
        If $Date2 > $Minor_Age2 Then;检测年龄
                WinClose("会员信息");关闭窗口
                MsgBox(0, "警告", "未成年!");警告提示
        Else
                ControlClick("会员信息", "", "[CLASS:Button; INSTANCE:8]");点击指定按钮
        EndIf
EndFunc   ;==>J_Member
INI配置文件
[Options]
#会员密码
PASSWORD=123456
#上机年龄(大于设置出生年月不能上机)
Age=
#加入会员最小年龄(大于设置出生年月不能加入)
Age2=
#网吧名称
Barname=
#欢迎语
WelcomeWords=
#电话
TEL=

本帖子中包含更多资源

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

×
 楼主| 发表于 2011-3-13 12:04:52 | 显示全部楼层
居然没人回  晕死啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 10:41 , Processed in 0.079063 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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