找回密码
 加入
搜索
查看: 4277|回复: 6

[AU3基础] 【已解决】主窗口 点关于按钮 点确定后 关闭关于 返回主窗口 该如何写脚本?

  [复制链接]
发表于 2015-1-8 15:04:34 | 显示全部楼层 |阅读模式
本帖最后由 mshuking 于 2015-1-8 15:49 编辑

主窗口 点关于按钮 点确定后 关闭关于 返回主窗口 该如何写脚本?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("关于", 184, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button1
                        #Region ### START Koda GUI section ### Form=
            $Form2 = GUICreate("关于", 338, 249, 302, 218)
            $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
            $Image1 = GUICtrlCreatePic("C:\Windows\Web\Wallpaper\Windows\img0.jpg", 16, 24, 105, 97)
            $Label1 = GUICtrlCreateLabel("产品名称", 152, 24, 52, 17)
            $Label2 = GUICtrlCreateLabel("版本", 152, 48, 28, 17)
            $Label4 = GUICtrlCreateLabel("备注", 16, 160, 28, 17)
            $Label3 = GUICtrlCreateLabel("版权", 16, 136, 28, 17)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Button2 = GUICtrlCreateButton("确定(&O)", 124, 208, 75, 25, 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###

            While 2
                     $nMsg1 = GUIGetMsg()
                     Switch $nMsg1
                         Case $GUI_EVENT_CLOSE , $Button2
                             Exit

                EndSwitch
            WEnd
        EndSwitch
WEnd
非常感谢
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
_ping()
$oIE = _IECreateEmbedded ()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("网络验证", 221, 89)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 1, 1, 1)        ;网络验证控件
$Button1 = GUICtrlCreateButton("网络验证测试", 72, 32, 84, 25)
$Button2 = GUICtrlCreateButton("测试", 72, 64, 84, 25)
GUISetState(@SW_SHOW)
GUICtrlSetState($Button1, $GUI_DISABLE);未验证前,禁止控件。
GUICtrlSetState($Button2, $GUI_DISABLE);未验证前,禁止控件。
#EndRegion ### END Koda GUI section ###
Global $yz[5][2]
 _IENavigate ($oIE, "http://hi.baidu.com/jjigwfowwkbdjtd/item/9cc6544d9df61595823ae1e7")
$html = _IEDocReadHTML($oIE)
$html=StringReplace($html,'"',"")
$html = _find_value($html,'<div id=m_blog class=modbox style=overflow-x:hidden;>',1,'<div class=opt id=blogOpt>')
$yz[0][1] = _find_value($html,'<p>',1,'</p>')
$yz[1][1] = _find_value($html,'<p>',2,'</p>')
$yz[2][1] = _find_value($html,'<p>',3,'</p>')
$yz[3][1] = _find_value($html,'<p>',4,'</p>')
;可以根据自己需要自己添加
$bb = "1.0"

If $yz[1][1] = $bb Then
        ;MsgBox(64,"更新提示","当前版本为:"& $bb & @CRLF &"新版本为:"&$yz[1][1]& @CRLF & "当前是最新版本,无须更新!")
ElseIf $yz[0][1] <> $bb Then
        MsgBox(64,"更新提示","当前版本为:"&$bb& @CRLF &"新版本为:"& $yz[1][1] & @CRLF & $yz[2][1] & @CRLF & $yz[3][1])
        Exit
EndIf
GUICtrlSetState($Button1, $GUI_ENABLE);验证通过,激活控件。
GUICtrlSetState($Button2, $GUI_ENABLE);验证通过,激活控件。
GUICtrlSetData($Button1,"网络验证通过")
GUICtrlSetData($Button2,"通过")
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
Func _find_value($or_testtxt,$key1,$key1_no,$key2)
        $position1=StringInStr($or_testtxt,$key1,0,$key1_no)+StringLen($key1)
        If $position1 Then   
                $textlen=StringInStr($or_testtxt,$key2,0,1,$position1)-$position1
                $testtxt=StringMid($or_testtxt,$position1,$textlen)
                $testtxt=StringStripWS($testtxt,3)
        Else
                $testtxt=""
        EndIf
        Return $testtxt
 
EndFunc
Func _ping()
Local $var = Ping("www.baidu.com")
If $var Then
Else
    MsgBox(64,"警告!","软件出现一个错误,错误代码: "& @error & @CRLF & @CRLF & "请检查您的网络连接,或联系作者。")
        Exit
EndIf
EndFunc
发表于 2015-1-8 15:29:26 | 显示全部楼层
回复 1# mshuking


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("关于", 184, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button1
                        #Region ### START Koda GUI section ### Form=
            $Form2 = GUICreate("关于", 338, 249, 302, 218)
            $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
            $Image1 = GUICtrlCreatePic("C:\Windows\Web\Wallpaper\Windows\img0.jpg", 16, 24, 105, 97)
            $Label1 = GUICtrlCreateLabel("产品名称", 152, 24, 52, 17)
            $Label2 = GUICtrlCreateLabel("版本", 152, 48, 28, 17)
            $Label4 = GUICtrlCreateLabel("备注", 16, 160, 28, 17)
            $Label3 = GUICtrlCreateLabel("版权", 16, 136, 28, 17)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Button2 = GUICtrlCreateButton("确定(&O)", 124, 208, 75, 25, 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###

            While 2
                     $nMsg1 = GUIGetMsg()
                     Switch $nMsg1
                         Case $GUI_EVENT_CLOSE
                             Exit
                                                 Case $Button2
                                                        GUISetState(@SW_HIDE,$Form2)
                             GUISetState(@SW_SHOW,$Form1)
                EndSwitch
            WEnd
        EndSwitch
WEnd
发表于 2015-1-8 15:31:31 | 显示全部楼层
33行exit改为以下
                                                GUIDelete($Form2)
                                                ExitLoop
发表于 2015-1-8 15:35:53 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
Dim $Form2
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Button1 = GUICtrlCreateButton("关于", 184, 184, 75, 25)
GUICtrlSetOnEvent(-1, "gy")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1

WEnd

Func gy()
        #region ### START Koda GUI section ### Form=
        $Form2 = GUICreate("关于", 338, 249, 302, 218, -1, -1, $Form1)
        GUISetOnEvent($GUI_EVENT_CLOSE, "gy_close")
        $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
        $Image1 = GUICtrlCreatePic("C:\Windows\Web\Wallpaper\Windows\img0.jpg", 16, 24, 105, 97)
        $Label1 = GUICtrlCreateLabel("产品名称", 152, 24, 52, 17)
        $Label2 = GUICtrlCreateLabel("版本", 152, 48, 28, 17)
        $Label4 = GUICtrlCreateLabel("备注", 16, 160, 28, 17)
        $Label3 = GUICtrlCreateLabel("版权", 16, 136, 28, 17)
        GUICtrlCreateGroup("", -99, -99, 1, 1)
        $Button2 = GUICtrlCreateButton("确定(&O)", 124, 208, 75, 25, 0)
        GUICtrlSetOnEvent(-1, "gy_close")
        GUISetState(@SW_SHOW)
        #endregion ### END Koda GUI section ###
EndFunc   ;==>gy

Func gy_close()
        GUIDelete($Form2)
EndFunc   ;==>gy_close

Func _Exit()
        Exit
EndFunc   ;==>_Exit
 楼主| 发表于 2015-1-8 16:07:17 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438)
$Button1 = GUICtrlCreateButton("关于", 184, 184, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button1
                        gy()
        EndSwitch
WEnd
Func gy()
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("关于", 338, 249)
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic("C:\Windows\Web\Wallpaper\Windows\img0.jpg", 16, 24, 105, 97)
$Label1 = GUICtrlCreateLabel("产品名称", 152, 24, 52, 17)
$Label2 = GUICtrlCreateLabel("版本", 152, 48, 28, 17)
$Label4 = GUICtrlCreateLabel("备注", 16, 160, 28, 17)
$Label3 = GUICtrlCreateLabel("版权", 16, 136, 28, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("确定(&O)", 124, 208, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 2
                $nMsg1 = GUIGetMsg()
                Switch $nMsg1
                Case $GUI_EVENT_CLOSE , $Button2
                        GUIDelete($Form2)
                        ExitLoop
                EndSwitch
WEnd
EndFunc
 楼主| 发表于 2015-1-12 19:04:21 | 显示全部楼层
谢谢 非常感谢
发表于 2015-1-14 16:42:20 | 显示全部楼层
感谢分享,学习了··
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 14:15 , Processed in 0.076897 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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