找回密码
 加入
搜索
查看: 1381|回复: 2

新手添加代码后运行报错

[复制链接]
发表于 2009-11-10 16:43:38 | 显示全部楼层 |阅读模式
代码是在本论坛里找到的
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=00.ico
#AutoIt3Wrapper_outfile=121.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
Opt("GUICloseOnESC", 0)
Dim $aRecords, $S = 1

        

If Not _FileReadToArray(@ScriptDir & "\资料.txt", $aRecords) Then
        MsgBox(0, "错误", "请检查身份信息文件是否存在!")
        Exit
EndIf

$Form2 = GUICreate("博吧专用", 319, 120)
$Button1 = GUICtrlCreateButton("刷新", 232, 24, 75, 20, 0)
$Button2 = GUICtrlCreateButton("填写", 232, 72, 75, 20, 0)
$Label1 = GUICtrlCreateLabel("姓  名", 16, 28, 40, 17)
$Label2 = GUICtrlCreateLabel("身份证", 16, 76, 40, 17)
$Input1 = GUICtrlCreateInput("", 64, 24, 121, 21, $ES_AUTOHSCROLL)
$Input2 = GUICtrlCreateInput("", 64, 72, 121, 21)
GUISetState(@SW_SHOW)


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        GUICtrlSetData($Input1, "")
                        GUICtrlSetData($Input2, "")
                        If $S > $aRecords[0] Then $S = 1
                        If $aRecords[$S] <> "" Then
                                $aRecords[$S] = StringStripWS($aRecords[$S], 8)
                                $Len = StringLen($aRecords[$S])
                                For $I = 1 To $Len
                                        $sfz = StringTrimLeft($aRecords[$S], $I)
                                        $Int = StringIsInt($sfz)
                                        If $Int = 1 Then
                                                $xm = StringLeft($aRecords[$S], $I)
                                                GUICtrlSetData($Input1, $xm)
                                                GUICtrlSetData($Input2, $sfz)
                                                $I = $Len
                                        EndIf
                                Next
                                $S = $S + 1
                        EndIf
                Case $Button2
                        $Exists = WinExists("常用操作", "")
                        If $Exists = 1 Then
                                WinActivate("常用操作", "")
                                WinWaitActive ("", "")
                                ControlSetText("", "", "ThunderRT6TextBox157", GUICtrlRead($Input1))
                                ControlSetText("", "", "ThunderRT6TextBox156", GUICtrlRead($Input2))
                        Else
                                MsgBox(0, "错误", "请先打开开卡页面")
                        EndIf
        EndSwitch
WEnd
我需要加入点击最小化和关闭按钮都最小化到托盘的功能,在论坛搜索到了相关代码
;下边有两种方法,自己看着用。
 
;按关闭按钮时隐藏窗口
case $msg = $GUI_EVENT_CLOSE
       GUISetState(@SW_HIDE,$hgui)
 
 
;按最小化按钮时隐藏窗口
 Case $GUI_EVENT_MINIMIZE 
                guisetstate(@SW_MINIMIZE,$hgui)
但是加入后运行是报错的
“错误: 表达式错误确 case”
 楼主| 发表于 2009-11-10 16:44:49 | 显示全部楼层
Opt("TrayIconHide", 0)
        GUISetState(@SW_HIDE, $Form1)
        TrayTip("提示:", "窗口已被最小化,单击此图标返回.", 10)



恢复窗口

Opt("TrayIconHide", 1)
        GUISetState(@SW_SHOW, $Form1)
用这个代码运行也报错,求大哥们指点一下。。
发表于 2009-11-10 17:53:32 | 显示全部楼层
$hgui
$Form1
你的窗口是$Form2啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 17:37 , Processed in 0.071223 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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