找回密码
 加入
搜索
查看: 2061|回复: 3

[AU3基础] 【已解决】一个If.........elseif..........endif的问题

[复制链接]
发表于 2010-10-27 19:09:27 | 显示全部楼层 |阅读模式
本帖最后由 llwan_love 于 2010-10-28 04:53 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>        
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Form1.kxf
$Form1 = GUICreate("南昌星空极速自动拨号助手", 480, 161, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Input0=GUICtrlCreateInput("", 80, 16, 337, 21)
GUICtrlSetOnEvent(-1, "Input0Change")
$Input1=GUICtrlCreateInput("", 80, 48, 337, 21)
GUICtrlSetOnEvent(-1, "Input1Change")
$Input2=GUICtrlCreateInput("", 80, 80, 337, 21)
GUICtrlSetOnEvent(-1, "Input2Change")
$Button1 = GUICtrlCreateButton("保存配置并设置为开机自动拨号", 120, 112, 225, 33)
GUICtrlSetOnEvent(-1, "Button1Click")
GUICtrlCreateLabel("程序目录:", 16, 16, 64, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("宽带账号:", 15, 50, 64, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("宽带密码:", 15, 83, 64, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("浏览", 424, 16, 41, 25)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If FileExists("fy.ini") Then
        $file = IniRead("fy.ini","设置","程序路径","配置文件fy.ini未找到!")
    If FileExists($file) Then 
         Else
         Msgbox(0, 0, "无法根据配置文件中的路径找到文件,路径设置错误,请检查配置文件中的程序路径设置。")
        EndIf
Else
EndIf
        Func Button1Click() 
                If $Input0="" Then
                 Msgbox(1, "请设置路径:", "星空极速程序路径为空,请设置!")
         ElseIf
             $Input1="" Then
                 MsgBox(1,"错误","宽带账户不能为空!")
         ElseIf
             $Input2="" Then
             MsgBox(1,"错误","宽带密码不能为空!")
                     Else
                 IniWrite("fy.ini","设置","程序路径",$Input0)
                 IniWrite("fy.ini","设置","宽带账户",$Input1)
                 IniWrite("fy.ini","设置","宽带密码",$Input2)
                 EndIf
                 EndFunc
Func Button2Click()
$mulu=FileOpenDialog("选择星空极速主程序","","可执行文件(NetKeeper.exe)",1+8)
GUICtrlSetData($Input0,$mulu)
EndFunc
运行后弹出       提示框:无法根据配置文件中的路径找到文件,路径设置错误,请检查配置文件中的程序路径设置。然后就自动关闭。怎么不会向下执行。新手初学,望各位大大给予指正,多谢!

endif不是把整个脚本结束掉吧!奇怪了。

程序目的是因为南昌校园的星空极速不会自动拨号,我想写一个开机自动运行星空极速并拨号的东西。写到这里就出现故障了。
发表于 2010-10-27 20:09:31 | 显示全部楼层
本帖最后由 lpxx 于 2010-10-27 20:12 编辑

大概帮你看了下,可能你要的效果,剩余的,相信你自己能搞定
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$File = @ScriptDir & "\fy.ini"
$check = FileExists(@ScriptDir & "\fy.ini");检查指定文件或目录是否存在
If $check = 0 Then
        MsgBox(48, "注意:", "未找到程序配置文件,程序将自动创建."& @CRLF &"路径为脚本所在路径")
        ;以下测试写配置
        IniWrite($File, "设置", "程序路径", @ScriptDir)
        IniWrite($File, "设置", "宽带账户", "youuser")
        IniWrite($File, "设置", "宽带密码", "youpass")
        ;=====
EndIf
$path = IniRead(@ScriptDir & "\fy.ini", "设置", "程序路径", "")
$user = IniRead(@ScriptDir & "\fy.ini", "设置", "宽带账户", "")
$pass = IniRead(@ScriptDir & "\fy.ini", "设置", "宽带密码", "")
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Form1.kxf
$Form1 = GUICreate("南昌星空极速自动拨号助手", 480, 161, 192, 124)
$1 = IniRead(@ScriptDir & "\fy.ini", "设置", "程序路径", "")
$2 = IniRead(@ScriptDir & "\fy.ini", "设置", "宽带账户", "")
$3 = IniRead(@ScriptDir & "\fy.ini", "设置", "宽带密码", "")
$Input0 = GUICtrlCreateInput($1, 80, 16, 337, 21)
$Input1 = GUICtrlCreateInput($2, 80, 48, 337, 21)
$Input2 = GUICtrlCreateInput($3, 80, 80, 337, 21)
$Button1 = GUICtrlCreateButton("保存配置并设置为开机自动拨号", 120, 112, 225, 33)
GUICtrlCreateLabel("程序目录:", 16, 16, 64, 20)
GUICtrlCreateLabel("宽带账号:", 15, 50, 64, 20)
GUICtrlCreateLabel("宽带密码:", 15, 83, 64, 20)
$Button2 = GUICtrlCreateButton("浏览", 424, 16, 41, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func Button1Click()
        ;=========

        ;=========
EndFunc   ;==>Button1Click
Func Button2Click()
        ;=========

        ;=========
EndFunc   ;==>Button2Click

评分

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

查看全部评分

 楼主| 发表于 2010-10-27 21:11:30 | 显示全部楼层
多谢了!应该没问题了!
发表于 2011-9-6 20:19:20 | 显示全部楼层
学习了 感谢楼主分享
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-11 19:17 , Processed in 0.082232 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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