Au3构建成功,不能运行,提示:AutoIt 错误 line -1:error:变量没有在开始声明!!
本帖最后由 19377708 于 2010-9-10 13:41 编辑EndFuncAu3构建成功,不能运行,提示:AutoIt 错误 line -1:error:变量没有在开始声明!!请高手分析一下我的源码,那里出错了,最好是有详细解释,本人刚刚接触Au3希望有详细解答,非常感谢!!!
func fanhui();问题出在这句的身上,请高手分析下,那个函数没有声明,非常感谢、#include <Process.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
If ProcessExists("elementclient.exe") Then
$mainwindow = GUICreate("完美世界", 200, 110)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("系统检测到你正在运行游戏", 27, 13)
GUICtrlCreateLabel("请退出游戏后,再运行该程序", 25,33)
$okbutton = GUICtrlCreateButton("立即关闭游戏",7,73,90)
GUICtrlSetOnEvent($okbutton, "guanbigame")
$okbutton = GUICtrlCreateButton("手动关闭游戏",105,73,90)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
while 1
Sleep(1000)
WEnd
Else
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("完美穿门程序", 329, 212)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$Button1 = GUICtrlCreateButton("确定(&O)", 64, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "queding")
$Button2 = GUICtrlCreateButton("取消(&C)", 160, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button2,"CLOSEClicked")
$Button3 = GUICtrlCreateButton("浏览(&R)", 256, 144, 67, 25, 0)
GUICtrlSetOnEvent($Button3, "liulang")
$Input1 = GUICtrlCreateInput("", 0, 146, 249, 21)
$Label1 = GUICtrlCreateLabel("欢迎使用“完美穿门程序”", 48, 16, 228, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("游戏安装目录", 16, 112, 100, 24)
$Label5 = GUICtrlCreateLabel("请选择游戏安装目录后按“确定(O)”键继续", 8, 48, 292, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
EndIf
Func liulang()
$ll=FileSelectFolder("浏览","")
If FileExists($ll) Then GUICtrlSetData($Input1,$ll)
EndFunc
Func CLOSEClicked()
Exit
EndFunc
Func qidongyouxi()
$number = GUICtrlRead($Input1)
Run($number & "\launcher\Launcher.exe")
Exit
EndFunc
Func queding()
$number = GUICtrlRead($Input1)
If FileExists($number & "\element") Then
$mainwindow = GUICreate("完美世界", 200, 175)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("完美世界穿门程序", 48, 5)
$okbutton = GUICtrlCreateButton("更改游戏为《穿门模式》",28,83,145)
GUICtrlSetOnEvent($okbutton, "chuanmenmoshi")
$okbutton = GUICtrlCreateButton("更改游戏为《默认模式》",28,113,145)
GUICtrlSetOnEvent($okbutton, "morenmoshi")
GUISetState(@SW_SHOW)
Else
MsgBox(16,"运行时出错","请输入正确的游戏路径或者复制本程序到游戏安装目录后运行")
EndIf
EndFunc
Func guanbigame()
ProcessClose("Launcher.exe")
processclose("elementclient.exe")
Sleep("500")
If ProcessExists("elementclient.exe") Then
$mainwindow = GUICreate("操作失败", 180, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("游戏退出失败", 52, 10)
GUICtrlCreateLabel("请手动退出游戏后,再运行该程序!", 5, 30)
$okbutton = GUICtrlCreateButton("确定",53,50,70)
GUICtrlSetOnEvent($okbutton, "fanhui")
GUISetState(@SW_SHOW)
Else
$mainwindow = GUICreate("操作成功", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("游戏退出成功", 48, 10)
$okbutton = GUICtrlCreateButton("确定",53,50,60)
GUICtrlSetOnEvent($okbutton, "fanhui")
GUISetState(@SW_SHOW)
EndIf
EndFunc
func fanhui();问题出在这句的身上,请高手分析下,那个函数没有声明,非常感谢、
If fileExists("element") Then
$mainwindow = GUICreate("完美世界", 200, 175)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("完美世界穿门程序", 48, 5)
$okbutton = GUICtrlCreateButton("更改游戏为《穿门模式》",28,83,145)
GUICtrlSetOnEvent($okbutton, "chuanmenmoshi")
$okbutton = GUICtrlCreateButton("更改游戏为《默认模式》",28,113,145)
GUICtrlSetOnEvent($okbutton, "morenmoshi")
GUISetState(@SW_SHOW)
Else
$Form1 = GUICreate("完美穿门程序", 329, 212)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$Button1 = GUICtrlCreateButton("确定(&O)", 64, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "queding")
$Button2 = GUICtrlCreateButton("取消(&C)", 160, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button2,"CLOSEClicked")
$Button3 = GUICtrlCreateButton("浏览(&R)", 256, 144, 67, 25, 0)
GUICtrlSetOnEvent($Button3, "liulang")
$Input1 = GUICtrlCreateInput("", 0, 146, 249, 21)
$Label1 = GUICtrlCreateLabel("欢迎使用“完美穿门程序”", 48, 16, 228, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("游戏安装目录", 16, 112, 100, 24)
$Label5 = GUICtrlCreateLabel("请选择游戏安装目录后按“确定(O)”键继续", 8, 48, 292, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
EndIf
EndFunc
Func chuanmenmoshi()
$number = GUICtrlRead($Input1)
If FileExists($number & "\element\grasses.pck.bak") Then
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《穿门模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
Else
FileCopy($number & "\element\grasses.pck", $number & "\element\grasses.pck.bak", 1)
FileCopy($number & "\element\trees.pck", $number & "\element\trees.pck.bak", 1)
FileChangeDir($number)
_RunDOS("ren element\grasses.pck grasses1.pck")
_RunDOS("ren element\trees.pck grasses.pck")
_RunDOS("ren element\grasses1.pck trees.pck")
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《穿门模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
EndIf
EndFunc
Func morenmoshi()
$number = GUICtrlRead($Input1)
if FileExists($number & "\element\grasses.pck.bak") Then
FileDelete($number & "\element\trees.pck")
FileDelete($number & "\element\grasses.pck")
sleep(100)
FileChangeDir($number)
_RunDOS("ren element\grasses.pck.bak grasses.pck")
_RunDOS("ren element\trees.pck.bak trees.pck")
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《默认模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
Else
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《默认模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
EndIf
EndFunc 本帖最后由 19377708 于 2010-9-9 18:33 编辑
回复 1# 19377708
那位大哥帮帮小弟,感激不尽! 回复 1# 19377708
源码太乱了,整理好了再拿出来提问, 这位大哥,已经按照你的要求,整理好了源码, 本帖最后由 republican 于 2010-9-9 20:55 编辑
LZ的代码确实混乱...
看的晕呼呼的,只能帮LZ整理代码了....
#include <Process.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
;~ fanhui()
If ProcessExists("elementclient.exe") Then
$mainwindow = GUICreate("完美世界", 200, 110)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("系统检测到你正在运行游戏", 27, 13)
GUICtrlCreateLabel("请退出游戏后,再运行该程序", 25,33)
$okbutton = GUICtrlCreateButton("立即关闭游戏",7,73,90)
GUICtrlSetOnEvent($okbutton, "guanbigame")
$okbutton = GUICtrlCreateButton("手动关闭游戏",105,73,90)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
while 1
Sleep(1000)
WEnd
Else
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("完美穿门程序", 329, 212)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$Button1 = GUICtrlCreateButton("确定(&O)", 64, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "queding")
$Button2 = GUICtrlCreateButton("取消(&C)", 160, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button2,"CLOSEClicked")
$Button3 = GUICtrlCreateButton("浏览(&R)", 256, 144, 67, 25, 0)
GUICtrlSetOnEvent($Button3, "liulang")
$Input1 = GUICtrlCreateInput("", 0, 146, 249, 21)
$Label1 = GUICtrlCreateLabel("欢迎使用“完美穿门程序”", 48, 16, 228, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("游戏安装目录", 16, 112, 100, 24)
$Label5 = GUICtrlCreateLabel("请选择游戏安装目录后按“确定(O)”键继续", 8, 48, 292, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
EndIf
Func liulang()
$ll=FileSelectFolder("浏览","")
If FileExists($ll) Then GUICtrlSetData($Input1,$ll)
EndFunc
Func CLOSEClicked()
Exit
EndFunc
Func qidongyouxi()
$number = GUICtrlRead($Input1)
Run($number & "\launcher\Launcher.exe")
Exit
EndFunc
Func queding()
$number = GUICtrlRead($Input1)
If FileExists($number & "\element") Then
$mainwindow = GUICreate("完美世界", 200, 175)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("完美世界穿门程序", 48, 5)
$okbutton = GUICtrlCreateButton("更改游戏为《穿门模式》",28,83,145)
GUICtrlSetOnEvent($okbutton, "chuanmenmoshi")
$okbutton = GUICtrlCreateButton("更改游戏为《默认模式》",28,113,145)
GUICtrlSetOnEvent($okbutton, "morenmoshi")
GUISetState(@SW_SHOW)
Else
MsgBox(16,"运行时出错","请输入正确的游戏路径或者复制本程序到游戏安装目录后运行")
EndIf
EndFunc
Func Exitgame()
ProcessClose("Launcher.exe")
processclose("elementclient.exe")
Sleep("500")
If ProcessExists("elementclient.exe") Then
$mainwindow = GUICreate("操作失败", 180, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("游戏退出失败", 52, 10)
GUICtrlCreateLabel("请手动退出游戏后,再运行该程序!", 5, 30)
$okbutton = GUICtrlCreateButton("确定",53,50,70)
GUICtrlSetOnEvent($okbutton, "fanhui")
GUISetState(@SW_SHOW)
Else
$mainwindow = GUICreate("操作成功", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("游戏退出成功", 48, 10)
$okbutton = GUICtrlCreateButton("确定",53,50,60)
GUICtrlSetOnEvent($okbutton, "fanhui")
GUISetState(@SW_SHOW)
EndIf
EndFunc
func fanhui();问题出在这句的身上,请高手分析下,那个函数没有声明,非常感谢、
If fileExists("element") Then
$mainwindow = GUICreate("完美世界", 200, 175)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("完美世界穿门程序", 48, 5)
$okbutton = GUICtrlCreateButton("更改游戏为《穿门模式》",28,83,145)
GUICtrlSetOnEvent($okbutton, "chuanmenmoshi")
$okbutton = GUICtrlCreateButton("更改游戏为《默认模式》",28,113,145)
GUICtrlSetOnEvent($okbutton, "morenmoshi")
GUISetState(@SW_SHOW)
Else
$Form1 = GUICreate("完美穿门程序", 329, 212)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$Button1 = GUICtrlCreateButton("确定(&O)", 64, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button1, "queding")
$Button2 = GUICtrlCreateButton("取消(&C)", 160, 176, 75, 25, 0)
GUICtrlSetOnEvent($Button2,"CLOSEClicked")
$Button3 = GUICtrlCreateButton("浏览(&R)", 256, 144, 67, 25, 0)
GUICtrlSetOnEvent($Button3, "liulang")
$Input1 = GUICtrlCreateInput("", 0, 146, 249, 21)
$Label1 = GUICtrlCreateLabel("欢迎使用“完美穿门程序”", 48, 16, 228, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("游戏安装目录", 16, 112, 100, 24)
$Label5 = GUICtrlCreateLabel("请选择游戏安装目录后按“确定(O)”键继续", 8, 48, 292, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
EndIf
EndFunc
Func chuanmenmoshi()
$number = GUICtrlRead($Input1)
If FileExists($number & "\element\grasses.pck.bak") Then
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《穿门模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
Else
FileCopy($number & "\element\grasses.pck", $number & "\element\grasses.pck.bak", 1)
FileCopy($number & "\element\trees.pck", $number & "\element\trees.pck.bak", 1)
FileChangeDir($number)
_RunDOS("ren element\grasses.pck grasses1.pck")
_RunDOS("ren element\trees.pck grasses.pck")
_RunDOS("ren element\grasses1.pck trees.pck")
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《穿门模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
EndIf
EndFunc
Func morenmoshi()
$number = GUICtrlRead($Input1)
if FileExists($number & "\element\grasses.pck.bak") Then
FileDelete($number & "\element\trees.pck")
FileDelete($number & "\element\grasses.pck")
sleep(100)
FileChangeDir($number)
_RunDOS("ren element\grasses.pck.bak grasses.pck")
_RunDOS("ren element\trees.pck.bak trees.pck")
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《默认模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
Else
$mainwindow = GUICreate("完美世界", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("《默认模式》更改成功", 22, 10)
$okbutton = GUICtrlCreateButton("运行游戏", 12, 48, 70)
GUICtrlSetOnEvent($okbutton, "qidongyouxi")
$okbutton = GUICtrlCreateButton("关闭程序", 88, 48, 70)
GUICtrlSetOnEvent($okbutton, "CLOSEClicked")
GUISetState(@SW_SHOW)
EndIf
EndFunc
Func guanbigame()
ProcessClose("Launcher.exe")
processclose("elementclient.exe")
$mainwindow = GUICreate("操作成功", 170, 80)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("游戏退出成功", 48, 10)
$okbutton = GUICtrlCreateButton("确定",53,50,60)
GUICtrlSetOnEvent($okbutton, "fanhui")
GUISetState(@SW_SHOW)
EndFunc
By the way,我这里没问题。 大哥,还是不行啊,就是返回的那一句,能显示界面,但是不能点确定啊,点确定后,提示:AutoIt 错误 line -1:error:变量没有在开始声明!!帮忙看下是那里出问题了,非常感谢!!! 首先说一句,没仔细看你这个代码,感觉这么建立界面很乱,一乱就懒得看了
不过你这个问题大概可能是变量都要声明为global,因为虽然你是在俩个界面里创建的控件,但是作为脚本,它是相同的,既然是这样,对于同一个变量不能分配两个函数,也不知道对不对,猜得 本帖最后由 19377708 于 2010-9-10 04:08 编辑
小弟刚刚开始学Au3,所以发出来的源码也比较乱,有那里做得不对,还请各位大哥能够批评指正,小弟感激不尽!!同时也希望各位大哥,能尽快的帮我解决难道、 也是初学者,希望大家一起进步 回复 1# 19377708
5楼的代码我运行也没错啊,你试试5楼的代码,你的代码实在太乱了,......... 本帖最后由 19377708 于 2010-9-10 13:14 编辑
attachimg]11092就是那句返回的代码,不能运行,能显示窗口,但是不能点击“确定”请高手帮忙分析一下,到底那里出错了,小弟感激不尽 Global $Input1 = GUICtrlCreateInput($temp, 8, 144, 225, 24)终于成功了,在前面声明这个自定义涵数或者在func fanhui() 下声明也可以,在这里非常感谢各位大哥的热心帮助,小弟在这里先谢谢各位大哥了,
页:
[1]